import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1247362 - move mAnonymousGlobalScope tracing into nsMessageManagerScriptExecutor; r=mccr8 (9b33b54bc9)
- Bug 1195881 - Contextual Identity working under e10s. r=tanvi r=sicking r=baku (b3fd69bd92)
- Bug 1174624 - Add the Transferable parameter into SendAsyncMessage of nsFrameMessageManager. r=baku (33911dc6f7)
- Bug 1174624 - Add PortIdentifier copy code in order to communicate with same process. r=baku (d597f24e20)
- Bug 1234176 - Do not send memory pressure events to applications sent into the background. r=dhylands (687f154573)
- Bug 1201394 - Remove unused mLRUPoolSize member variable. r=gsvelto (a109934b8d)
- Bug 1144132 follow up to fix static check build bustage on a CLOSED TREE with r=me (050f49060e)
- Bug 1153394 - make HangMonitorChild::sInstance an atomic variable; r=billm (89e6905f3f)
- Bug 1202952 - Fix directory picking for e10s on Windows by making FilePickerParent use the correct nsIFilePicker API for directory picking. r=roc (a7e964d4fa)
- Bug 1227312 - Avoid calling FinalizeChildData twice in GenerateCompleteMinidump. r=ted (c29e6786ae)
- Bug 1222109 - Initialize mHasGamepadListener in InitializeMembers(); r=cleu (8057137e5d)
- Bug 1231498 - ContentParent::RecvCreateWindow() should fail in opt builds if passed bad chromeflags. r=billm (639fb93101)
- minor indentation (f5dbd8996c)
- fix misspatch (3b306e0084)
- Bug 1101264: Truncate long sourceName messages since they can be massive data: URLs. r=bent (c528048e58)
- Bug 1233497 - Update test_bug1086684.html to not access CPOWs unsafely inside SpecialPowers. r=mrbkap (d5d161eac2)
- align tests (24d98036dc)
- Bug 1232931 Return null instead of throwing if swm.getWorkerByID() cannot find the worker. r=ochameau IGNORE IDL for comment only change (17f293f323)
- Bug 1186812 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in dom/{ipc,plugins}/. r=jimm. (a944fa4480)
- Bug 1234656 - Add TouchEvent ctor, r=mbrubeck (842245df14)
- Bug 1246854 - Remove unnecessary warning. r=botond (7d0532e516)
- Bug 1245393 - Measure s{,Default}RootBranch in the Preferences memory reporter. r=froydnj. (be200f9ebe)
- Bug 1089232 - Updates nsContentPrefService to take an extra isPrivate argument. r=adw (9ea4fe075d)
- Bug 1229519: Fix toolkit/components/contentprefs to pass eslint checks. r=mconley (e48b64448b)
- Bug 663570 - MetaCSP Part 6: CSP preload changes (r=sicking) (65700820c1)
- Bug 1030936 - [CSP] remove fast-path for certified apps once the C++ backend is activated. r=ckerschb (e9527e9cfc)
- Bug 1228497 - initialize 3 members in class. r=christophkerschbaumer (44414e8429)
- Bug 1208946 - Strip URIs in CSP reports (r=dveditz) (dd6c18a8ff)
- Bug 1247464 - Run CSP report URIs through the URL classifier. r=ckerschb (ebb3570172)
- Bug 1242909, r=ckerschb (569de89b26)
- Bug 1119565: Ensure that a plugin listener's stream type is always set, even when it is STREAM_TYPE_UNKNOWN; r=jimm (43fb9ebdb9)
- Bug 1228116 - Relax Security checks for DTD loads. r=sicking (b77e2c4531)
- Bug 1195173 - Use channel->ascynOpen2 layout/style/Loader.cpp (r=bz) (97de97b864)
- let-var (fb35f8f50c)
- Bug 1226324 - Do not use NS_ENSURCE_SUCCESS(rv, NS_OK) within nsContentSecurityManager. r=tanvi (745ecaf562)
- Bug 1221365 - Tests for "Is origin potentially trustworthy?" logic. r=ckerschb,bkelly (1d520ebcc5)
- Bug 1132211 - Dispatch an event when <input type=password> is added to a document (including outside of a form). r=smaug (3e9acb8bf3)
- Bug 1217766 - All PDFs trigger the insecure password warning. r=MattN,bz (0ea7e35b96)
- Bug 1155471 - Mark some members of nsNodeInfoManager as MOZ_NON_OWNING_REF; r=baku (bd47bcea10)
- Tests for bug 1200856; r=sicking (454ff8048a)
- Bug 1243453 P1 Make nsCORSListenerProxy call UpdateChannel() for internal redirects. r=sicking (f2a45b1997)
- Bug 1243453 P2 Test XHR with a non-intercepting service worker. r=ehsan (d83b31ab3d)
- Bug 1169233 - Get grey (inactive) text color from menu labels. r=karlt (470155483b)
- Bug 1161056 - Gtk3 - use sMozWindowBackground colors for combobox background. r=karlt (4502f5583a)
- Bug 1169232 - [gtk3] Add background class to tooltip window to get correct background color. r=karlt (9421a23b1c)
- Bug 1219717 - Derive text color/background from GtkTextView. r=karlt (a39cd997ee)
- Bug 1241239 - Fix missing 'using mozilla::LogLevel' in nsIdleServiceGTK.cpp. r=karlt (16bacfc530)
- Bug 1209659 - Disable client-side decorations on broken Gtk3 versions (<3.20). r=karlt (d5cbd4c0fb)
- Bug 540078 - Remove assertion annotations that are no longer needed and add crashtest. (89f33bb00c)
- Bug 1168219 - Make nsIWidget::Configuration::mChild a smart pointer on widget/qt too. r=froydnj (0f2f97a31b)
- Bug 1234385: Add downloadable blocklist support for between comparison types, by recognizing driverVersionMax when parsing. r=benwa (87617d0fa1)
- Bug 1112712 - DOM key mapping for soft1 soft2 and call keys r=schien (3f4360e64b)
- Bug 1237691 - Implement Oculus Head Pose Prediction (3f6b0122e3)
- Bug 1041882 - Remove Froyo-specific OMX plugin support. r=snorp (eb2f6dd36a)
- Bug 1205930 - Tighten up warnings handling in media/omx-plugin/. r=gerald. (86845d720a)
- Bug 1153849 - Use MOZ_JPEG_CFLAGS when build libyuv with system jpeg. r=jesup (a38f53057d)
- Bug 1240635 - Interpret glyph x-offsets on SVG vertical text paths in the correct direction. r=longsonr (ce90452da1)
- Bug 1185266 - Look up painting properties on the SVGTextFrame when painting text frames that are direct children of <text>. r=jwatt (9c89ab71eb)
- Bug 1143096 - Init all WebMBufferedParser members - r=kinetik (7df2e4e0c3)
- Bug 1231855 - Avoid inserting out of (timecode) order entries in WebMBufferedParser. r=jya (f7806faec4)
This commit is contained in:
2023-12-21 11:24:17 +08:00
parent 074e62376e
commit b3dd358267
128 changed files with 1750 additions and 769 deletions
-1
View File
@@ -679,7 +679,6 @@ pref("layout.css.scroll-snap.enabled", true);
pref("dom.ipc.processPriorityManager.enabled", true);
pref("dom.ipc.processPriorityManager.backgroundGracePeriodMS", 1000);
pref("dom.ipc.processPriorityManager.backgroundPerceivableGracePeriodMS", 5000);
pref("dom.ipc.processPriorityManager.memoryPressureGracePeriodMS", 3000);
pref("dom.ipc.processPriorityManager.temporaryPriorityLockMS", 5000);
// Number of different background/foreground levels for background/foreground
+1 -3
View File
@@ -57,9 +57,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(ProcessGlobal)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
for (uint32_t i = 0; i < tmp->mAnonymousGlobalScopes.Length(); ++i) {
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mAnonymousGlobalScopes[i])
}
tmp->nsMessageManagerScriptExecutor::Trace(aCallbacks, aClosure);
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ProcessGlobal)
+1 -5
View File
@@ -1041,16 +1041,12 @@ StructuredCloneHolder::CustomReadTransferHandler(JSContext* aCx,
MOZ_ASSERT(mSupportsTransferring);
if (aTag == SCTAG_DOM_MAP_MESSAGEPORT) {
// This can be null.
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mParent);
MOZ_ASSERT(aExtraData < mPortIdentifiers.Length());
const MessagePortIdentifier& portIdentifier = mPortIdentifiers[aExtraData];
// aExtraData is the index of this port identifier.
ErrorResult rv;
RefPtr<MessagePort> port =
MessagePort::Create(window, portIdentifier, rv);
MessagePort::Create(mParent, portIdentifier, rv);
if (NS_WARN_IF(rv.Failed())) {
return false;
}
+2 -2
View File
@@ -210,7 +210,7 @@ public:
return Move(mTransferredPorts);
}
nsTArray<MessagePortIdentifier>& PortIdentifiers()
nsTArray<MessagePortIdentifier>& PortIdentifiers() const
{
MOZ_ASSERT(mSupportsTransferring);
return mPortIdentifiers;
@@ -310,7 +310,7 @@ protected:
// This array contains the identifiers of the MessagePorts. Based on these we
// are able to reconnect the new transferred ports with the other
// MessageChannel ports.
nsTArray<MessagePortIdentifier> mPortIdentifiers;
mutable nsTArray<MessagePortIdentifier> mPortIdentifiers;
#ifdef DEBUG
nsCOMPtr<nsIThread> mCreationThread;
+43 -9
View File
@@ -33,6 +33,8 @@
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/MessagePort.h"
#include "mozilla/dom/MessagePortList.h"
#include "mozilla/dom/nsIContentParent.h"
#include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/dom/ProcessGlobal.h"
@@ -274,6 +276,8 @@ BuildClonedMessageData(typename BlobTraits<Flavor>::ConcreteContentManagerType*
SerializedStructuredCloneBuffer& buffer = aClonedData.data();
buffer.data = aData.Data();
buffer.dataLength = aData.DataLength();
aClonedData.identfiers().AppendElements(aData.PortIdentifiers());
const nsTArray<RefPtr<BlobImpl>>& blobImpls = aData.BlobImpls();
if (!blobImpls.IsEmpty()) {
@@ -317,9 +321,12 @@ UnpackClonedMessageData(const ClonedMessageData& aClonedData,
const SerializedStructuredCloneBuffer& buffer = aClonedData.data();
typedef typename BlobTraits<Flavor>::ProtocolType ProtocolType;
const InfallibleTArray<ProtocolType*>& blobs = DataBlobs<Flavor>::Blobs(aClonedData);
const InfallibleTArray<MessagePortIdentifier>& identifiers = aClonedData.identfiers();
aData.UseExternalData(buffer.data, buffer.dataLength);
aData.PortIdentifiers().AppendElements(identifiers);
if (!blobs.IsEmpty()) {
uint32_t length = blobs.Length();
aData.BlobImpls().SetCapacity(length);
@@ -616,12 +623,14 @@ JSONCreator(const char16_t* aBuf, uint32_t aLen, void* aData)
static bool
GetParamsForMessage(JSContext* aCx,
const JS::Value& aValue,
const JS::Value& aTransfer,
StructuredCloneData& aData)
{
// First try to use structured clone on the whole thing.
JS::RootedValue v(aCx, aValue);
JS::RootedValue t(aCx, aTransfer);
ErrorResult rv;
aData.Write(aCx, v, rv);
aData.Write(aCx, v, t, rv);
if (!rv.Failed()) {
return true;
}
@@ -716,7 +725,7 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
}
StructuredCloneData data;
if (aArgc >= 2 && !GetParamsForMessage(aCx, aJSON, data)) {
if (aArgc >= 2 && !GetParamsForMessage(aCx, aJSON, JS::UndefinedHandleValue, data)) {
return NS_ERROR_DOM_DATA_CLONE_ERR;
}
@@ -791,11 +800,12 @@ nsFrameMessageManager::DispatchAsyncMessage(const nsAString& aMessageName,
const JS::Value& aJSON,
const JS::Value& aObjects,
nsIPrincipal* aPrincipal,
const JS::Value& aTransfers,
JSContext* aCx,
uint8_t aArgc)
{
StructuredCloneData data;
if (aArgc >= 2 && !GetParamsForMessage(aCx, aJSON, data)) {
if (aArgc >= 2 && !GetParamsForMessage(aCx, aJSON, aTransfers, data)) {
return NS_ERROR_DOM_DATA_CLONE_ERR;
}
@@ -808,7 +818,6 @@ nsFrameMessageManager::DispatchAsyncMessage(const nsAString& aMessageName,
aPrincipal);
}
// nsIMessageSender
NS_IMETHODIMP
@@ -816,11 +825,12 @@ nsFrameMessageManager::SendAsyncMessage(const nsAString& aMessageName,
JS::Handle<JS::Value> aJSON,
JS::Handle<JS::Value> aObjects,
nsIPrincipal* aPrincipal,
JS::Handle<JS::Value> aTransfers,
JSContext* aCx,
uint8_t aArgc)
{
return DispatchAsyncMessage(aMessageName, aJSON, aObjects, aPrincipal, aCx,
aArgc);
return DispatchAsyncMessage(aMessageName, aJSON, aObjects, aPrincipal,
aTransfers, aCx, aArgc);
}
@@ -833,8 +843,8 @@ nsFrameMessageManager::BroadcastAsyncMessage(const nsAString& aMessageName,
JSContext* aCx,
uint8_t aArgc)
{
return DispatchAsyncMessage(aMessageName, aJSON, aObjects, nullptr, aCx,
aArgc);
return DispatchAsyncMessage(aMessageName, aJSON, aObjects, nullptr,
JS::UndefinedHandleValue, aCx, aArgc);
}
NS_IMETHODIMP
@@ -1141,6 +1151,20 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
return NS_OK;
}
}
// Get cloned MessagePort from StructuredCloneData.
nsTArray<RefPtr<mozilla::dom::MessagePort>> ports;
if (aCloneData) {
ports = aCloneData->TakeTransferredPorts();
}
JS::Rooted<JSObject*> transferredList(cx);
RefPtr<MessagePortList> portList = new MessagePortList(aTargetFrameLoader, ports);
transferredList = portList->WrapObject(cx, nullptr);
if (NS_WARN_IF(!transferredList)) {
return NS_ERROR_UNEXPECTED;
}
JS::Rooted<JSString*> jsMessage(cx,
JS_NewUCStringCopyN(cx,
static_cast<const char16_t*>(aMessage.BeginReading()),
@@ -1152,7 +1176,9 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
JS_DefineProperty(cx, param, "sync", syncv, JSPROP_ENUMERATE) &&
JS_DefineProperty(cx, param, "json", json, JSPROP_ENUMERATE) && // deprecated
JS_DefineProperty(cx, param, "data", json, JSPROP_ENUMERATE) &&
JS_DefineProperty(cx, param, "objects", cpowsv, JSPROP_ENUMERATE);
JS_DefineProperty(cx, param, "objects", cpowsv, JSPROP_ENUMERATE) &&
JS_DefineProperty(cx, param, "ports", transferredList, JSPROP_ENUMERATE);
NS_ENSURE_TRUE(ok, NS_ERROR_UNEXPECTED);
if (aTargetFrameLoader) {
@@ -1795,6 +1821,14 @@ nsMessageManagerScriptExecutor::TryCacheLoadAndCompileScript(
TryCacheLoadAndCompileScript(aURL, aRunInGlobalScope, true, &script);
}
void
nsMessageManagerScriptExecutor::Trace(const TraceCallbacks& aCallbacks, void* aClosure)
{
for (size_t i = 0, length = mAnonymousGlobalScopes.Length(); i < length; ++i) {
aCallbacks.Trace(&mAnonymousGlobalScopes[i], "mAnonymousGlobalScopes[i]", aClosure);
}
}
bool
nsMessageManagerScriptExecutor::InitChildGlobalInternal(
nsISupports* aScope,
+3
View File
@@ -215,8 +215,10 @@ public:
const JS::Value& aJSON,
const JS::Value& aObjects,
nsIPrincipal* aPrincipal,
const JS::Value& aTransfers,
JSContext* aCx,
uint8_t aArgc);
nsresult DispatchAsyncMessageInternal(JSContext* aCx,
const nsAString& aMessage,
StructuredCloneData& aData,
@@ -397,6 +399,7 @@ protected:
void TryCacheLoadAndCompileScript(const nsAString& aURL,
bool aRunInGlobalScope);
bool InitChildGlobalInternal(nsISupports* aScope, const nsACString& aID);
void Trace(const TraceCallbacks& aCallbacks, void* aClosure);
nsCOMPtr<nsIXPConnectJSObjectHolder> mGlobal;
nsCOMPtr<nsIPrincipal> mPrincipal;
AutoTArray<JS::Heap<JSObject*>, 2> mAnonymousGlobalScopes;
+2 -1
View File
@@ -282,7 +282,8 @@ interface nsIMessageSender : nsIMessageListenerManager
void sendAsyncMessage([optional] in AString messageName,
[optional] in jsval obj,
[optional] in jsval objects,
[optional] in nsIPrincipal principal);
[optional] in nsIPrincipal principal,
[optional] in jsval transfers);
};
/**
+1 -3
View File
@@ -146,9 +146,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsInProcessTabChildGlobal,
DOMEventTargetHelper)
for (uint32_t i = 0; i < tmp->mAnonymousGlobalScopes.Length(); ++i) {
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mAnonymousGlobalScopes[i])
}
tmp->nsMessageManagerScriptExecutor::Trace(aCallbacks, aClosure);
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsInProcessTabChildGlobal,
@@ -34,6 +34,7 @@ nsNoDataProtocolContentPolicy::ShouldLoad(uint32_t aContentType,
{
MOZ_ASSERT(aContentType == nsContentUtils::InternalContentPolicyTypeToExternal(aContentType),
"We should only see external content policy types here.");
*aDecision = nsIContentPolicy::ACCEPT;
// Don't block for TYPE_OBJECT since such URIs are sometimes loaded by the
+4 -4
View File
@@ -130,13 +130,13 @@ private:
void *arg);
PLHashTable *mNodeInfoHash;
nsIDocument *mDocument; // WEAK
nsIDocument * MOZ_NON_OWNING_REF mDocument; // WEAK
uint32_t mNonDocumentNodeInfos;
nsCOMPtr<nsIPrincipal> mPrincipal; // Never null after Init() succeeds.
nsCOMPtr<nsIPrincipal> mDefaultPrincipal; // Never null after Init() succeeds
mozilla::dom::NodeInfo *mTextNodeInfo; // WEAK to avoid circular ownership
mozilla::dom::NodeInfo *mCommentNodeInfo; // WEAK to avoid circular ownership
mozilla::dom::NodeInfo *mDocumentNodeInfo; // WEAK to avoid circular ownership
mozilla::dom::NodeInfo * MOZ_NON_OWNING_REF mTextNodeInfo; // WEAK to avoid circular ownership
mozilla::dom::NodeInfo * MOZ_NON_OWNING_REF mCommentNodeInfo; // WEAK to avoid circular ownership
mozilla::dom::NodeInfo * MOZ_NON_OWNING_REF mDocumentNodeInfo; // WEAK to avoid circular ownership
RefPtr<nsBindingManager> mBindingManager;
};
+3
View File
@@ -31,6 +31,9 @@ DEFINE_KEYNAME_WITH_SAME_NAME(Unidentified)
DEFINE_KEYNAME_INTERNAL(PrintableKey, "MozPrintableKey")
DEFINE_KEYNAME_INTERNAL(HomeScreen, "MozHomeScreen")
DEFINE_KEYNAME_INTERNAL(CameraFocusAdjust, "MozCameraFocusAdjust")
DEFINE_KEYNAME_INTERNAL(PhoneCall, "MozPhoneCall")
DEFINE_KEYNAME_INTERNAL(SoftLeft, "MozSoftLeft")
DEFINE_KEYNAME_INTERNAL(SoftRight, "MozSoftRight")
/******************************************************************************
* Modifier Keys
+23 -1
View File
@@ -7,7 +7,6 @@
#include "mozilla/dom/Touch.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/dom/TouchBinding.h"
#include "mozilla/dom/TouchEvent.h"
#include "nsGlobalWindow.h"
#include "nsContentUtils.h"
@@ -16,6 +15,29 @@
namespace mozilla {
namespace dom {
// static
already_AddRefed<Touch>
Touch::Constructor(const GlobalObject& aGlobal,
const TouchInit& aParam,
ErrorResult& aRv)
{
// Annoyingly many parameters, make sure the ordering is the same as in the
// Touch constructor.
RefPtr<Touch> touch = new Touch(aParam.mTarget,
aParam.mIdentifier,
aParam.mPageX,
aParam.mPageY,
aParam.mScreenX,
aParam.mScreenY,
aParam.mClientX,
aParam.mClientY,
aParam.mRadiusX,
aParam.mRadiusY,
aParam.mRotationAngle,
aParam.mForce);
return touch.forget();
}
Touch::Touch(EventTarget* aTarget,
int32_t aIdentifier,
int32_t aPageX,
+5
View File
@@ -10,6 +10,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/EventForwards.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/dom/TouchBinding.h"
#include "nsWrapperCache.h"
#include "nsAutoPtr.h"
#include "Units.h"
@@ -28,6 +29,10 @@ class Touch final : public nsISupports
public:
static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal);
static already_AddRefed<Touch> Constructor(const GlobalObject& aGlobal,
const TouchInit& aParam,
ErrorResult& aRv);
Touch(EventTarget* aTarget,
int32_t aIdentifier,
int32_t aPageX,
+33 -1
View File
@@ -194,7 +194,6 @@ TouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
}
prefValue = sIsTouchDeviceSupportPresent;
#else
NS_WARNING("dom.w3c_touch_events.enabled=2 not implemented!");
prefValue = false;
#endif
} else {
@@ -207,6 +206,39 @@ TouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
return prefValue;
}
// static
already_AddRefed<Event>
TouchEvent::Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const TouchEventInit& aParam,
ErrorResult& aRv)
{
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
RefPtr<TouchEvent> e = new TouchEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
RefPtr<TouchList> touches = e->CopyTouches(aParam.mTouches);
RefPtr<TouchList> targetTouches = e->CopyTouches(aParam.mTargetTouches);
RefPtr<TouchList> changedTouches = e->CopyTouches(aParam.mChangedTouches);
e->InitTouchEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
aParam.mDetail, aParam.mCtrlKey, aParam.mAltKey,
aParam.mShiftKey, aParam.mMetaKey, touches, targetTouches,
changedTouches);
e->SetTrusted(trusted);
return e.forget();
}
already_AddRefed<TouchList>
TouchEvent::CopyTouches(const Sequence<OwningNonNull<Touch>>& aTouches)
{
RefPtr<TouchList> list = new TouchList(GetParentObject());
size_t len = aTouches.Length();
for (size_t i = 0; i < len; ++i) {
list->Append(aTouches[i]);
}
return list.forget();
}
bool
TouchEvent::AltKey()
{
+8
View File
@@ -95,6 +95,9 @@ public:
return TouchEventBinding::Wrap(aCx, this, aGivenProto);
}
already_AddRefed<TouchList>
CopyTouches(const Sequence<OwningNonNull<Touch>>& aTouches);
TouchList* Touches();
TouchList* TargetTouches();
TouchList* ChangedTouches();
@@ -120,6 +123,11 @@ public:
static bool PrefEnabled(JSContext* aCx = nullptr,
JSObject* aGlobal = nullptr);
static already_AddRefed<Event> Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const TouchEventInit& aParam,
ErrorResult& aRv);
protected:
~TouchEvent() {}
+20 -2
View File
@@ -1137,6 +1137,15 @@ HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
LoadImage(src, false, aNotify, eImageLoadType_Normal);
}
}
if (mType == NS_FORM_INPUT_PASSWORD && IsInComposedDoc()) {
AsyncEventDispatcher* dispatcher =
new AsyncEventDispatcher(this,
NS_LITERAL_STRING("DOMInputPasswordAdded"),
true,
true);
dispatcher->PostDOMEvent();
}
}
if (aName == nsGkAtoms::required || aName == nsGkAtoms::disabled ||
@@ -4222,11 +4231,20 @@ HTMLInputElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
// And now make sure our state is up to date
UpdateState(false);
#ifdef EARLY_BETA_OR_EARLIER
if (mType == NS_FORM_INPUT_PASSWORD) {
if (IsInComposedDoc()) {
AsyncEventDispatcher* dispatcher =
new AsyncEventDispatcher(this,
NS_LITERAL_STRING("DOMInputPasswordAdded"),
true,
true);
dispatcher->PostDOMEvent();
}
#ifdef EARLY_BETA_OR_EARLIER
Telemetry::Accumulate(Telemetry::PWMGR_PASSWORD_INPUT_IN_FORM, !!mForm);
}
#endif
}
return rv;
}
+18 -13
View File
@@ -10,22 +10,27 @@ interface nsIContentURIGrouper;
interface nsILoadContext;
interface mozIStorageConnection;
[scriptable, uuid(746c7a02-f6c1-4869-b434-7c8b86e60e61)]
[scriptable, uuid(43635c53-b445-4c4e-8cc5-562697299b55)]
interface nsIContentPrefObserver : nsISupports
{
/**
* Called when a content pref is set to a different value.
*
*
* @param aGroup the group to which the pref belongs, or null
* if it's a global pref (applies to all sites)
* @param aName the name of the pref that was set
* @param aValue the new value of the pref
* @param aIsPrivate an optional flag determining whether the
* original context is private or not
*/
void onContentPrefSet(in AString aGroup, in AString aName, in nsIVariant aValue);
void onContentPrefSet(in AString aGroup,
in AString aName,
in nsIVariant aValue,
[optional] in boolean aIsPrivate);
/**
* Called when a content pref is removed.
*
*
* @param aGroup the group to which the pref belongs, or null
* if it's a global pref (applies to all sites)
* @param aName the name of the pref that was removed
@@ -58,7 +63,7 @@ interface nsIContentPrefService : nsISupports
*
* @param aGroup the group for which to get the pref, as an nsIURI
* from which the hostname will be used, a string
* (typically in the format of a hostname), or null
* (typically in the format of a hostname), or null
* to get the global pref (applies to all sites)
* @param aName the name of the pref to get
* @param aPrivacyContext
@@ -99,7 +104,7 @@ interface nsIContentPrefService : nsISupports
* @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
*/
void setPref(in nsIVariant aGroup, in AString aName, in nsIVariant aValue, in nsILoadContext aPrivacyContext);
/**
* Check whether or not a pref exists.
*
@@ -142,7 +147,7 @@ interface nsIContentPrefService : nsISupports
* @param aGroup the group for which to remove the pref, as an nsIURI
* from which the hostname will be used, a string
* (typically in the format of a hostname), or null
* to remove the global pref (applies to all sites)
* to remove the global pref (applies to all sites)
* @param aName the name of the pref to remove
* @param aPrivacyContext
* a context from which to determine the privacy status
@@ -185,13 +190,13 @@ interface nsIContentPrefService : nsISupports
* @param aGroup the group for which to retrieve prefs, as an nsIURI
* from which the hostname will be used, a string
* (typically in the format of a hostname), or null
* to get the global prefs (apply to all sites)
* to get the global prefs (apply to all sites)
* @param aPrivacyContext
* a context from which to determine the privacy status
* of the pref (ie. whether to search for prefs in memory
* or in permanent storage), obtained from a relevant
* window or channel.
*
*
* @returns a property bag of prefs
* @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null
*/
@@ -206,21 +211,21 @@ interface nsIContentPrefService : nsISupports
* of the pref (ie. whether to search for prefs in memory
* or in permanent storage), obtained from a relevant
* window or channel.
*
*
* @returns a property bag of prefs
* @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string
*/
nsIPropertyBag2 getPrefsByName(in AString aName, in nsILoadContext aContext);
/**
* Add an observer.
*
*
* @param aName the setting to observe, or null to add
* a generic observer that observes all settings
* @param aObserver the observer to add
*/
void addObserver(in AString aName, in nsIContentPrefObserver aObserver);
/**
* Remove an observer.
*
@@ -57,7 +57,8 @@ interface nsIServiceWorkerRegistrationInfo : nsISupports
// Allows to get the related nsIServiceWorkerInfo for a given
// nsIWorkerDebugger. Over time we shouldn't need this anymore,
// and instead always control then nsIWorkerDebugger from
// nsIServiceWorkerInfo and not the other way around.
// nsIServiceWorkerInfo and not the other way around. Returns
// null if the service worker is no longer registered.
nsIServiceWorkerInfo getWorkerByID(in unsigned long long aID);
void addListener(in nsIServiceWorkerRegistrationInfoListener listener);
+3
View File
@@ -447,6 +447,9 @@ ConsoleListener::Observe(nsIConsoleMessage* aMessage)
// errors in particular share the memory for long lines with
// repeated errors, but the IPC communication we're about to do
// will break that sharing, so we better truncate now.
if (sourceName.Length() > 1000) {
sourceName.Truncate(1000);
}
if (sourceLine.Length() > 1000) {
sourceLine.Truncate(1000);
}
+15 -14
View File
@@ -480,7 +480,7 @@ public:
virtual bool RecvUnregisterSheet(const URIParams& aURI, const uint32_t& aType) override;
virtual bool RecvNotifyPhoneStateChange(const nsString& state) override;
virtual bool RecvNotifyPhoneStateChange(const nsString& aState) override;
void AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
@@ -520,6 +520,20 @@ public:
virtual bool RecvEndDragSession(const bool& aDoneDrag,
const bool& aUserCancelled) override;
virtual bool
RecvPush(const nsCString& aScope,
const IPC::Principal& aPrincipal) override;
virtual bool
RecvPushWithData(const nsCString& aScope,
const IPC::Principal& aPrincipal,
InfallibleTArray<uint8_t>&& aData) override;
virtual bool
RecvPushSubscriptionChange(const nsCString& aScope,
const IPC::Principal& aPrincipal) override;
#ifdef ANDROID
gfx::IntSize GetScreenSize() { return mScreenSize; }
#endif
@@ -618,19 +632,6 @@ private:
AppInfo mAppInfo;
virtual bool
RecvPush(const nsCString& aScope,
const IPC::Principal& aPrincipal) override;
virtual bool
RecvPushWithData(const nsCString& aScope,
const IPC::Principal& aPrincipal,
InfallibleTArray<uint8_t>&& aData) override;
virtual bool
RecvPushSubscriptionChange(const nsCString& aScope,
const IPC::Principal& aPrincipal) override;
#ifdef ANDROID
gfx::IntSize mScreenSize;
#endif
+11 -6
View File
@@ -2430,6 +2430,7 @@ ContentParent::InitializeMembers()
mShutdownPending = false;
mIPCOpen = true;
mHangMonitorActor = nullptr;
mHasGamepadListener = false;
}
bool
@@ -2473,7 +2474,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
, mOpener(aOpener)
, mIsForBrowser(aIsForBrowser)
, mIsNuwaProcess(aIsNuwaProcess)
, mHasGamepadListener(false)
{
InitializeMembers(); // Perform common initialization.
@@ -5541,10 +5541,14 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
// The content process should never be in charge of computing whether or
// not a window should be private or remote - the parent will do that.
MOZ_ASSERT(!(aChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW));
MOZ_ASSERT(!(aChromeFlags & nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW));
MOZ_ASSERT(!(aChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME));
MOZ_ASSERT(!(aChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW));
const uint32_t badFlags =
nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW
| nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW
| nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME
| nsIWebBrowserChrome::CHROME_REMOTE_WINDOW;
if (!!(aChromeFlags & badFlags)) {
return false;
}
TabParent* thisTabParent = nullptr;
if (aThisTab) {
@@ -5686,7 +5690,8 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
const char* features = aFeatures.IsVoid() ? nullptr : aFeatures.get();
*aResult = pwwatch->OpenWindow2(parent, uri, name, features, aCalledFromJS,
false, false, thisTabParent, nullptr, nullptr, getter_AddRefs(window));
false, false, thisTabParent, nullptr, nullptr,
getter_AddRefs(window));
if (NS_WARN_IF(NS_FAILED(*aResult))) {
return true;
+3 -3
View File
@@ -105,7 +105,9 @@ CrashReporterParent::GenerateCrashReportForMinidump(nsIFile* minidump,
return false;
}
return GenerateChildData(processNotes);
bool result = GenerateChildData(processNotes);
FinalizeChildData();
return result;
}
bool
@@ -151,8 +153,6 @@ CrashReporterParent::GenerateChildData(const AnnotationTable* processNotes)
if (!ret) {
NS_WARNING("problem appending child data to .extra");
}
FinalizeChildData();
return ret;
}
+10 -7
View File
@@ -31,7 +31,8 @@ public:
/*
* Attempt to create a bare-bones crash report, along with extra process-
* specific annotations present in the given AnnotationTable.
* specific annotations present in the given AnnotationTable. Calls
* GenerateChildData and FinalizeChildData.
*
* @returns true if successful, false otherwise.
*/
@@ -45,7 +46,7 @@ public:
* generate the minidumps. Crash reporter annotations set prior to this
* call will be saved via PairedDumpCallbackExtra into an .extra file
* under the proper crash id. AnnotateCrashReport annotations are not
* set in this call, use GenerateChildData.
* set in this call and the report is not finalized.
*
* @returns true if successful, false otherwise.
*/
@@ -106,8 +107,8 @@ public:
GenerateCompleteMinidump(Toplevel* t);
/**
* Submits a raw minidump handed in, calls GenerateChildData. Used
* by plugins.
* Submits a raw minidump handed in, calls GenerateChildData and
* FinalizeChildData. Used by content plugins and gmp.
*
* @returns true if successful, false otherwise.
*/
@@ -243,7 +244,9 @@ CrashReporterParent::GenerateCrashReport(Toplevel* t,
nsCOMPtr<nsIFile> crashDump;
if (t->TakeMinidump(getter_AddRefs(crashDump), nullptr) &&
CrashReporter::GetIDFromMinidump(crashDump, mChildDumpID)) {
return GenerateChildData(processNotes);
bool result = GenerateChildData(processNotes);
FinalizeChildData();
return result;
}
return false;
}
@@ -273,9 +276,9 @@ CrashReporterParent::GenerateCompleteMinidump(Toplevel* t)
nullptr, // pair with a dump of this process and thread
getter_AddRefs(childDump)) &&
CrashReporter::GetIDFromMinidump(childDump, mChildDumpID)) {
GenerateChildData(nullptr);
bool result = GenerateChildData(nullptr);
FinalizeChildData();
return true;
return result;
}
return false;
}
+9
View File
@@ -24,10 +24,19 @@ union OptionalID
void_t;
};
struct MessagePortIdentifier
{
nsID uuid;
nsID destinationUuid;
uint32_t sequenceId;
bool neutered;
};
struct ClonedMessageData
{
SerializedStructuredCloneBuffer data;
PBlob[] blobs;
MessagePortIdentifier[] identfiers;
};
union BlobData
+1 -2
View File
@@ -139,8 +139,7 @@ FilePickerParent::Done(int16_t aResult)
}
nsTArray<RefPtr<BlobImpl>> blobs;
if (mMode == nsIFilePicker::modeOpenMultiple ||
mMode == nsIFilePicker::modeGetFolder) {
if (mMode == nsIFilePicker::modeOpenMultiple) {
nsCOMPtr<nsISimpleEnumerator> iter;
NS_ENSURE_SUCCESS_VOID(mFilePicker->GetFiles(getter_AddRefs(iter)));
+2 -2
View File
@@ -106,7 +106,7 @@ class HangMonitorChild
private:
void ShutdownOnThread();
static HangMonitorChild* sInstance;
static Atomic<HangMonitorChild*> sInstance;
const RefPtr<ProcessHangMonitor> mHangMonitor;
Monitor mMonitor;
@@ -124,7 +124,7 @@ class HangMonitorChild
bool mIPCOpen;
};
HangMonitorChild* HangMonitorChild::sInstance;
Atomic<HangMonitorChild*> HangMonitorChild::sInstance;
/* Parent process objects */
+8 -37
View File
@@ -99,7 +99,7 @@ public:
/**
* Creates a new process LRU pool for the specified priority.
*/
ProcessLRUPool(ProcessPriority aPriority);
explicit ProcessLRUPool(ProcessPriority aPriority);
/**
* Used to remove a particular process priority manager from the LRU pool
@@ -116,7 +116,6 @@ public:
private:
ProcessPriority mPriority;
uint32_t mLRUPoolLevels;
uint32_t mLRUPoolSize;
nsTArray<ParticularProcessPriorityManager*> mLRUPool;
uint32_t CalculateLRULevel(uint32_t aLRUPoolIndex);
@@ -345,7 +344,6 @@ public:
private:
static uint32_t sBackgroundPerceivableGracePeriodMS;
static uint32_t sBackgroundGracePeriodMS;
static uint32_t sMemoryPressureGracePeriodMS;
void FireTestOnlyObserverNotification(
const char* aTopic,
@@ -370,7 +368,6 @@ private:
nsAutoCString mNameWithComma;
nsCOMPtr<nsITimer> mResetPriorityTimer;
nsCOMPtr<nsITimer> mMemoryPressureTimer;
};
/* static */ bool ProcessPriorityManagerImpl::sInitialized = false;
@@ -383,7 +380,6 @@ private:
ProcessPriorityManagerImpl::sSingleton;
/* static */ uint32_t ParticularProcessPriorityManager::sBackgroundPerceivableGracePeriodMS = 0;
/* static */ uint32_t ParticularProcessPriorityManager::sBackgroundGracePeriodMS = 0;
/* static */ uint32_t ParticularProcessPriorityManager::sMemoryPressureGracePeriodMS = 0;
NS_IMPL_ISUPPORTS(ProcessPriorityManagerImpl,
nsIObserver,
@@ -703,8 +699,6 @@ ParticularProcessPriorityManager::StaticInit()
"dom.ipc.processPriorityManager.backgroundPerceivableGracePeriodMS");
Preferences::AddUintVarCache(&sBackgroundGracePeriodMS,
"dom.ipc.processPriorityManager.backgroundGracePeriodMS");
Preferences::AddUintVarCache(&sMemoryPressureGracePeriodMS,
"dom.ipc.processPriorityManager.memoryPressureGracePeriodMS");
}
void
@@ -1011,28 +1005,17 @@ ParticularProcessPriorityManager::ScheduleResetPriority(TimeoutPref aTimeoutPref
}
LOGP("Scheduling reset timer to fire in %dms.", timeout);
mResetPriorityTimer = do_CreateInstance("@mozilla.org/timer;1");
mResetPriorityTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
mResetPriorityTimer->InitWithCallback(this, timeout, nsITimer::TYPE_ONE_SHOT);
}
NS_IMETHODIMP
ParticularProcessPriorityManager::Notify(nsITimer* aTimer)
{
if (mResetPriorityTimer == aTimer) {
LOGP("Reset priority timer callback; about to ResetPriorityNow.");
ResetPriorityNow();
mResetPriorityTimer = nullptr;
return NS_OK;
}
if (mContentParent && mMemoryPressureTimer == aTimer) {
Unused << mContentParent->SendFlushMemory(NS_LITERAL_STRING("lowering-priority"));
mMemoryPressureTimer = nullptr;
return NS_OK;
}
NS_WARNING("Unexpected timer!");
return NS_ERROR_INVALID_POINTER;
LOGP("Reset priority timer callback; about to ResetPriorityNow.");
ResetPriorityNow();
mResetPriorityTimer = nullptr;
return NS_OK;
}
bool
@@ -1157,18 +1140,6 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
NotifyProcessPriorityChanged(this, oldPriority);
Unused << mContentParent->SendNotifyProcessPriorityChanged(mPriority);
if (mMemoryPressureTimer) {
mMemoryPressureTimer->Cancel();
mMemoryPressureTimer = nullptr;
}
if (aPriority < PROCESS_PRIORITY_FOREGROUND) {
mMemoryPressureTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
mMemoryPressureTimer->InitWithCallback(this,
sMemoryPressureGracePeriodMS,
nsITimer::TYPE_ONE_SHOT);
}
}
FireTestOnlyObserverNotification("process-priority-set",
@@ -1361,9 +1332,9 @@ ProcessLRUPool::ProcessLRUPool(ProcessPriority aPriority)
mLRUPoolLevels <= 4);
// LRU pool size = 2 ^ (number of background LRU pool levels) - 1
mLRUPoolSize = (1 << mLRUPoolLevels) - 1;
uint32_t LRUPoolSize = (1 << mLRUPoolLevels) - 1;
LOG("Making %s LRU pool with size(%d)", str, mLRUPoolSize);
LOG("Making %s LRU pool with size(%d)", str, LRUPoolSize);
}
uint32_t
+12 -1
View File
@@ -41,6 +41,8 @@ StructuredCloneData::Copy(const StructuredCloneData& aData)
NS_ENSURE_TRUE(mSharedData, false);
}
PortIdentifiers().AppendElements(aData.PortIdentifiers());
MOZ_ASSERT(BlobImpls().IsEmpty());
BlobImpls().AppendElements(aData.BlobImpls());
@@ -66,10 +68,19 @@ void
StructuredCloneData::Write(JSContext* aCx,
JS::Handle<JS::Value> aValue,
ErrorResult &aRv)
{
Write(aCx, aValue, JS::UndefinedHandleValue, aRv);
}
void
StructuredCloneData::Write(JSContext* aCx,
JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aTransfer,
ErrorResult &aRv)
{
MOZ_ASSERT(!Data());
StructuredCloneHolder::Write(aCx, aValue, aRv);
StructuredCloneHolder::Write(aCx, aValue, aTransfer, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
+6 -1
View File
@@ -70,7 +70,7 @@ class StructuredCloneData : public StructuredCloneHolder
public:
StructuredCloneData()
: StructuredCloneHolder(StructuredCloneHolder::CloningSupported,
StructuredCloneHolder::TransferringNotSupported,
StructuredCloneHolder::TransferringSupported,
StructuredCloneHolder::DifferentProcess)
, mExternalData(nullptr)
, mExternalDataLength(0)
@@ -106,6 +106,11 @@ public:
JS::Handle<JS::Value> aValue,
ErrorResult &aRv);
void Write(JSContext* aCx,
JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aTransfers,
ErrorResult &aRv);
void UseExternalData(uint64_t* aData, size_t aDataLength)
{
MOZ_ASSERT(!Data());
+5 -4
View File
@@ -178,9 +178,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(TabChildBase)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(TabChildBase)
for (uint32_t i = 0; i < tmp->mAnonymousGlobalScopes.Length(); ++i) {
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mAnonymousGlobalScopes[i])
}
tmp->nsMessageManagerScriptExecutor::Trace(aCallbacks, aClosure);
NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TabChildBase)
@@ -870,7 +868,10 @@ TabChild::NotifyTabContextUpdated()
} else {
docShell->SetIsApp(OwnAppId());
}
docShell->SetIsSignedPackage(OriginAttributesRef().mSignedPkg);
OriginAttributes attrs = OriginAttributesRef();
docShell->SetIsSignedPackage(attrs.mSignedPkg);
docShell->SetUserContextId(attrs.mUserContextId);
}
}
+9 -7
View File
@@ -1,6 +1,6 @@
[test_blob_sliced_from_child_process.html]
# This test is only supposed to run in the main process.
skip-if = buildapp == 'b2g' || buildapp == 'mulet' || e10s
skip-if = buildapp == 'b2g' || e10s
[test_blob_sliced_from_parent_process.html]
# This test is only supposed to run in the main process.
skip-if = buildapp == 'b2g' || buildapp == 'mulet' || e10s
@@ -11,13 +11,15 @@ skip-if = toolkit != 'gonk'
[test_NuwaProcessDeadlock.html]
skip-if = toolkit != 'gonk'
[test_child_docshell.html]
run-if = toolkit != 'cocoa' # disabled due to hangs, see changeset 6852e7c47edf
skip-if = toolkit == 'cocoa' # disabled due to hangs, see changeset 6852e7c47edf
[test_CrashService_crash.html]
skip-if = !(crashreporter && !e10s && (toolkit == 'gtk2' || toolkit == 'gtk3' || toolkit == 'cocoa' || toolkit == 'windows') && (buildapp != 'b2g' || toolkit == 'gonk') && (buildapp != 'mulet')) # TC: Bug 1144079 - Re-enable Mulet mochitests and reftests taskcluster-specific disables.
[test_permission_for_in_process_app.html]
skip-if = e10s || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
skip-if = e10s || (buildapp != 'b2g' && buildapp != 'mulet') || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
support-files =
test_permission_helper.js
[test_permission_for_oop_app.html]
skip-if = buildapp == 'mulet' || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
skip-if = (buildapp != 'b2g' && buildapp != 'mulet') || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
support-files =
file_app.sjs
file_app.template.webapp
@@ -25,7 +27,7 @@ support-files =
test_permission_embed.html
test_permission_framescript.js
[test_permission_for_nested_oop_app.html]
skip-if = buildapp == 'mulet' || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
skip-if = (buildapp != 'b2g' && buildapp != 'mulet') || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
support-files =
file_app.sjs
file_app.template.webapp
@@ -33,7 +35,7 @@ support-files =
test_permission_embed.html
test_permission_framescript.js
[test_permission_for_two_oop_apps.html]
skip-if = buildapp == 'mulet' || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
skip-if = (buildapp != 'b2g' && buildapp != 'mulet') || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
support-files =
file_app.sjs
file_app.template.webapp
@@ -41,7 +43,7 @@ support-files =
test_permission_embed.html
test_permission_framescript.js
[test_permission_when_oop_app_crashes.html]
skip-if = buildapp == 'mulet' || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
skip-if = buildapp != 'b2g' || os == "android" || toolkit == "gonk" # embed-apps doesn't work in mochitest app
support-files =
file_app.sjs
file_app.template.webapp
@@ -0,0 +1,94 @@
<!DOCTYPE HTML>
<html>
<!--
Ensures that content crashes are reported to the crash service
(nsICrashService and CrashManager.jsm).
-->
<head>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7">
"use strict";
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
SpecialPowers.addPermission("browser", true, document);
SpecialPowers.pushPrefEnv({'set':[
["dom.mozBrowserFramesEnabled", true],
["dom.ipc.tabs.disabled", false]
]}, function () {
var iframe = document.createElementNS('http://www.w3.org/1999/xhtml', 'iframe');
iframe.setAttribute("remote", "true");
SpecialPowers.wrap(iframe).mozbrowser = true;
document.documentElement.appendChild(iframe);
SimpleTest.expectChildProcessCrash();
var crashMan =
SpecialPowers.Cu.import("resource://gre/modules/Services.jsm").
Services.crashmanager;
// First, clear the crash record store.
info("Waiting for pruneOldCrashes");
var future = new Date(Date.now() + 1000 * 60 * 60 * 24);
crashMan.pruneOldCrashes(future).then(function () {
var crashDateMS = Date.now();
// Inject a frame script that crashes the content process.
var mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
mm.loadFrameScript('data:,new ' + function ContentScriptScope() {
let Cu = Components.utils;
Cu.import("resource://gre/modules/ctypes.jsm");
let crash = function() {
let zero = new ctypes.intptr_t(8);
let badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t));
badptr.contents;
};
privateNoteIntentionalCrash();
crash();
}, false);
// Finally, poll for the new crash record.
function tryGetCrash() {
info("Waiting for getCrashes");
crashMan.getCrashes().then(SpecialPowers.wrapCallback(function (crashes) {
if (crashes.length) {
is(crashes.length, 1, "There should be only one record");
var crash = crashes[0];
ok(crash.isOfType(crashMan.PROCESS_TYPE_CONTENT,
crashMan.CRASH_TYPE_CRASH),
"Record should be a content crash");
ok(!!crash.id, "Record should have an ID");
ok(!!crash.crashDate, "Record should have a crash date");
var dateMS = crash.crashDate.valueOf();
var twoMin = 1000 * 60 * 2;
ok(crashDateMS - twoMin <= dateMS &&
dateMS <= crashDateMS + twoMin,
"Record's crash date should be nowish: " +
"now=" + crashDateMS + " recordDate=" + dateMS);
SimpleTest.finish();
}
else {
setTimeout(tryGetCrash, 1000);
}
}), function (err) {
ok(false, "Error getting crashes: " + err);
SimpleTest.finish();
});
}
setTimeout(tryGetCrash, 1000);
}, function () {
ok(false, "pruneOldCrashes error");
SimpleTest.finish();
});
});
</script>
</body>
</html>
+1 -1
View File
@@ -1,5 +1,5 @@
Components.utils.import("resource://gre/modules/Services.jsm");
let cm = Services.crashmanager;
var cm = Services.crashmanager;
var cpIdList = [];
var shutdownObs = {
+10 -7
View File
@@ -10,10 +10,13 @@
using namespace mozilla;
// "test.webm" contains 8 SimpleBlocks in a single Cluster with the following attributes
static const uint64_t gTimecodes[] = { 66000000, 160000000, 100000000, 133000000,
166000000, 200000000, 233000000, 320000000 };
static const int64_t gEndOffsets[] = { 501, 772, 930, 1085, 1244, 1380, 1543, 2015 };
// "test.webm" contains 8 SimpleBlocks in a single Cluster. The blocks with
// timecodes 100000000 and are 133000000 skipped by WebMBufferedParser
// because they occur after a block with timecode 160000000 and the parser
// expects in-order timecodes per the WebM spec. The remaining 6
// SimpleBlocks have the following attributes:
static const uint64_t gTimecodes[] = { 66000000, 160000000, 166000000, 200000000, 233000000, 320000000 };
static const int64_t gEndOffsets[] = { 501, 772, 1244, 1380, 1543, 2015 };
TEST(WebMBuffered, BasicTests)
{
@@ -66,7 +69,7 @@ TEST(WebMBuffered, RealData)
nsTArray<WebMTimeDataOffset> mapping;
parser.Append(webmData.Elements(), webmData.Length(), mapping, dummy);
EXPECT_EQ(mapping.Length(), 8u);
EXPECT_EQ(mapping.Length(), 6u);
EXPECT_EQ(parser.mStartOffset, 0);
EXPECT_EQ(parser.mCurrentOffset, int64_t(webmData.Length()));
EXPECT_EQ(parser.GetTimecodeScale(), 500000u);
@@ -95,7 +98,7 @@ TEST(WebMBuffered, RealDataAppend)
EXPECT_EQ(parser.mCurrentOffset, int64_t(offset));
if (mapping.Length() != arrayEntries) {
arrayEntries = mapping.Length();
ASSERT_LE(arrayEntries, 8u);
ASSERT_LE(arrayEntries, 6u);
uint32_t i = arrayEntries - 1;
EXPECT_EQ(mapping[i].mEndOffset, gEndOffsets[i]);
EXPECT_EQ(mapping[i].mSyncOffset, 361);
@@ -103,7 +106,7 @@ TEST(WebMBuffered, RealDataAppend)
EXPECT_EQ(parser.GetTimecodeScale(), 500000u);
}
}
EXPECT_EQ(mapping.Length(), 8u);
EXPECT_EQ(mapping.Length(), 6u);
EXPECT_EQ(parser.mStartOffset, 0);
EXPECT_EQ(parser.mCurrentOffset, int64_t(webmData.Length()));
EXPECT_EQ(parser.GetTimecodeScale(), 500000u);
+22 -3
View File
@@ -9,8 +9,12 @@
#include "nsThreadUtils.h"
#include <algorithm>
#define WEBM_DEBUG(arg, ...) MOZ_LOG(gWebMDemuxerLog, mozilla::LogLevel::Debug, ("WebMBufferedParser(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
namespace mozilla {
extern LazyLogModule gWebMDemuxerLog;
static uint32_t
VIntLength(unsigned char aFirstByte, uint32_t* aMask)
{
@@ -183,9 +187,20 @@ void WebMBufferedParser::Append(const unsigned char* aBuffer, uint32_t aLength,
MOZ_ASSERT(mGotTimecodeScale);
uint64_t absTimecode = mClusterTimecode + mBlockTimecode;
absTimecode *= mTimecodeScale;
WebMTimeDataOffset entry(endOffset, absTimecode, mLastInitStartOffset,
mClusterOffset, mClusterEndOffset);
aMapping.InsertElementAt(idx, entry);
// Avoid creating an entry if the timecode is out of order
// (invalid according to the WebM specification) so that
// ordering invariants of aMapping are not violated.
if (idx == 0 ||
aMapping[idx - 1].mTimecode <= absTimecode ||
(idx + 1 < aMapping.Length() &&
aMapping[idx + 1].mTimecode >= absTimecode)) {
WebMTimeDataOffset entry(endOffset, absTimecode, mLastInitStartOffset,
mClusterOffset, mClusterEndOffset);
aMapping.InsertElementAt(idx, entry);
} else {
WEBM_DEBUG("Out of order timecode %llu in Cluster at %lld ignored",
absTimecode, mClusterOffset);
}
}
}
}
@@ -302,6 +317,7 @@ bool WebMBufferedState::CalculateBufferedForRange(int64_t aStartOffset, int64_t
"Must have found greatest WebMTimeDataOffset for end");
}
MOZ_ASSERT(mTimeMapping[end].mTimecode >= mTimeMapping[end - 1].mTimecode);
uint64_t frameDuration = mTimeMapping[end].mTimecode - mTimeMapping[end - 1].mTimecode;
*aStartTime = mTimeMapping[start].mTimecode;
*aEndTime = mTimeMapping[end].mTimecode + frameDuration;
@@ -471,3 +487,6 @@ WebMBufferedState::GetNextKeyframeTime(uint64_t aTime, uint64_t* aKeyframeTime)
return true;
}
} // namespace mozilla
#undef WEBM_DEBUG
+9
View File
@@ -60,10 +60,19 @@ struct WebMBufferedParser
, mInitEndOffset(-1)
, mBlockEndOffset(-1)
, mState(READ_ELEMENT_ID)
, mNextState(READ_ELEMENT_ID)
, mVIntRaw(false)
, mLastInitStartOffset(-1)
, mClusterSyncPos(0)
, mVIntLeft(0)
, mBlockSize(0)
, mClusterTimecode(0)
, mClusterOffset(0)
, mClusterEndOffset(-1)
, mBlockOffset(0)
, mBlockTimecode(0)
, mBlockTimecodeLength(0)
, mSkipBytes(0)
, mTimecodeScale(1000000)
, mGotTimecodeScale(false)
{
+13 -11
View File
@@ -116,13 +116,10 @@ public:
JSContext* cx = jsapi.cx();
nsCOMPtr<nsPIDOMWindow> window =
do_QueryInterface(mPort->GetParentObject());
ErrorResult rv;
JS::Rooted<JS::Value> value(cx);
mData->Read(window, cx, &value, rv);
mData->Read(mPort->GetParentObject(), cx, &value, rv);
if (NS_WARN_IF(rv.Failed())) {
return rv.StealNSResult();
}
@@ -282,15 +279,20 @@ NS_IMPL_ISUPPORTS(ForceCloseHelper, nsIIPCBackgroundChildCreateCallback)
} // namespace
MessagePort::MessagePort(nsPIDOMWindow* aWindow)
: DOMEventTargetHelper(aWindow)
, mInnerID(0)
MessagePort::MessagePort(nsISupports* aSupports)
: mInnerID(0)
, mMessageQueueEnabled(false)
, mIsKeptAlive(false)
{
mIdentifier = new MessagePortIdentifier();
mIdentifier->neutered() = true;
mIdentifier->sequenceId() = 0;
nsCOMPtr<nsIGlobalObject> globalObject = do_QueryInterface(aSupports);
if (NS_WARN_IF(!globalObject)) {
return;
}
BindToOwner(globalObject);
}
MessagePort::~MessagePort()
@@ -300,21 +302,21 @@ MessagePort::~MessagePort()
}
/* static */ already_AddRefed<MessagePort>
MessagePort::Create(nsPIDOMWindow* aWindow, const nsID& aUUID,
MessagePort::Create(nsISupports* aSupport, const nsID& aUUID,
const nsID& aDestinationUUID, ErrorResult& aRv)
{
RefPtr<MessagePort> mp = new MessagePort(aWindow);
RefPtr<MessagePort> mp = new MessagePort(aSupport);
mp->Initialize(aUUID, aDestinationUUID, 1 /* 0 is an invalid sequence ID */,
false /* Neutered */, eStateUnshippedEntangled, aRv);
return mp.forget();
}
/* static */ already_AddRefed<MessagePort>
MessagePort::Create(nsPIDOMWindow* aWindow,
MessagePort::Create(nsISupports* aSupport,
const MessagePortIdentifier& aIdentifier,
ErrorResult& aRv)
{
RefPtr<MessagePort> mp = new MessagePort(aWindow);
RefPtr<MessagePort> mp = new MessagePort(aSupport);
mp->Initialize(aIdentifier.uuid(), aIdentifier.destinationUuid(),
aIdentifier.sequenceId(), aIdentifier.neutered(),
eStateEntangling, aRv);
+3 -3
View File
@@ -47,11 +47,11 @@ public:
DOMEventTargetHelper)
static already_AddRefed<MessagePort>
Create(nsPIDOMWindow* aWindow, const nsID& aUUID,
Create(nsISupports* aSupport, const nsID& aUUID,
const nsID& aDestinationUUID, ErrorResult& aRv);
static already_AddRefed<MessagePort>
Create(nsPIDOMWindow* aWindow, const MessagePortIdentifier& aIdentifier,
Create(nsISupports* aSupport, const MessagePortIdentifier& aIdentifier,
ErrorResult& aRv);
// For IPC.
@@ -90,7 +90,7 @@ public:
void Closed();
private:
explicit MessagePort(nsPIDOMWindow* aWindow);
explicit MessagePort(nsISupports* nsISupports);
~MessagePort();
enum State {
+1 -9
View File
@@ -5,19 +5,11 @@
include protocol PBackground;
include protocol PBlob;
using struct nsID from "nsID.h";
include DOMTypes;
namespace mozilla {
namespace dom {
struct MessagePortIdentifier
{
nsID uuid;
nsID destinationUuid;
uint32_t sequenceId;
bool neutered;
};
struct MessagePortMessage
{
MessagePortIdentifier[] transferredPorts;
@@ -334,7 +334,8 @@ nsNPAPIPluginStreamListener::OnStartBinding(nsPluginStreamListenerPeer* streamPe
if (streamType == nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN) {
SuspendRequest();
} else if (!SetStreamType(streamType, false)) {
}
if (!SetStreamType(streamType, false)) {
return NS_ERROR_FAILURE;
}
@@ -364,6 +365,12 @@ nsNPAPIPluginStreamListener::SetStreamType(uint16_t aType, bool aNeedsResume)
// instance is destroyed.
NS_ADDREF_THIS();
break;
case nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN:
MOZ_ASSERT(!aNeedsResume);
mStreamType = nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN;
// In this case we just want to set mStreamType but we do not want to
// execute anything else in this function.
return true;
default:
return false;
}
@@ -1182,6 +1182,7 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
void
nsPluginStreamListenerPeer::OnStreamTypeSet(const int32_t aStreamType)
{
MOZ_ASSERT(aStreamType != STREAM_TYPE_UNKNOWN);
MOZ_ASSERT(mRequest);
mStreamType = aStreamType;
if (!mUseLocalCache && mStreamType >= NP_ASFILE) {
@@ -1198,8 +1199,6 @@ nsPluginStreamListenerPeer::OnStreamTypeSet(const int32_t aStreamType)
}
}
const int32_t nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN = UINT16_MAX;
nsresult
nsPluginStreamListenerPeer::OnFileAvailable(nsIFile* aFile)
{
@@ -131,7 +131,9 @@ public:
// Called by nsNPAPIPluginStreamListener
void OnStreamTypeSet(const int32_t aStreamType);
static const int32_t STREAM_TYPE_UNKNOWN;
enum {
STREAM_TYPE_UNKNOWN = UINT16_MAX
};
private:
nsresult SetUpStreamListener(nsIRequest* request, nsIURI* aURL);
+5 -29
View File
@@ -1759,7 +1759,7 @@ PluginInstanceParent::NPP_NewStream(NPMIMEType type, NPStream* stream,
MOZ_ASSERT(mSurrogate);
mSurrogate->AsyncCallDeparting();
if (SendAsyncNPP_NewStream(bs, NullableString(type), seekable)) {
*stype = UINT16_MAX;
*stype = nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN;
} else {
err = NPERR_GENERIC_ERROR;
}
@@ -1822,31 +1822,6 @@ PluginInstanceParent::AllocPPluginScriptableObjectParent()
return new PluginScriptableObjectParent(Proxy);
}
#ifdef DEBUG
namespace {
struct ActorSearchData
{
PluginScriptableObjectParent* actor;
bool found;
};
PLDHashOperator
ActorSearch(NPObject* aKey,
PluginScriptableObjectParent* aData,
void* aUserData)
{
ActorSearchData* asd = reinterpret_cast<ActorSearchData*>(aUserData);
if (asd->actor == aData) {
asd->found = true;
return PL_DHASH_STOP;
}
return PL_DHASH_NEXT;
}
} // namespace
#endif // DEBUG
bool
PluginInstanceParent::DeallocPPluginScriptableObjectParent(
PPluginScriptableObjectParent* aObject)
@@ -1862,9 +1837,10 @@ PluginInstanceParent::DeallocPPluginScriptableObjectParent(
}
#ifdef DEBUG
else {
ActorSearchData asd = { actor, false };
mScriptableObjects.EnumerateRead(ActorSearch, &asd);
NS_ASSERTION(!asd.found, "Actor in the hash with a null NPObject!");
for (auto iter = mScriptableObjects.Iter(); !iter.Done(); iter.Next()) {
NS_ASSERTION(actor != iter.UserData(),
"Actor in the hash with a null NPObject!");
}
}
#endif
+8
View File
@@ -1285,6 +1285,8 @@ PluginModuleChromeParent::TerminateChildProcess(MessageLoop* aMsgLoop,
}
if (reportsReady) {
// Important to set this here, it tells the ActorDestroy handler
// that we have an existing crash report that needs to be finalized.
mPluginDumpID = crashReporter->ChildDumpID();
PLUGIN_LOG_DEBUG(
("generated paired browser/plugin minidumps: %s)",
@@ -1532,7 +1534,13 @@ PluginModuleChromeParent::ProcessFirstMinidump()
WriteExtraDataForMinidump(notes);
if (!mPluginDumpID.IsEmpty()) {
// mPluginDumpID may be set in TerminateChildProcess, which means the
// process hang monitor has already collected a 3-way browser, plugin,
// content crash report. If so, update the existing report with our
// annotations and finalize it. If not, fall through for standard
// plugin crash report handling.
crashReporter->GenerateChildData(&notes);
crashReporter->FinalizeChildData();
return;
}
@@ -33,7 +33,7 @@ XPCOMUtils.defineLazyGetter(this, "GP", function() {
return obj;
});
let DEBUG = SE.DEBUG_ACE;
var DEBUG = SE.DEBUG_ACE;
function debug(msg) {
if (DEBUG) {
dump("-*- GPAccessRulesManager " + msg);
+2 -2
View File
@@ -7,14 +7,14 @@
/* exported run_test */
Components.utils.import("resource://gre/modules/SEUtils.jsm");
let GP = {};
var GP = {};
Components.utils.import("resource://gre/modules/gp_consts.js", GP);
const VALID_HEX_STR = "0123456789ABCDEF";
const VALID_BYTE_ARR = [0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF];
// This set should be what the actual ACE uses.
let containerTags = [
var containerTags = [
GP.TAG_SEQUENCE,
GP.TAG_FCP,
GP.TAG_GPD_AID,
+67 -19
View File
@@ -114,9 +114,7 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
CSPCONTEXTLOG((">>>> aContentType: %d", aContentType));
}
bool isStyleOrScriptPreLoad =
(aContentType == nsIContentPolicy::TYPE_INTERNAL_SCRIPT_PRELOAD ||
aContentType == nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD);
bool isPreload = nsContentUtils::IsPreloadType(aContentType);
// Since we know whether we are dealing with a preload, we have to convert
// the internal policytype ot the external policy type before moving on.
@@ -155,7 +153,7 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
}
nsAutoString nonce;
if (!isStyleOrScriptPreLoad) {
if (!isPreload) {
if (aContentType == nsIContentPolicy::TYPE_SCRIPT ||
aContentType == nsIContentPolicy::TYPE_STYLESHEET) {
nsCOMPtr<nsIDOMHTMLElement> htmlElement = do_QueryInterface(aRequestContext);
@@ -175,7 +173,7 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
originalURI,
nonce,
wasRedirected,
isStyleOrScriptPreLoad,
isPreload,
false, // allow fallback to default-src
true, // send violation reports
true); // send blocked URI in violation reports
@@ -184,7 +182,7 @@ nsCSPContext::ShouldLoad(nsContentPolicyType aContentType,
: nsIContentPolicy::REJECT_SERVER;
// Done looping, cache any relevant result
if (cacheKey.Length() > 0 && !isStyleOrScriptPreLoad) {
if (cacheKey.Length() > 0 && !isPreload) {
mShouldLoadCache.Put(cacheKey, *outDecision);
}
@@ -607,6 +605,7 @@ nsCSPContext::SetRequestContext(nsIDOMDocument* aDOMDocument,
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDOMDocument);
mLoadingContext = do_GetWeakReference(doc);
mSelfURI = doc->GetDocumentURI();
mLoadingPrincipal = doc->NodePrincipal();
doc->GetReferrer(mReferrer);
mInnerWindowID = doc->InnerWindowID();
// the innerWindowID is not available for CSPs delivered through the
@@ -684,6 +683,51 @@ nsCSPContext::logToConsole(const char16_t* aName,
aSeverityFlag, "CSP", mInnerWindowID);
}
/**
* Strip URI for reporting according to:
* http://www.w3.org/TR/CSP/#violation-reports
*
* @param aURI
* The uri to be stripped for reporting
* @param aProtectedResourcePrincipal
* The loadingPrincipal of the protected resource
* which is needed to enforce the SOP.
* @return ASCII serialization of the uri to be reported.
*/
void
StripURIForReporting(nsIURI* aURI,
nsIPrincipal* aProtectedResourcePrincipal,
nsACString& outStrippedURI)
{
// 1) If the origin of uri is a globally unique identifier (for example,
// aURI has a scheme of data, blob, or filesystem), then return the
// ASCII serialization of uris scheme.
bool isHttp =
(NS_SUCCEEDED(aURI->SchemeIs("http", &isHttp)) && isHttp) ||
(NS_SUCCEEDED(aURI->SchemeIs("https", &isHttp)) && isHttp);
if (!isHttp) {
// not strictly spec compliant, but what we really care about is
// http/https. If it's not http/https, then treat aURI as if
// it's a globally unique identifier and just return the scheme.
aURI->GetScheme(outStrippedURI);
return;
}
// 2) If the origin of uri is not the same as the origin of the protected
// resource, then return the ASCII serialization of uris origin.
bool sameOrigin =
NS_SUCCEEDED(aProtectedResourcePrincipal->CheckMayLoad(aURI, false, false));
if (!sameOrigin) {
// cross origin redirects also fall into this category, see:
// http://www.w3.org/TR/CSP/#violation-reports
aURI->GetPrePath(outStrippedURI);
return;
}
// 3) Return uri, with any fragment component removed.
aURI->GetSpecIgnoringRef(outStrippedURI);
}
/**
* Sends CSP violation reports to all sources listed under report-uri.
*
@@ -730,15 +774,7 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
nsCOMPtr<nsIURI> uri = do_QueryInterface(aBlockedContentSource);
// could be a string or URI
if (uri) {
// aOriginalURI will only be *not* null in case of a redirect in which
// case aOriginalURI is the uri before the redirect.
if (aOriginalURI) {
// do not report anything else than the origin in case of a redirect, see:
// http://www.w3.org/TR/CSP/#violation-reports
uri->GetPrePath(reportBlockedURI);
} else {
uri->GetSpecIgnoringRef(reportBlockedURI);
}
StripURIForReporting(uri, mLoadingPrincipal, reportBlockedURI);
} else {
nsCOMPtr<nsISupportsCString> cstr = do_QueryInterface(aBlockedContentSource);
if (cstr) {
@@ -755,7 +791,7 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
// document-uri
nsAutoCString reportDocumentURI;
mSelfURI->GetSpecIgnoringRef(reportDocumentURI);
StripURIForReporting(mSelfURI, mLoadingPrincipal, reportDocumentURI);
report.mCsp_report.mDocument_uri = NS_ConvertUTF8toUTF16(reportDocumentURI);
// original-policy
@@ -827,19 +863,26 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
}
// try to create a new channel for every report-uri
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL | nsIChannel::LOAD_CLASSIFY_URI;
if (doc) {
rv = NS_NewChannel(getter_AddRefs(reportChannel),
reportURI,
doc,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_CSP_REPORT);
nsIContentPolicy::TYPE_CSP_REPORT,
nullptr, // aLoadGroup
nullptr, // aCallbacks
loadFlags);
}
else {
rv = NS_NewChannel(getter_AddRefs(reportChannel),
reportURI,
mLoadingPrincipal,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
nsIContentPolicy::TYPE_CSP_REPORT);
nsIContentPolicy::TYPE_CSP_REPORT,
nullptr, // aLoadGroup
nullptr, // aCallbacks
loadFlags);
}
if (NS_FAILED(rv)) {
@@ -892,7 +935,12 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(reportChannel));
NS_ASSERTION(uploadChannel, "nsIUploadChannel is needed but not available to send CSP violation reports");
if (!uploadChannel) {
// It's possible the URI provided can't be uploaded to, in which case
// we skip this one. We'll already have warned about a non-HTTP URI earlier.
continue;
}
rv = uploadChannel->SetUploadStream(sis, NS_LITERAL_CSTRING("application/json"), -1);
NS_ENSURE_SUCCESS(rv, rv);
+4 -1
View File
@@ -122,12 +122,15 @@ nsCSPParser::nsCSPParser(cspTokens& aTokens,
nsIURI* aSelfURI,
nsCSPContext* aCSPContext,
bool aDeliveredViaMetaTag)
: mHasHashOrNonce(false)
: mCurChar(nullptr)
, mEndChar(nullptr)
, mHasHashOrNonce(false)
, mUnsafeInlineKeywordSrc(nullptr)
, mChildSrc(nullptr)
, mFrameSrc(nullptr)
, mTokens(aTokens)
, mSelfURI(aSelfURI)
, mPolicy(nullptr)
, mCSPContext(aCSPContext)
, mDeliveredViaMetaTag(aDeliveredViaMetaTag)
{
+80 -116
View File
@@ -135,104 +135,63 @@ CSPService::ShouldLoad(uint32_t aContentType,
return NS_OK;
}
// ----- THIS IS A TEMPORARY FAST PATH FOR CERTIFIED APPS. -----
// ----- PLEASE REMOVE ONCE bug 925004 LANDS. -----
// Cache the app status for this origin.
uint16_t status = nsIPrincipal::APP_STATUS_NOT_INSTALLED;
nsAutoCString sourceOrigin;
if (aRequestPrincipal && aRequestOrigin) {
aRequestOrigin->GetPrePath(sourceOrigin);
if (!mAppStatusCache.Get(sourceOrigin, &status)) {
aRequestPrincipal->GetAppStatus(&status);
mAppStatusCache.Put(sourceOrigin, status);
}
}
if (status == nsIPrincipal::APP_STATUS_CERTIFIED) {
// The CSP for certified apps is :
// "default-src * data: blob:; script-src 'self'; object-src 'none'; style-src 'self' app://theme.gaiamobile.org:*"
// That means we can optimize for this case by:
// - loading same origin scripts and stylesheets, and stylesheets from the
// theme url space.
// - never loading objects.
// - accepting everything else.
switch (aContentType) {
case nsIContentPolicy::TYPE_SCRIPT:
case nsIContentPolicy::TYPE_STYLESHEET:
{
// Whitelist the theme resources.
auto themeOrigin = Preferences::GetCString("b2g.theme.origin");
nsAutoCString contentOrigin;
aContentLocation->GetPrePath(contentOrigin);
if (!(sourceOrigin.Equals(contentOrigin) ||
(themeOrigin && themeOrigin.Equals(contentOrigin)))) {
*aDecision = nsIContentPolicy::REJECT_SERVER;
}
}
break;
case nsIContentPolicy::TYPE_OBJECT:
*aDecision = nsIContentPolicy::REJECT_SERVER;
break;
default:
*aDecision = nsIContentPolicy::ACCEPT;
}
// Only cache and return if we are successful. If not, we want the error
// to be reported, and thus fallback to the slow path.
if (*aDecision == nsIContentPolicy::ACCEPT) {
return NS_OK;
}
}
// ----- END OF TEMPORARY FAST PATH FOR CERTIFIED APPS. -----
// query the principal of the document; if no document is passed, then
// fall back to using the requestPrincipal (e.g. service workers do not
// pass a document).
nsCOMPtr<nsINode> node(do_QueryInterface(aRequestContext));
nsCOMPtr<nsIPrincipal> principal = node ? node->NodePrincipal()
: aRequestPrincipal;
if (principal) {
nsCOMPtr<nsIContentSecurityPolicy> csp;
principal->GetCsp(getter_AddRefs(csp));
if (!principal) {
// if we can't query a principal, then there is nothing to do.
return NS_OK;
}
nsresult rv = NS_OK;
if (csp) {
if (MOZ_LOG_TEST(gCspPRLog, LogLevel::Debug)) {
uint32_t numPolicies = 0;
nsresult rv = csp->GetPolicyCount(&numPolicies);
if (NS_SUCCEEDED(rv)) {
for (uint32_t i=0; i<numPolicies; i++) {
nsAutoString policy;
csp->GetPolicy(i, policy);
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("Document has CSP[%d]: %s", i,
NS_ConvertUTF16toUTF8(policy).get()));
}
}
}
// 1) Apply speculate CSP for preloads
bool isPreload = nsContentUtils::IsPreloadType(aContentType);
if (isPreload) {
nsCOMPtr<nsIContentSecurityPolicy> preloadCsp;
rv = principal->GetPreloadCsp(getter_AddRefs(preloadCsp));
NS_ENSURE_SUCCESS(rv, rv);
if (preloadCsp) {
// obtain the enforcement decision
// (don't pass aExtra, we use that slot for redirects)
csp->ShouldLoad(aContentType,
aContentLocation,
aRequestOrigin,
aRequestContext,
aMimeTypeGuess,
nullptr,
aDecision);
rv = preloadCsp->ShouldLoad(aContentType,
aContentLocation,
aRequestOrigin,
aRequestContext,
aMimeTypeGuess,
nullptr, // aExtra
aDecision);
NS_ENSURE_SUCCESS(rv, rv);
// if the preload policy already denied the load, then there
// is no point in checking the real policy
if (NS_CP_REJECTED(*aDecision)) {
return NS_OK;
}
}
}
else if (MOZ_LOG_TEST(gCspPRLog, LogLevel::Debug)) {
nsAutoCString uriSpec;
aContentLocation->GetSpec(uriSpec);
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("COULD NOT get nsIPrincipal for location: %s", uriSpec.get()));
}
// 2) Apply actual CSP to all loads
nsCOMPtr<nsIContentSecurityPolicy> csp;
rv = principal->GetCsp(getter_AddRefs(csp));
NS_ENSURE_SUCCESS(rv, rv);
if (csp) {
// obtain the enforcement decision
// (don't pass aExtra, we use that slot for redirects)
rv = csp->ShouldLoad(aContentType,
aContentLocation,
aRequestOrigin,
aRequestContext,
aMimeTypeGuess,
nullptr,
aDecision);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}
@@ -283,16 +242,6 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
return NS_OK;
}
// Get the LoadingPrincipal and CSP from the loadInfo
nsCOMPtr<nsIContentSecurityPolicy> csp;
rv = loadInfo->LoadingPrincipal()->GetCsp(getter_AddRefs(csp));
NS_ENSURE_SUCCESS(rv, rv);
// if there is no CSP, nothing for us to do
if (!csp) {
return NS_OK;
}
/* Since redirecting channels don't call into nsIContentPolicy, we call our
* Content Policy implementation directly when redirects occur using the
* information set in the LoadInfo when channels are created.
@@ -315,28 +264,43 @@ CSPService::AsyncOnChannelRedirect(nsIChannel *oldChannel,
nsContentUtils::InternalContentPolicyTypeToExternalOrWorker(policyType);
int16_t aDecision = nsIContentPolicy::ACCEPT;
csp->ShouldLoad(policyType, // load type per nsIContentPolicy (uint32_t)
newUri, // nsIURI
nullptr, // nsIURI
nullptr, // nsISupports
EmptyCString(), // ACString - MIME guess
originalUri, // aMimeTypeGuess
&aDecision);
// 1) Apply speculative CSP for preloads
if (isPreload) {
nsCOMPtr<nsIContentSecurityPolicy> preloadCsp;
loadInfo->LoadingPrincipal()->GetPreloadCsp(getter_AddRefs(preloadCsp));
if (newUri && MOZ_LOG_TEST(gCspPRLog, LogLevel::Debug)) {
nsAutoCString newUriSpec("None");
newUri->GetSpec(newUriSpec);
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("CSPService::AsyncOnChannelRedirect called for %s",
newUriSpec.get()));
if (preloadCsp) {
// Pass originalURI as aExtra to indicate the redirect
preloadCsp->ShouldLoad(policyType, // load type per nsIContentPolicy (uint32_t)
newUri, // nsIURI
nullptr, // nsIURI
nullptr, // nsISupports
EmptyCString(), // ACString - MIME guess
originalUri, // aExtra
&aDecision);
// if the preload policy already denied the load, then there
// is no point in checking the real policy
if (NS_CP_REJECTED(aDecision)) {
autoCallback.DontCallback();
return NS_BINDING_FAILED;
}
}
}
if (aDecision == 1) {
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("CSPService::AsyncOnChannelRedirect ALLOWING request."));
}
else {
MOZ_LOG(gCspPRLog, LogLevel::Debug,
("CSPService::AsyncOnChannelRedirect CANCELLING request."));
// 2) Apply actual CSP to all loads
nsCOMPtr<nsIContentSecurityPolicy> csp;
loadInfo->LoadingPrincipal()->GetCsp(getter_AddRefs(csp));
if (csp) {
// Pass originalURI as aExtra to indicate the redirect
csp->ShouldLoad(policyType, // load type per nsIContentPolicy (uint32_t)
newUri, // nsIURI
nullptr, // nsIURI
nullptr, // nsISupports
EmptyCString(), // ACString - MIME guess
originalUri, // aExtra
&aDecision);
}
// if ShouldLoad doesn't accept the load, cancel the request
+28 -5
View File
@@ -42,6 +42,11 @@ static bool SchemeIs(nsIURI* aURI, const char* aScheme)
static nsresult
DoCheckLoadURIChecks(nsIURI* aURI, nsILoadInfo* aLoadInfo)
{
// Bug 1228117: determine the correct security policy for DTD loads
if (aLoadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_DTD) {
return NS_OK;
}
nsresult rv = NS_OK;
nsCOMPtr<nsIPrincipal> loadingPrincipal = aLoadInfo->LoadingPrincipal();
@@ -146,8 +151,17 @@ DoContentSecurityChecks(nsIURI* aURI, nsILoadInfo* aLoadInfo)
break;
}
case nsIContentPolicy::TYPE_IMAGE:
case nsIContentPolicy::TYPE_STYLESHEET:
case nsIContentPolicy::TYPE_IMAGE: {
MOZ_ASSERT(false, "contentPolicyType not supported yet");
break;
}
case nsIContentPolicy::TYPE_STYLESHEET: {
mimeTypeGuess = NS_LITERAL_CSTRING("text/css");
requestingContext = aLoadInfo->LoadingNode();
break;
}
case nsIContentPolicy::TYPE_OBJECT:
case nsIContentPolicy::TYPE_DOCUMENT: {
MOZ_ASSERT(false, "contentPolicyType not supported yet");
@@ -531,10 +545,18 @@ nsContentSecurityManager::IsURIPotentiallyTrustworthy(nsIURI* aURI, bool* aIsTru
*aIsTrustWorthy = false;
nsAutoCString scheme;
nsresult rv = aURI->GetScheme(scheme);
NS_ENSURE_SUCCESS(rv, NS_OK);
if (NS_FAILED(rv)) {
return NS_OK;
}
// According to the specification, the user agent may choose to extend the
// trust to other, vendor-specific URL schemes. We use this for "resource:",
// which is technically a substituting protocol handler that is not limited to
// local resource mapping, but in practice is never mapped remotely as this
// would violate assumptions a lot of code makes.
if (scheme.EqualsLiteral("https") ||
scheme.EqualsLiteral("file") ||
scheme.EqualsLiteral("resource") ||
scheme.EqualsLiteral("app") ||
scheme.EqualsLiteral("wss")) {
*aIsTrustWorthy = true;
@@ -543,7 +565,9 @@ nsContentSecurityManager::IsURIPotentiallyTrustworthy(nsIURI* aURI, bool* aIsTru
nsAutoCString host;
rv = aURI->GetHost(host);
NS_ENSURE_SUCCESS(rv, NS_OK);
if (NS_FAILED(rv)) {
return NS_OK;
}
if (host.Equals("127.0.0.1") ||
host.Equals("localhost") ||
@@ -551,6 +575,5 @@ nsContentSecurityManager::IsURIPotentiallyTrustworthy(nsIURI* aURI, bool* aIsTru
*aIsTrustWorthy = true;
return NS_OK;
}
return NS_OK;
}
@@ -27,6 +27,9 @@ function handleRequest(request, response)
if (secData.allowOrigin)
response.setHeader("Access-Control-Allow-Origin", secData.allowOrigin);
if (secData.withCred)
response.setHeader("Access-Control-Allow-Credentials", "true");
if (isPreflight) {
if (secData.allowHeaders)
response.setHeader("Access-Control-Allow-Headers", secData.allowHeaders);
@@ -417,6 +417,65 @@ function runTest() {
{ pass: 0,
method: "DELETE"
},
{ newTest: "*******" },
{ pass: 1,
method: "GET",
withCred: true,
headers: { "x-my-header": "myValue" },
allowHeaders: "x-my-header",
cacheTime: 3600
},
{ pass: 1,
method: "GET",
withCred: true,
headers: { "x-my-header": "myValue" },
},
{ pass: 0,
method: "GET",
headers: { "x-my-header": "myValue" },
},
{ newTest: "*******" },
{ pass: 1,
method: "GET",
withCred: true,
headers: { "x-my-header": "myValue" },
allowHeaders: "x-my-header",
cacheTime: 3600
},
{ pass: 1,
method: "GET",
headers: { "y-my-header": "myValue" },
allowHeaders: "y-my-header",
cacheTime: 2
},
{ pass: 1,
method: "GET",
headers: { "y-my-header": "myValue" },
},
{ pass: 1,
method: "GET",
withCred: true,
headers: { "x-my-header": "myValue" },
},
{ pause: 2.1 },
{ pass: 1,
method: "GET",
withCred: true,
headers: { "x-my-header": "myValue" },
},
{ pass: 0,
method: "GET",
headers: { "x-my-header": "myValue" },
},
{ pass: 0,
method: "GET",
headers: { "y-my-header": "myValue" },
},
{ pass: 0,
method: "GET",
withCred: true,
headers: { "y-my-header": "myValue" },
},
];
for (let i = 0; i < 110; i++) {
@@ -448,12 +507,14 @@ function runTest() {
url: baseURL + "c=" + unique,
method: test.method,
headers: test.headers,
withCred: test.withCred,
};
sec = { allowOrigin: test.noOrigin ? "" : origin,
allowHeaders: test.allowHeaders,
allowMethods: test.allowMethods,
cacheTime: test.cacheTime };
cacheTime: test.cacheTime,
withCred: test.withCred };
xhr = new XMLHttpRequest();
xhr.open("POST", setStateURL + escape(sec.toSource()), true);
xhr.onloadend = function() { gen.next(); }
@@ -0,0 +1,33 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/*
* Tests the "Is origin potentially trustworthy?" logic from
* <https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy>.
*/
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "gContentSecurityManager",
"@mozilla.org/contentsecuritymanager;1",
"nsIContentSecurityManager");
add_task(function* test_isURIPotentiallyTrustworthy() {
for (let [uriSpec, expectedResult] of [
["http://example.com/", false],
["https://example.com/", true],
["http://localhost/", true],
["http://127.0.0.1/", true],
["file:///", true],
["resource:///", true],
["about:config", false],
["urn:generic", false],
]) {
let uri = NetUtil.newURI(uriSpec);
Assert.equal(gContentSecurityManager.isURIPotentiallyTrustworthy(uri),
expectedResult);
}
});
+1
View File
@@ -5,3 +5,4 @@ skip-if = toolkit == 'gonk'
[test_csp_reports.js]
skip-if = buildapp == 'mulet'
[test_isURIPotentiallyTrustworthy.js]
+1 -1
View File
@@ -351,7 +351,7 @@ HMDPositionVRDevice::GetState()
already_AddRefed<VRPositionState>
HMDPositionVRDevice::GetImmediateState()
{
gfx::VRHMDSensorState state = mHMD->GetSensorState();
gfx::VRHMDSensorState state = mHMD->GetImmediateSensorState();
RefPtr<VRPositionState> obj = new VRPositionState(mParent, state);
return obj.forget();
+17 -1
View File
@@ -10,7 +10,23 @@
* liability, trademark and document use rules apply.
*/
[Func="mozilla::dom::Touch::PrefEnabled"]
dictionary TouchInit {
required long identifier;
required EventTarget target;
long clientX = 0;
long clientY = 0;
long screenX = 0;
long screenY = 0;
long pageX = 0;
long pageY = 0;
float radiusX = 0;
float radiusY = 0;
float rotationAngle = 0;
float force = 0;
};
[Constructor(TouchInit touchInitDict),
Func="mozilla::dom::Touch::PrefEnabled"]
interface Touch {
readonly attribute long identifier;
readonly attribute EventTarget? target;
+8 -1
View File
@@ -4,7 +4,14 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Func="mozilla::dom::TouchEvent::PrefEnabled"]
dictionary TouchEventInit : EventModifierInit {
sequence<Touch> touches = [];
sequence<Touch> targetTouches = [];
sequence<Touch> changedTouches = [];
};
[Constructor(DOMString type, optional TouchEventInit eventInitDict),
Func="mozilla::dom::TouchEvent::PrefEnabled"]
interface TouchEvent : UIEvent {
readonly attribute TouchList touches;
readonly attribute TouchList targetTouches;
+1 -3
View File
@@ -501,9 +501,7 @@ ServiceWorkerRegistrationInfo::GetWorkerByID(uint64_t aID, nsIServiceWorkerInfo
MOZ_ASSERT(aResult);
RefPtr<ServiceWorkerInfo> info = GetServiceWorkerInfoById(aID);
if (NS_WARN_IF(!info)) {
return NS_ERROR_FAILURE;
}
// It is ok to return null for a missing service worker info.
info.forget(aResult);
return NS_OK;
}
@@ -159,6 +159,15 @@ fetchXHR(corsServerURL + '?status=200&allowOrigin=*', function(xhr) {
finish();
});
// Verify origin header is sent properly even when we have a no-intercept SW.
var uriOrigin = encodeURIComponent(origin);
fetchXHR('http://example.org' + corsServerPath + '?ignore&status=200&origin=' + uriOrigin +
'&allowOrigin=' + uriOrigin, function(xhr) {
my_ok(xhr.status == 200, "cross origin load with correct headers should be successful");
my_ok(xhr.getResponseHeader("access-control-allow-origin") == null, "cors headers should be filtered out");
finish();
});
// Verify that XHR is considered CORS tainted even when original URL is same-origin
// redirected to cross-origin.
fetchXHR(redirectURL([{ server: origin },
@@ -1,6 +1,10 @@
var seenIndex = false;
onfetch = function(ev) {
if (ev.request.url.includes("ignore")) {
return;
}
if (ev.request.url.includes("bare-synthesized.txt")) {
ev.respondWith(Promise.resolve(
new Response("synthesized response body", {})
@@ -63,9 +67,6 @@ onfetch = function(ev) {
));
}
else if (ev.request.url.includes("ignored.txt")) {
}
else if (ev.request.url.includes("rejected.txt")) {
ev.respondWith(Promise.reject());
}
+1
View File
@@ -199,6 +199,7 @@ private:
DECL_GFX_PREF(Once, "dom.vr.oculus050.enabled", VROculus050Enabled, bool, true);
DECL_GFX_PREF(Once, "dom.vr.cardboard.enabled", VRCardboardEnabled, bool, false);
DECL_GFX_PREF(Once, "dom.vr.add-test-devices", VRAddTestDevices, int32_t, 1);
DECL_GFX_PREF(Live, "dom.vr.poseprediction.enabled", VRPosePredictionEnabled, bool, false);
DECL_GFX_PREF(Live, "dom.w3c_pointer_events.enabled", PointerEventsEnabled, bool, false);
DECL_GFX_PREF(Live, "dom.w3c_touch_events.enabled", TouchEventsEnabled, int32_t, 0);
+9 -1
View File
@@ -79,13 +79,21 @@ VRDeviceProxy::ZeroSensor()
}
VRHMDSensorState
VRDeviceProxy::GetSensorState(double timeOffset)
VRDeviceProxy::GetSensorState()
{
VRManagerChild *vm = VRManagerChild::Get();
Unused << vm->SendKeepSensorTracking(mDeviceInfo.mDeviceID);
return mSensorState;
}
VRHMDSensorState
VRDeviceProxy::GetImmediateSensorState()
{
// XXX TODO - Need to perform IPC call to get the current sensor
// state rather than the predictive state used for the frame rendering.
return GetSensorState();
}
void
VRDeviceProxy::UpdateSensorState(const VRHMDSensorState& aSensorState)
{
+2 -1
View File
@@ -28,7 +28,8 @@ public:
void UpdateSensorState(const VRHMDSensorState& aSensorState);
const VRDeviceInfo& GetDeviceInfo() const { return mDeviceInfo; }
virtual VRHMDSensorState GetSensorState(double timeOffset = 0.0);
virtual VRHMDSensorState GetSensorState();
virtual VRHMDSensorState GetImmediateSensorState();
bool SetFOV(const VRFieldOfView& aFOVLeft, const VRFieldOfView& aFOVRight,
double zNear, double zFar);
+8 -1
View File
@@ -187,13 +187,20 @@ VRDeviceProxyOrientationFallBack::ComputeStateFromLastSensor()
}
VRHMDSensorState
VRDeviceProxyOrientationFallBack::GetSensorState(double timeOffset)
VRDeviceProxyOrientationFallBack::GetSensorState()
{
StartSensorTracking();
ComputeStateFromLastSensor();
return mSensorState;
}
VRHMDSensorState
VRDeviceProxyOrientationFallBack::GetImmediateSensorState()
{
// XXX TODO - Should return actual immediate sensor state
return GetSensorState();
}
} // namespace gfx
} // namespace mozilla
+2 -1
View File
@@ -23,7 +23,8 @@ public:
explicit VRDeviceProxyOrientationFallBack(const VRDeviceUpdate& aDeviceUpdate);
virtual void ZeroSensor() override;
virtual VRHMDSensorState GetSensorState(double timeOffset = 0.0) override;
virtual VRHMDSensorState GetSensorState() override;
virtual VRHMDSensorState GetImmediateSensorState() override;
// ISensorObserver interface
void Notify(const hal::SensorData& SensorData) override;
+2 -1
View File
@@ -264,7 +264,8 @@ public:
virtual bool KeepSensorTracking() = 0;
virtual void NotifyVsync(const TimeStamp& aVsyncTimestamp) = 0;
virtual VRHMDSensorState GetSensorState(double timeOffset = 0.0) = 0;
virtual VRHMDSensorState GetSensorState() = 0;
virtual VRHMDSensorState GetImmediateSensorState() = 0;
virtual void ZeroSensor() = 0;
+8 -1
View File
@@ -51,7 +51,7 @@ HMDInfoCardboard::HMDInfoCardboard()
VRHMDSensorState
HMDInfoCardboard::GetSensorState(double timeOffset)
HMDInfoCardboard::GetSensorState()
{
// Actual sensor state is calculated on the main thread,
// within VRDeviceProxyOrientationFallBack
@@ -60,6 +60,13 @@ HMDInfoCardboard::GetSensorState(double timeOffset)
return result;
}
VRHMDSensorState
HMDInfoCardboard::GetImmediateSensorState()
{
return GetSensorState();
}
void
HMDInfoCardboard::ZeroSensor()
{
+2 -1
View File
@@ -25,7 +25,8 @@ public:
bool SetFOV(const VRFieldOfView& aFOVLeft, const VRFieldOfView& aFOVRight,
double zNear, double zFar) override;
VRHMDSensorState GetSensorState(double timeOffset) override;
virtual VRHMDSensorState GetSensorState() override;
virtual VRHMDSensorState GetImmediateSensorState() override;
void ZeroSensor() override;
bool KeepSensorTracking() override;
void NotifyVsync(const TimeStamp& aVsyncTimestamp) override;
+51 -26
View File
@@ -41,6 +41,7 @@ static pfn_ovr_Destroy ovr_Destroy = nullptr;
static pfn_ovr_RecenterPose ovr_RecenterPose = nullptr;
static pfn_ovr_GetTrackingState ovr_GetTrackingState = nullptr;
static pfn_ovr_GetPredictedDisplayTime ovr_GetPredictedDisplayTime = nullptr;
static pfn_ovr_GetFovTextureSize ovr_GetFovTextureSize = nullptr;
static pfn_ovr_GetRenderDesc ovr_GetRenderDesc = nullptr;
@@ -171,6 +172,7 @@ InitializeOculusCAPI()
REQUIRE_FUNCTION(ovr_RecenterPose);
REQUIRE_FUNCTION(ovr_GetTrackingState);
REQUIRE_FUNCTION(ovr_GetPredictedDisplayTime);
REQUIRE_FUNCTION(ovr_GetFovTextureSize);
REQUIRE_FUNCTION(ovr_GetRenderDesc);
@@ -200,26 +202,6 @@ static bool InitializeOculusCAPI()
#endif
static void
do_CalcEyePoses(ovrPosef headPose,
const ovrVector3f hmdToEyeViewOffset[2],
ovrPosef outEyePoses[2])
{
if (!hmdToEyeViewOffset || !outEyePoses)
return;
for (uint32_t i = 0; i < 2; ++i) {
gfx::Quaternion o(headPose.Orientation.x, headPose.Orientation.y, headPose.Orientation.z, headPose.Orientation.w);
Point3D vo(hmdToEyeViewOffset[i].x, hmdToEyeViewOffset[i].y, hmdToEyeViewOffset[i].z);
Point3D p = o.RotatePoint(vo);
outEyePoses[i].Orientation = headPose.Orientation;
outEyePoses[i].Position.x = p.x + headPose.Position.x;
outEyePoses[i].Position.y = p.y + headPose.Position.y;
outEyePoses[i].Position.z = p.z + headPose.Position.z;
}
}
ovrFovPort
ToFovPort(const gfx::VRFieldOfView& aFOV)
{
@@ -281,6 +263,10 @@ HMDInfoOculus::HMDInfoOculus(ovrSession aSession)
mDeviceInfo.mIsFakeScreen = true;
SetFOV(mDeviceInfo.mRecommendedEyeFOV[VRDeviceInfo::Eye_Left], mDeviceInfo.mRecommendedEyeFOV[VRDeviceInfo::Eye_Right], 0.01, 10000.0);
for (int i = 0; i < kMaxLatencyFrames; i++) {
mLastSensorState[i].Clear();
}
}
void
@@ -356,15 +342,33 @@ HMDInfoOculus::ZeroSensor()
ovr_RecenterPose(mSession);
}
VRHMDSensorState
HMDInfoOculus::GetSensorState()
{
VRHMDSensorState result;
double frameTiming = 0.0f;
if (gfxPrefs::VRPosePredictionEnabled()) {
frameTiming = ovr_GetPredictedDisplayTime(mSession, mInputFrameID);
}
result = GetSensorState(frameTiming);
result.inputFrameID = mInputFrameID;
mLastSensorState[mInputFrameID % kMaxLatencyFrames] = result;
return result;
}
VRHMDSensorState
HMDInfoOculus::GetImmediateSensorState()
{
return GetSensorState(0.0);
}
VRHMDSensorState
HMDInfoOculus::GetSensorState(double timeOffset)
{
VRHMDSensorState result;
result.Clear();
// XXX this is the wrong time base for timeOffset; we need to figure out how to synchronize
// the Oculus time base and the browser one.
ovrTrackingState state = ovr_GetTrackingState(mSession, ovr_GetTimeInSeconds() + timeOffset, true);
ovrTrackingState state = ovr_GetTrackingState(mSession, timeOffset, true);
ovrPoseStatef& pose(state.HeadPose);
result.timestamp = pose.TimeInSeconds;
@@ -401,8 +405,6 @@ HMDInfoOculus::GetSensorState(double timeOffset)
result.linearAcceleration[1] = pose.LinearAcceleration.y;
result.linearAcceleration[2] = pose.LinearAcceleration.z;
}
mLastTrackingState = state;
return result;
}
@@ -526,6 +528,13 @@ HMDInfoOculus::SubmitFrame(RenderTargetSet *aRTSet, int32_t aInputFrameID)
MOZ_ASSERT(rts->hmd != nullptr);
MOZ_ASSERT(rts->textureSet != nullptr);
VRHMDSensorState sensorState = mLastSensorState[aInputFrameID % kMaxLatencyFrames];
// It is possible to get a cache miss on mLastSensorState if latency is
// longer than kMaxLatencyFrames. An optimization would be to find a frame
// that is closer than the one selected with the modulus.
// If we hit this; however, latency is already so high that the site is
// un-viewable and a more accurate pose prediction is not likely to
// compensate.
ovrLayerEyeFov layer;
layer.Header.Type = ovrLayerType_EyeFov;
layer.Header.Flags = 0;
@@ -546,7 +555,23 @@ HMDInfoOculus::SubmitFrame(RenderTargetSet *aRTSet, int32_t aInputFrameID)
const Point3D& r = rts->hmd->mDeviceInfo.mEyeTranslation[1];
const ovrVector3f hmdToEyeViewOffset[2] = { { l.x, l.y, l.z },
{ r.x, r.y, r.z } };
do_CalcEyePoses(rts->hmd->mLastTrackingState.HeadPose.ThePose, hmdToEyeViewOffset, layer.RenderPose);
for (uint32_t i = 0; i < 2; ++i) {
gfx::Quaternion o(sensorState.orientation[0],
sensorState.orientation[1],
sensorState.orientation[2],
sensorState.orientation[3]);
Point3D vo(hmdToEyeViewOffset[i].x, hmdToEyeViewOffset[i].y, hmdToEyeViewOffset[i].z);
Point3D p = o.RotatePoint(vo);
layer.RenderPose[i].Orientation.x = o.x;
layer.RenderPose[i].Orientation.y = o.y;
layer.RenderPose[i].Orientation.z = o.z;
layer.RenderPose[i].Orientation.w = o.w;
layer.RenderPose[i].Position.x = p.x + sensorState.position[0];
layer.RenderPose[i].Position.y = p.y + sensorState.position[1];
layer.RenderPose[i].Position.z = p.z + sensorState.position[2];
}
ovrLayerHeader *layers = &layer.Header;
ovrResult orv = ovr_SubmitFrame(mSession, aInputFrameID, nullptr, &layers, 1);
+15 -3
View File
@@ -28,7 +28,8 @@ public:
bool SetFOV(const VRFieldOfView& aFOVLeft, const VRFieldOfView& aFOVRight,
double zNear, double zFar) override;
VRHMDSensorState GetSensorState(double timeOffset) override;
virtual VRHMDSensorState GetSensorState() override;
virtual VRHMDSensorState GetImmediateSensorState() override;
void ZeroSensor() override;
bool KeepSensorTracking() override;
void NotifyVsync(const TimeStamp& aVsyncTimestamp) override;
@@ -67,8 +68,19 @@ protected:
ovrSession mSession;
ovrHmdDesc mDesc;
ovrFovPort mFOVPort[2];
ovrTrackingState mLastTrackingState;
int mInputFrameID;
VRHMDSensorState GetSensorState(double timeOffset);
// The maximum number of frames of latency that we would expect before we
// should give up applying pose prediction.
// If latency is greater than one second, then the experience is not likely
// to be corrected by pose prediction. Setting this value too
// high may result in unnecessary memory allocation.
// As the current fastest refresh rate is 90hz, 100 is selected as a
// conservative value.
static const int kMaxLatencyFrames = 100;
VRHMDSensorState mLastSensorState[kMaxLatencyFrames];
int32_t mInputFrameID;
};
} // namespace impl
+8 -2
View File
@@ -463,14 +463,20 @@ HMDInfoOculus050::ZeroSensor()
}
VRHMDSensorState
HMDInfoOculus050::GetSensorState(double timeOffset)
HMDInfoOculus050::GetImmediateSensorState()
{
return GetSensorState();
}
VRHMDSensorState
HMDInfoOculus050::GetSensorState()
{
VRHMDSensorState result;
result.Clear();
// XXX this is the wrong time base for timeOffset; we need to figure out how to synchronize
// the Oculus time base and the browser one.
ovrTrackingState state = ovrHmd_GetTrackingState(mHMD, ovr_GetTimeInSeconds() + timeOffset);
ovrTrackingState state = ovrHmd_GetTrackingState(mHMD, ovr_GetTimeInSeconds());
ovrPoseStatef& pose(state.HeadPose);
result.timestamp = pose.TimeInSeconds;
+2 -1
View File
@@ -26,7 +26,8 @@ public:
bool SetFOV(const VRFieldOfView& aFOVLeft, const VRFieldOfView& aFOVRight,
double zNear, double zFar) override;
VRHMDSensorState GetSensorState(double timeOffset) override;
virtual VRHMDSensorState GetSensorState() override;
virtual VRHMDSensorState GetImmediateSensorState() override;
void ZeroSensor() override;
bool KeepSensorTracking() override;
void NotifyVsync(const TimeStamp& aVsyncTimestamp) override;
+1 -1
View File
@@ -427,7 +427,7 @@ load 812665.html
load 813372-1.html
load 817219.html
load 818454.html
asserts-if(gtkWidget,0-1) load 822865.html # bug 540078
load 822865.html
load 824862.html
load 826163.html
load 833604-1.html
+2 -2
View File
@@ -110,8 +110,8 @@ load 379917-1.xhtml
load 380012-1.html
load 381152-1.html
load 381786-1.html
asserts-if(gtkWidget,0-2) load 382129-1.xhtml # Bug 540078
asserts-if(gtkWidget,0-1) load 382131-1.html # Bug 540078
load 382129-1.xhtml
load 382131-1.html
load 382199-1.html
load 382208-1.xhtml
load 382262-1.html
+9
View File
@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg">
<style>
text { fill: url(#green); }
</style>
<linearGradient id="green">
<stop stop-color="green"/>
</linearGradient>
<text x="10" y="20">This text must be green.</text>
</svg>

After

Width:  |  Height:  |  Size: 236 B

+23
View File
@@ -0,0 +1,23 @@
<svg xmlns="http://www.w3.org/2000/svg" class="reftest-wait">
<style>
g { fill: url(#red); }
g.x { fill: url(#green); }
</style>
<linearGradient id="red">
<stop stop-color="red"/>
</linearGradient>
<linearGradient id="green">
<stop stop-color="green"/>
</linearGradient>
<g>
<text x="10" y="20">This text must be green.</text>
</g>
<script>
function run() {
var g = document.querySelector("g");
g.setAttribute("class", "x");
document.documentElement.removeAttribute("class");
}
document.addEventListener("MozReftestInvalidate", run, false);
</script>
</svg>

After

Width:  |  Height:  |  Size: 628 B

+3
View File
@@ -183,6 +183,9 @@ fuzzy-if(cocoaWidget,1,6) == pattern-content.svg pattern-content-ref.svg
# text and filters
HTTP(../..) == filter-applied.svg filter-applied-ref.svg
# vertical text
== textpath-vertical-dx.svg textpath-vertical-dx-ref.svg
# selection
needs-focus == deselectAll.svg deselectAll-ref.svg
needs-focus == selectSubString.svg selectSubString-ref.svg
@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<style>
path { stroke: red; }
text { writing-mode: vertical-rl; font: 24px sans-serif; }
</style>
<path id="p" d="M 40,40 v 150"/>
<text transform="translate(16, 0)"><textPath xlink:href="#p">中国 China</textPath></text>
</svg>

After

Width:  |  Height:  |  Size: 330 B

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<style>
path { stroke: red; }
text { writing-mode: vertical-rl; font: 24px sans-serif; }
</style>
<path id="p" d="M 40,40 v 150"/>
<text dx="16"><textPath xlink:href="#p">中国 China</textPath></text>
</svg>

After

Width:  |  Height:  |  Size: 309 B

+53 -134
View File
@@ -48,7 +48,6 @@
#include "nsThreadUtils.h"
#include "nsGkAtoms.h"
#include "nsIThreadInternal.h"
#include "nsCORSListenerProxy.h"
#include "nsINetworkPredictor.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/URL.h"
@@ -75,16 +74,14 @@ using namespace mozilla::dom;
* The CSS Loader gets requests to load various sorts of style sheets:
* inline style from <style> elements, linked style, @import-ed child
* sheets, non-document sheets. The loader handles the following tasks:
*
* 1) Checking whether the load is allowed: CheckLoadAllowed()
* 2) Creation of the actual style sheet objects: CreateSheet()
* 3) setting of the right media, title, enabled state, etc on the
* 1) Creation of the actual style sheet objects: CreateSheet()
* 2) setting of the right media, title, enabled state, etc on the
* sheet: PrepareSheet()
* 4) Insertion of the sheet in the proper cascade order:
* 3) Insertion of the sheet in the proper cascade order:
* InsertSheetInDoc() and InsertChildSheet()
* 5) Load of the sheet: LoadSheet()
* 6) Parsing of the sheet: ParseSheet()
* 7) Cleanup: SheetComplete()
* 4) Load of the sheet: LoadSheet() including security checks
* 5) Parsing of the sheet: ParseSheet()
* 6) Cleanup: SheetComplete()
*
* The detailed documentation for these functions is found with the
* function implementations.
@@ -1018,63 +1015,6 @@ Loader::ObsoleteSheet(nsIURI* aURI)
return NS_OK;
}
/**
* CheckLoadAllowed will return success if the load is allowed,
* failure otherwise.
*
* @param aSourcePrincipal the principal of the node or document or parent
* sheet loading the sheet
* @param aTargetURI the uri of the sheet to be loaded
* @param aContext the node owning the sheet. This is the element or document
* owning the stylesheet (possibly indirectly, for child sheets)
*/
nsresult
Loader::CheckLoadAllowed(nsIPrincipal* aSourcePrincipal,
nsIURI* aTargetURI,
nsISupports* aContext,
bool aIsPreload)
{
LOG(("css::Loader::CheckLoadAllowed"));
nsresult rv;
if (aSourcePrincipal) {
// Check with the security manager
nsIScriptSecurityManager *secMan = nsContentUtils::GetSecurityManager();
rv =
secMan->CheckLoadURIWithPrincipal(aSourcePrincipal, aTargetURI,
nsIScriptSecurityManager::ALLOW_CHROME);
if (NS_FAILED(rv)) { // failure is normal here; don't warn
return rv;
}
LOG((" Passed security check"));
// Check with content policy
nsContentPolicyType contentPolicyType =
aIsPreload ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
: nsIContentPolicy::TYPE_INTERNAL_STYLESHEET;
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(contentPolicyType,
aTargetURI,
aSourcePrincipal,
aContext,
NS_LITERAL_CSTRING("text/css"),
nullptr, //extra param
&shouldLoad,
nsContentUtils::GetContentPolicy(),
nsContentUtils::GetSecurityManager());
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
LOG((" Load blocked by content policy"));
return NS_ERROR_CONTENT_BLOCKED;
}
}
return NS_OK;
}
/**
* CreateSheet() creates a CSSStyleSheet object for the given URI,
* if any. If there is no URI given, we just create a new style sheet
@@ -1445,19 +1385,8 @@ Loader::LoadSheet(SheetLoadData* aLoadData,
return NS_BINDING_ABORTED;
}
bool inherit = false;
nsIPrincipal* triggeringPrincipal = aLoadData->mLoaderPrincipal;
if (triggeringPrincipal) {
rv = NS_URIChainHasFlags(aLoadData->mURI,
nsIProtocolHandler::URI_INHERITS_SECURITY_CONTEXT,
&inherit);
inherit =
((NS_SUCCEEDED(rv) && inherit) ||
(nsContentUtils::URIIsLocalFile(aLoadData->mURI) &&
NS_SUCCEEDED(aLoadData->mLoaderPrincipal->
CheckMayLoad(aLoadData->mURI, false, false))));
}
else {
if (!triggeringPrincipal) {
triggeringPrincipal = nsContentUtils::GetSystemPrincipal();
}
@@ -1486,6 +1415,14 @@ Loader::LoadSheet(SheetLoadData* aLoadData,
mDocument);
}
nsSecurityFlags securityFlags =
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
nsILoadInfo::SEC_ALLOW_CHROME;
nsContentPolicyType contentPolicyType =
aIsPreload ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
: nsIContentPolicy::TYPE_INTERNAL_STYLESHEET;
// Just load it
nsCOMPtr<nsIChannel> channel;
// Note that we are calling NS_NewChannelWithTriggeringPrincipal() with both
@@ -1498,8 +1435,8 @@ Loader::LoadSheet(SheetLoadData* aLoadData,
aLoadData->mURI,
aLoadData->mRequestingNode,
triggeringPrincipal,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
securityFlags,
contentPolicyType);
}
else {
// either we are loading something inside a document, in which case
@@ -1510,13 +1447,17 @@ Loader::LoadSheet(SheetLoadData* aLoadData,
rv = NS_NewChannel(getter_AddRefs(channel),
aLoadData->mURI,
triggeringPrincipal,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
securityFlags,
contentPolicyType);
}
if (NS_FAILED(rv)) {
LOG_ERROR((" Failed to create channel"));
SheetComplete(aLoadData, rv);
return rv;
}
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStream> stream;
rv = channel->Open(getter_AddRefs(stream));
rv = channel->Open2(getter_AddRefs(stream));
if (NS_FAILED(rv)) {
LOG_ERROR((" Failed to open URI synchronously"));
@@ -1580,20 +1521,32 @@ Loader::LoadSheet(SheetLoadData* aLoadData,
return NS_OK;
}
#ifdef DEBUG
mSyncCallback = true;
#endif
nsCOMPtr<nsILoadGroup> loadGroup;
if (mDocument) {
loadGroup = mDocument->GetDocumentLoadGroup();
NS_ASSERTION(loadGroup,
"No loadgroup for stylesheet; onload will fire early");
// load for a document with no loadgrup indicates that something is
// completely bogus, let's bail out early.
if (!loadGroup) {
LOG_ERROR((" Failed to query loadGroup from document"));
SheetComplete(aLoadData, NS_ERROR_UNEXPECTED);
return NS_ERROR_UNEXPECTED;
}
}
#ifdef DEBUG
mSyncCallback = true;
#endif
nsLoadFlags securityFlags = nsILoadInfo::SEC_NORMAL;
if (inherit) {
securityFlags |= nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
CORSMode ourCORSMode = aLoadData->mSheet->GetCORSMode();
nsSecurityFlags securityFlags =
ourCORSMode == CORS_NONE
? nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS
: nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS;
if (ourCORSMode == CORS_ANONYMOUS) {
securityFlags |= nsILoadInfo::SEC_COOKIES_SAME_ORIGIN;
} else if (ourCORSMode == CORS_USE_CREDENTIALS) {
securityFlags |= nsILoadInfo::SEC_COOKIES_INCLUDE;
}
securityFlags |= nsILoadInfo::SEC_ALLOW_CHROME;
nsContentPolicyType contentPolicyType =
aIsPreload ? nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD
@@ -1689,35 +1642,13 @@ Loader::LoadSheet(SheetLoadData* aLoadData,
return rv;
}
nsCOMPtr<nsIStreamListener> channelListener;
CORSMode ourCORSMode = aLoadData->mSheet->GetCORSMode();
if (ourCORSMode != CORS_NONE) {
bool withCredentials = (ourCORSMode == CORS_USE_CREDENTIALS);
LOG((" Doing CORS-enabled load; credentials %d", withCredentials));
RefPtr<nsCORSListenerProxy> corsListener =
new nsCORSListenerProxy(streamLoader, aLoadData->mLoaderPrincipal,
withCredentials);
rv = corsListener->Init(channel, DataURIHandling::Allow);
if (NS_FAILED(rv)) {
#ifdef DEBUG
mSyncCallback = false;
#endif
LOG_ERROR((" Initial CORS check failed"));
SheetComplete(aLoadData, rv);
return rv;
}
channelListener = corsListener;
} else {
channelListener = streamLoader;
}
if (mDocument) {
mozilla::net::PredictorLearn(aLoadData->mURI, mDocument->GetDocumentURI(),
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE,
mDocument);
}
rv = channel->AsyncOpen(channelListener, nullptr);
rv = channel->AsyncOpen2(streamLoader);
#ifdef DEBUG
mSyncCallback = false;
@@ -2060,17 +1991,13 @@ Loader::LoadStyleLink(nsIContent* aElement,
if (!context) {
context = mDocument;
}
nsresult rv = CheckLoadAllowed(principal, aURL, context, false);
if (NS_FAILED(rv)) return rv;
LOG((" Passed load check"));
StyleSheetState state;
RefPtr<CSSStyleSheet> sheet;
rv = CreateSheet(aURL, aElement, principal, aCORSMode,
aReferrerPolicy, aIntegrity, false,
aHasAlternateRel, aTitle, state, aIsAlternate,
getter_AddRefs(sheet));
nsresult rv = CreateSheet(aURL, aElement, principal, aCORSMode,
aReferrerPolicy, aIntegrity, false,
aHasAlternateRel, aTitle, state, aIsAlternate,
getter_AddRefs(sheet));
NS_ENSURE_SUCCESS(rv, rv);
LOG((" Sheet is alternate: %d", *aIsAlternate));
@@ -2194,12 +2121,6 @@ Loader::LoadChildSheet(CSSStyleSheet* aParentSheet,
context = mDocument;
}
nsIPrincipal* principal = aParentSheet->Principal();
nsresult rv = CheckLoadAllowed(principal, aURL, context, false);
if (NS_FAILED(rv)) return rv;
LOG((" Passed load check"));
SheetLoadData* parentData = nullptr;
nsCOMPtr<nsICSSLoaderObserver> observer;
@@ -2226,7 +2147,9 @@ Loader::LoadChildSheet(CSSStyleSheet* aParentSheet,
// Now that we know it's safe to load this (passes security check and not a
// loop) do so.
nsIPrincipal* principal = aParentSheet->Principal();
RefPtr<CSSStyleSheet> sheet;
nsresult rv;
StyleSheetState state;
if (aReusableSheets && aReusableSheets->FindReusableStyleSheet(aURL, sheet)) {
aParentRule->SetSheet(sheet);
@@ -2350,16 +2273,12 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL,
return NS_ERROR_NOT_AVAILABLE;
}
nsresult rv = CheckLoadAllowed(aOriginPrincipal, aURL, mDocument, aIsPreload);
if (NS_FAILED(rv)) {
return rv;
}
StyleSheetState state;
bool isAlternate;
RefPtr<CSSStyleSheet> sheet;
bool syncLoad = (aObserver == nullptr);
const nsSubstring& empty = EmptyString();
nsresult rv;
rv = CreateSheet(aURL, nullptr, aOriginPrincipal, aCORSMode,
aReferrerPolicy, aIntegrity, syncLoad, false,
-10
View File
@@ -441,16 +441,6 @@ public:
private:
friend class SheetLoadData;
// Note: null aSourcePrincipal indicates that the content policy and
// CheckLoadURI checks should be skipped.
// aIsPreload indicates whether the html parser preloads that
// stylesheet or if it is a regular load.
nsresult CheckLoadAllowed(nsIPrincipal* aSourcePrincipal,
nsIURI* aTargetURI,
nsISupports* aContext,
bool aIsPreload);
// For inline style, the aURI param is null, but the aLinkingContent
// must be non-null then. The loader principal must never be null
// if aURI is not null.
+1 -1
View File
@@ -5045,7 +5045,7 @@ SVGTextFrame::DoTextPathLayout()
Float rotation = vertical ? atan2f(-tangent.x, tangent.y)
: atan2f(tangent.y, tangent.x);
Point normal(-tangent.y, tangent.x); // Unit vector normal to the point.
Point offsetFromPath = normal * (vertical ? mPositions[i].mPosition.x
Point offsetFromPath = normal * (vertical ? -mPositions[i].mPosition.x
: mPositions[i].mPosition.y);
pt += offsetFromPath;
Point direction = tangent * sign;
+12 -2
View File
@@ -593,8 +593,18 @@ nsSVGEffects::GetPaintServer(nsIFrame *aTargetFrame, const nsStyleSVGPaint *aPai
if (aPaint->mType != eStyleSVGPaintType_Server)
return nullptr;
nsIFrame *frame = aTargetFrame->GetContent()->IsNodeOfType(nsINode::eTEXT) ?
aTargetFrame->GetParent() : aTargetFrame;
// If we're looking at a frame within SVG text, then we need to look up
// to find the right frame to get the painting property off. We should at
// least look up past a text frame, and if the text frame's parent is the
// anonymous block frame, then we look up to its parent (the SVGTextFrame).
nsIFrame* frame = aTargetFrame;
if (frame->GetContent()->IsNodeOfType(nsINode::eTEXT)) {
frame = frame->GetParent();
nsIFrame* grandparent = frame->GetParent();
if (grandparent && grandparent->GetType() == nsGkAtoms::svgTextFrame) {
frame = grandparent;
}
}
nsSVGPaintingProperty *property =
nsSVGEffects::GetPaintingProperty(aPaint->mPaint.mPaintServer, frame, aType);
if (!property)
+3
View File
@@ -85,6 +85,9 @@
'defines': [
'HAVE_JPEG'
],
'cflags_mozilla': [
'$(MOZ_JPEG_CFLAGS)',
],
}],
[ 'OS != "ios" and build_with_mozilla!=1', {
'defines': [
+7 -33
View File
@@ -26,21 +26,12 @@
#define MAX_DECODER_NAME_LEN 256
#define AVC_MIME_TYPE "video/avc"
#if !defined(MOZ_ANDROID_FROYO)
#define DEFAULT_STAGEFRIGHT_FLAGS OMXCodec::kClientNeedsFramebuffer
#else
#define DEFAULT_STAGEFRIGHT_FLAGS 0
#endif
#undef LOG
#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "OmxPlugin" , ## args)
#if defined(MOZ_ANDROID_FROYO) || defined(MOZ_ANDROID_GB)
// Android versions 2.x.x have common API differences
#define MOZ_ANDROID_V2_X_X
#endif
#if !defined(MOZ_ANDROID_V2_X_X) && !defined(MOZ_ANDROID_HC)
#if !defined(MOZ_ANDROID_GB) && !defined(MOZ_ANDROID_HC)
#define MOZ_ANDROID_V4_OR_ABOVE
#endif
@@ -242,8 +233,6 @@ GetDefaultStagefrightFlags(PluginHost *aPluginHost)
{
uint32_t flags = DEFAULT_STAGEFRIGHT_FLAGS;
#if !defined(MOZ_ANDROID_FROYO)
char hardware[256] = "";
aPluginHost->GetSystemInfoString("hardware", hardware, sizeof(hardware));
@@ -260,8 +249,6 @@ GetDefaultStagefrightFlags(PluginHost *aPluginHost)
LOG("Hardware %s; using default flags %#x\n", hardware, flags);
#endif
return flags;
}
@@ -281,7 +268,7 @@ static uint32_t GetVideoCreationFlags(PluginHost* aPluginHost)
int32_t flags = 0;
aPluginHost->GetIntPref("media.stagefright.omxcodec.flags", &flags);
if (flags != 0) {
#if !defined(MOZ_ANDROID_V2_X_X)
#if !defined(MOZ_ANDROID_GB)
LOG("media.stagefright.omxcodec.flags=%d", flags);
if ((flags & OMXCodec::kHardwareCodecsOnly) != 0) {
LOG("FORCE HARDWARE DECODING");
@@ -446,7 +433,7 @@ static sp<MediaSource> CreateVideoSource(PluginHost* aPluginHost,
// Throw away the videoSource and try again with new flags.
LOG("Falling back to software decoder");
videoSource.clear();
#if defined(MOZ_ANDROID_V2_X_X)
#if defined(MOZ_ANDROID_GB)
flags = DEFAULT_STAGEFRIGHT_FLAGS | OMXCodec::kPreferSoftwareCodecs;
#else
flags = DEFAULT_STAGEFRIGHT_FLAGS | OMXCodec::kSoftwareCodecsOnly;
@@ -521,11 +508,6 @@ bool OmxDecoder::Init()
sp<MediaSource> videoTrack;
sp<MediaSource> videoSource;
if (videoTrackIndex != -1 && (videoTrack = extractor->getTrack(videoTrackIndex)) != nullptr) {
#if defined(MOZ_ANDROID_FROYO)
// Allow up to 720P video.
sp<MetaData> meta = extractor->getTrackMetaData(videoTrackIndex);
meta->setInt32(kKeyMaxInputSize, (1280 * 720 * 3) / 2);
#endif
videoSource = CreateVideoSource(mPluginHost, omx, videoTrack);
if (videoSource == nullptr) {
LOG("OMXCodec failed to initialize video decoder for \"%s\"", videoMime);
@@ -623,7 +605,7 @@ bool OmxDecoder::SetVideoFormat() {
// slice height. Stagefright only seems to use its kKeyStride and
// kKeySliceHeight to initialize camera video formats.
#if defined(DEBUG) && !defined(MOZ_ANDROID_FROYO)
#if defined(DEBUG)
int32_t unexpected;
if (format->findInt32(kKeyStride, &unexpected))
LOG("Expected kKeyWidth, but found kKeyStride %d", unexpected);
@@ -651,7 +633,7 @@ bool OmxDecoder::SetVideoFormat() {
}
// Gingerbread does not support the kKeyCropRect key
#if !defined(MOZ_ANDROID_V2_X_X)
#if !defined(MOZ_ANDROID_GB)
if (!format->findRect(kKeyCropRect, &mVideoCropLeft, &mVideoCropTop,
&mVideoCropRight, &mVideoCropBottom)) {
#endif
@@ -660,7 +642,7 @@ bool OmxDecoder::SetVideoFormat() {
mVideoCropRight = mVideoStride - 1;
mVideoCropBottom = mVideoSliceHeight - 1;
LOG("crop rect not available, assuming no cropping");
#if !defined(MOZ_ANDROID_V2_X_X)
#if !defined(MOZ_ANDROID_GB)
}
#endif
@@ -675,14 +657,10 @@ bool OmxDecoder::SetVideoFormat() {
MOZ_ASSERT(mVideoWidth > 0 && mVideoWidth <= mVideoStride);
MOZ_ASSERT(mVideoHeight > 0 && mVideoHeight <= mVideoSliceHeight);
#if !defined(MOZ_ANDROID_FROYO)
if (!format->findInt32(kKeyRotation, &mVideoRotation)) {
#endif
mVideoRotation = 0;
#if !defined(MOZ_ANDROID_FROYO)
LOG("rotation not available, assuming 0");
}
#endif
if (mVideoRotation != 0 && mVideoRotation != 90 &&
mVideoRotation != 180 && mVideoRotation != 270) {
@@ -842,7 +820,7 @@ bool OmxDecoder::ToVideoFrame_ColorConverter(VideoFrame *aFrame, int64_t aTimeUs
aFrame->mSize = mVideoWidth * mVideoHeight * 2;
#if defined(MOZ_ANDROID_V2_X_X)
#if defined(MOZ_ANDROID_GB)
mColorConverter->convert(mVideoWidth, mVideoHeight,
aData, 0 /* srcSkip */,
buffer, mVideoWidth * 2);
@@ -895,9 +873,6 @@ bool OmxDecoder::ToVideoFrame_I420ColorConverter(VideoFrame *aFrame, int64_t aTi
bool OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame, BufferCallback *aBufferCallback) {
switch (mVideoColorFormat) {
// Froyo support is best handled with the android color conversion code. I
// get corrupted videos when using our own routines below.
#if !defined(MOZ_ANDROID_FROYO)
case OMX_COLOR_FormatYUV420Planar: // e.g. Asus Transformer, Stagefright's software decoder
ToVideoFrame_YUV420Planar(aFrame, aTimeUs, aData, aSize, aKeyFrame);
break;
@@ -919,7 +894,6 @@ bool OmxDecoder::ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData,
case OMX_COLOR_Format16bitRGB565:
return ToVideoFrame_RGB565(aFrame, aTimeUs, aData, aSize, aKeyFrame, aBufferCallback);
break;
#endif
default:
if (!ToVideoFrame_ColorConverter(aFrame, aTimeUs, aData, aSize, aKeyFrame, aBufferCallback) &&
!ToVideoFrame_I420ColorConverter(aFrame, aTimeUs, aData, aSize, aKeyFrame, aBufferCallback)) {
@@ -81,11 +81,7 @@ MOZ_EXPORT MediaSource::ReadOptions::ReadOptions()
{
}
MOZ_EXPORT void MediaSource::ReadOptions::setSeekTo(int64_t time_us
#if !defined(MOZ_ANDROID_FROYO)
, SeekMode mode
#endif
)
MOZ_EXPORT void MediaSource::ReadOptions::setSeekTo(int64_t time_us, SeekMode mode)
{
}
@@ -9,6 +9,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
SOURCES += [
'libstagefright.cpp',
]
# Some codec-related code uses multi-character constants; allow this.
# XXX: could instead use the FOURCC macro to define these constants.
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
SOURCES['libstagefright.cpp'].flags += ['-Wno-error=multichar']
SharedLibrary('stagefright')
@@ -24,6 +28,3 @@ USE_LIBS += [
# Don't use STL wrappers; this isn't Gecko code
DISABLE_STL_WRAPPING = True
NO_VISIBILITY_FLAGS = True
# XXX: We should fix these warnings.
ALLOW_COMPILER_WARNINGS = True
@@ -9,6 +9,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
SOURCES += [
'libstagefright.cpp',
]
# Some codec-related code uses multi-character constants; allow this.
# XXX: could instead use the FOURCC macro to define these constants.
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
SOURCES['libstagefright.cpp'].flags += ['-Wno-error=multichar']
SharedLibrary('stagefright')
@@ -24,6 +28,3 @@ USE_LIBS += [
# Don't use STL wrappers; this isn't Gecko code
DISABLE_STL_WRAPPING = True
NO_VISIBILITY_FLAGS = True
# XXX: We should fix these warnings.
ALLOW_COMPILER_WARNINGS = True
@@ -9,6 +9,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
SOURCES += [
'libstagefright.cpp',
]
# Some codec-related code uses multi-character constants; allow this.
# XXX: could instead use the FOURCC macro to define these constants.
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
SOURCES['libstagefright.cpp'].flags += ['-Wno-error=multichar']
SharedLibrary('stagefright')
@@ -24,6 +28,3 @@ USE_LIBS += [
# Don't use STL wrappers; this isn't Gecko code
DISABLE_STL_WRAPPING = True
NO_VISIBILITY_FLAGS = True
# XXX: We should fix these warnings.
ALLOW_COMPILER_WARNINGS = True
@@ -9,6 +9,10 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gonk':
SOURCES += [
'libstagefright.cpp',
]
# Some codec-related code uses multi-character constants; allow this.
# XXX: could instead use the FOURCC macro to define these constants.
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
SOURCES['libstagefright.cpp'].flags += ['-Wno-error=multichar']
SharedLibrary('stagefright')
@@ -24,6 +28,3 @@ USE_LIBS += [
# Don't use STL wrappers; this isn't Gecko code
DISABLE_STL_WRAPPING = True
NO_VISIBILITY_FLAGS = True
# XXX: We should fix these warnings.
ALLOW_COMPILER_WARNINGS = True
+6 -2
View File
@@ -245,8 +245,12 @@ Preferences::SizeOfIncludingThisAndOtherStuff(mozilla::MallocSizeOf aMallocSizeO
n += iter.Data()->mClosures.ShallowSizeOfExcludingThis(aMallocSizeOf);
}
}
// We don't measure sRootBranch and sDefaultRootBranch here because
// DMD indicates they are not significant.
if (sRootBranch) {
n += reinterpret_cast<nsPrefBranch*>(sRootBranch)->SizeOfIncludingThis(aMallocSizeOf);
}
if (sDefaultRootBranch) {
n += reinterpret_cast<nsPrefBranch*>(sDefaultRootBranch)->SizeOfIncludingThis(aMallocSizeOf);
}
n += pref_SizeOfPrivateData(aMallocSizeOf);
return n;
}
+9 -2
View File
@@ -4907,8 +4907,10 @@ pref("dom.mozPermissionSettings.enabled", false);
// W3C touch events
// 0 - disabled, 1 - enabled, 2 - autodetect
// Enabling it for Windows is tracked by bug 736048.
#if defined(XP_WIN) || defined(XP_MACOSX)
// Autodetection is currently only supported on Windows and GTK3
#if defined(XP_MACOSX)
pref("dom.w3c_touch_events.enabled", 0);
#elif defined(XP_WIN) && !defined(NIGHTLY_BUILD)
pref("dom.w3c_touch_events.enabled", 0);
#else
pref("dom.w3c_touch_events.enabled", 2);
@@ -5045,6 +5047,11 @@ pref("dom.vr.oculus050.enabled", true);
pref("dom.vr.cardboard.enabled", false);
// 0 = never; 1 = only if real devices aren't there; 2 = always
pref("dom.vr.add-test-devices", 1);
// Pose prediction reduces latency effects by returning future predicted HMD
// poses to callers of the WebVR API. This currently only has an effect for
// Oculus Rift on SDK 0.8 or greater. It is disabled by default for now due to
// frame uniformity issues with e10s.
pref("dom.vr.poseprediction.enabled", false);
// true = show the VR textures in our compositing output; false = don't.
// true might have performance impact
pref("gfx.vr.mirror-textures", false);
+9
View File
@@ -687,6 +687,15 @@ void nsPrefBranch::NotifyObserver(const char *newpref, void *data)
NS_ConvertASCIItoUTF16(suffix).get());
}
size_t
nsPrefBranch::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
{
size_t n = aMallocSizeOf(this);
n += mPrefRoot.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
n += mObservers.ShallowSizeOfExcludingThis(aMallocSizeOf);
return n;
}
void nsPrefBranch::freeObserverList(void)
{
// We need to prevent anyone from modifying mObservers while we're iterating
+9 -2
View File
@@ -145,12 +145,19 @@ NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized,
continue;
}
}
if (!aSerialized.mOriginAttributes.mSignedPkg.IsEmpty() &&
aSerialized.mOriginAttributes.mSignedPkg != tabContext.OriginAttributesRef().mSignedPkg) {
continue;
}
aAttrs = OriginAttributes(appId, inBrowserElement);
aAttrs.mSignedPkg = tabContext.OriginAttributesRef().mSignedPkg;
if (aSerialized.mOriginAttributes.mUserContextId != tabContext.OriginAttributesRef().mUserContextId) {
continue;
}
aAttrs = OriginAttributes();
aAttrs.mAppId = appId;
aAttrs.mInBrowser = inBrowserElement;
aAttrs.mSignedPkg = aSerialized.mOriginAttributes.mSignedPkg;
aAttrs.mUserContextId = aSerialized.mOriginAttributes.mUserContextId;
return nullptr;
}
+26 -8
View File
@@ -443,7 +443,7 @@ nsCORSListenerProxy::Init(nsIChannel* aChannel, DataURIHandling aAllowDataURI)
aChannel->GetNotificationCallbacks(getter_AddRefs(mOuterNotificationCallbacks));
aChannel->SetNotificationCallbacks(this);
nsresult rv = UpdateChannel(aChannel, aAllowDataURI);
nsresult rv = UpdateChannel(aChannel, aAllowDataURI, UpdateType::Default);
if (NS_FAILED(rv)) {
mOuterListener = nullptr;
mRequestingPrincipal = nullptr;
@@ -636,8 +636,22 @@ nsCORSListenerProxy::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
nsIAsyncVerifyRedirectCallback *aCb)
{
nsresult rv;
if (!NS_IsInternalSameURIRedirect(aOldChannel, aNewChannel, aFlags) &&
!NS_IsHSTSUpgradeRedirect(aOldChannel, aNewChannel, aFlags)) {
if (NS_IsInternalSameURIRedirect(aOldChannel, aNewChannel, aFlags) ||
NS_IsHSTSUpgradeRedirect(aOldChannel, aNewChannel, aFlags)) {
// Internal redirects still need to be updated in order to maintain
// the correct headers. We use DataURIHandling::Allow, since unallowed
// data URIs should have been blocked before we got to the internal
// redirect.
rv = UpdateChannel(aNewChannel, DataURIHandling::Allow,
UpdateType::InternalOrHSTSRedirect);
if (NS_FAILED(rv)) {
NS_WARNING("nsCORSListenerProxy::AsyncOnChannelRedirect: "
"internal redirect UpdateChannel() returned failure");
aOldChannel->Cancel(rv);
return rv;
}
} else {
// A real, external redirect. Perform CORS checking on new URL.
rv = CheckRequestApproved(aOldChannel);
if (NS_FAILED(rv)) {
nsCOMPtr<nsIURI> oldURI;
@@ -698,7 +712,8 @@ nsCORSListenerProxy::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
}
}
rv = UpdateChannel(aNewChannel, DataURIHandling::Disallow);
rv = UpdateChannel(aNewChannel, DataURIHandling::Disallow,
UpdateType::Default);
if (NS_FAILED(rv)) {
NS_WARNING("nsCORSListenerProxy::AsyncOnChannelRedirect: "
"UpdateChannel() returned failure");
@@ -800,7 +815,8 @@ CheckUpgradeInsecureRequestsPreventsCORS(nsIPrincipal* aRequestingPrincipal,
nsresult
nsCORSListenerProxy::UpdateChannel(nsIChannel* aChannel,
DataURIHandling aAllowDataURI)
DataURIHandling aAllowDataURI,
UpdateType aUpdateType)
{
nsCOMPtr<nsIURI> uri, originalURI;
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
@@ -870,7 +886,7 @@ nsCORSListenerProxy::UpdateChannel(nsIChannel* aChannel,
// Check if we need to do a preflight, and if so set one up. This must be
// called once we know that the request is going, or has gone, cross-origin.
rv = CheckPreflightNeeded(aChannel);
rv = CheckPreflightNeeded(aChannel, aUpdateType);
NS_ENSURE_SUCCESS(rv, rv);
// It's a cross site load
@@ -909,7 +925,7 @@ nsCORSListenerProxy::UpdateChannel(nsIChannel* aChannel,
}
nsresult
nsCORSListenerProxy::CheckPreflightNeeded(nsIChannel* aChannel)
nsCORSListenerProxy::CheckPreflightNeeded(nsIChannel* aChannel, UpdateType aUpdateType)
{
// If this caller isn't using AsyncOpen2, or if this *is* a preflight channel,
// then we shouldn't initiate preflight for this channel.
@@ -962,7 +978,9 @@ nsCORSListenerProxy::CheckPreflightNeeded(nsIChannel* aChannel)
// A preflight is needed. But if we've already been cross-site, then
// we already did a preflight when that happened, and so we're not allowed
// to do another preflight again.
NS_ENSURE_FALSE(mHasBeenCrossSite, NS_ERROR_DOM_BAD_URI);
if (aUpdateType != UpdateType::InternalOrHSTSRedirect) {
NS_ENSURE_FALSE(mHasBeenCrossSite, NS_ERROR_DOM_BAD_URI);
}
nsCOMPtr<nsIHttpChannelInternal> internal = do_QueryInterface(http);
NS_ENSURE_TRUE(internal, NS_ERROR_DOM_BAD_URI);
+9 -2
View File
@@ -37,6 +37,12 @@ enum class DataURIHandling
Disallow
};
enum class UpdateType
{
Default,
InternalOrHSTSRedirect
};
class nsCORSListenerProxy final : public nsIStreamListener,
public nsIInterfaceRequestor,
public nsIChannelEventSink,
@@ -78,9 +84,10 @@ private:
~nsCORSListenerProxy();
nsresult UpdateChannel(nsIChannel* aChannel, DataURIHandling aAllowDataURI);
nsresult UpdateChannel(nsIChannel* aChannel, DataURIHandling aAllowDataURI,
UpdateType aUpdateType);
nsresult CheckRequestApproved(nsIRequest* aRequest);
nsresult CheckPreflightNeeded(nsIChannel* aChannel);
nsresult CheckPreflightNeeded(nsIChannel* aChannel, UpdateType aUpdateType);
nsCOMPtr<nsIStreamListener> mOuterListener;
// The principal that originally kicked off the request
@@ -24,8 +24,9 @@ ContentPrefInstance.prototype = {
return this._contentPrefSvc.getPref(aName, aGroup, this._context, aCallback);
},
setPref: function ContentPrefInstance_setPref(aGroup, aName, aValue) {
return this._contentPrefSvc.setPref(aGroup, aName, aValue, this._context);
setPref: function ContentPrefInstance_setPref(aGroup, aName, aValue, aContext) {
return this._contentPrefSvc.setPref(aGroup, aName, aValue,
aContext ? aContext : this._context);
},
hasPref: function ContentPrefInstance_hasPref(aGroup, aName) {
@@ -254,7 +254,7 @@ ContentPrefService2.prototype = {
this._pbStore.set(group, name, value);
this._schedule(function () {
cbHandleCompletion(callback, Ci.nsIContentPrefCallback2.COMPLETE_OK);
this._cps._notifyPrefSet(group, name, value);
this._cps._notifyPrefSet(group, name, value, context.usePrivateBrowsing);
});
return;
}
@@ -327,7 +327,7 @@ ContentPrefService2.prototype = {
this._cache.setWithCast(group, name, value);
cbHandleCompletion(callback, reason);
if (ok)
this._cps._notifyPrefSet(group, name, value);
this._cps._notifyPrefSet(group, name, value, context && context.usePrivateBrowsing);
},
onError: function onError(nsresult) {
cbHandleError(callback, nsresult);
@@ -256,7 +256,7 @@ ContentPrefService.prototype = {
if (aContext && aContext.usePrivateBrowsing) {
this._privModeStorage.setWithCast(group, aName, aValue);
this._notifyPrefSet(group, aName, aValue);
this._notifyPrefSet(group, aName, aValue, aContext.usePrivateBrowsing);
return;
}
@@ -278,7 +278,9 @@ ContentPrefService.prototype = {
this._insertPref(groupID, settingID, aValue);
this._cache.setWithCast(group, aName, aValue);
this._notifyPrefSet(group, aName, aValue);
this._notifyPrefSet(group, aName, aValue,
aContext ? aContext.usePrivateBrowsing : false);
},
hasPref: function ContentPrefService_hasPref(aGroup, aName, aContext) {
@@ -382,19 +384,19 @@ ContentPrefService.prototype = {
var settingID = this._selectSettingID(aName);
if (!settingID)
return;
var selectGroupsStmt = this._dbCreateStatement(`
SELECT groups.id AS groupID, groups.name AS groupName
FROM prefs
JOIN groups ON prefs.groupID = groups.id
WHERE prefs.settingID = :setting
`);
var groupNames = [];
var groupIDs = [];
try {
selectGroupsStmt.params.setting = settingID;
while (selectGroupsStmt.executeStep()) {
groupIDs.push(selectGroupsStmt.row["groupID"]);
groupNames.push(selectGroupsStmt.row["groupName"]);
@@ -403,7 +405,7 @@ ContentPrefService.prototype = {
finally {
selectGroupsStmt.reset();
}
if (this.hasPref(null, aName)) {
groupNames.push(null);
}
@@ -538,10 +540,10 @@ ContentPrefService.prototype = {
/**
* Notify all observers about a preference change.
*/
_notifyPrefSet: function ContentPrefService__notifyPrefSet(aGroup, aName, aValue) {
_notifyPrefSet: function ContentPrefService__notifyPrefSet(aGroup, aName, aValue, aIsPrivate) {
for (var observer of this._getObservers(aName)) {
try {
observer.onContentPrefSet(aGroup, aName, aValue);
observer.onContentPrefSet(aGroup, aName, aValue, aIsPrivate);
}
catch(ex) {
Cu.reportError(ex);
@@ -985,7 +987,7 @@ ContentPrefService.prototype = {
finally {
this._stmtSelectPrefsByName.reset();
}
var global = this._selectGlobalPref(aName);
if (typeof global != "undefined") {
prefs.setProperty(null, global);
@@ -1070,7 +1072,9 @@ ContentPrefService.prototype = {
}
// If the connection isn't ready after we open the database, that means
// the database has been corrupted, so we back it up and then recreate it.
catch (e if e.result == Cr.NS_ERROR_FILE_CORRUPTED) {
catch (e) {
if (e.result != Cr.NS_ERROR_FILE_CORRUPTED)
throw e;
dbConnection = this._dbBackUpAndRecreate(dbService, dbFile,
dbConnection);
}
@@ -1259,7 +1263,7 @@ function HostnameGrouper() {}
HostnameGrouper.prototype = {
//**************************************************************************//
// XPCOM Plumbing
classID: Components.ID("{8df290ae-dcaa-4c11-98a5-2429a4dc97bb}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentURIGrouper]),
@@ -1284,7 +1288,7 @@ HostnameGrouper.prototype = {
// reference, and hash, if possible) as the group. This means that URIs
// like about:mozilla and about:blank will be considered separate groups,
// but at least they'll be grouped somehow.
// This also means that each individual file: URL will be considered
// its own group. This seems suboptimal, but so does treating the entire
// file: URL space as a single group (especially if folks start setting
@@ -186,7 +186,7 @@ function run_test() {
//**************************************************************************//
// getPrefs
cps.setPref(uri, "test.getPrefs.a", 1);
cps.setPref(uri, "test.getPrefs.b", 2);
cps.setPref(uri, "test.getPrefs.c", 3);
@@ -236,7 +236,7 @@ function run_test() {
var specificObserver = {
interfaces: [Ci.nsIContentPrefObserver, Ci.nsISupports],
QueryInterface: function ContentPrefTest_QueryInterface(iid) {
if (!this.interfaces.some( function(v) { return iid.equals(v) } ))
throw Cr.NS_ERROR_NO_INTERFACE;
@@ -262,7 +262,7 @@ function run_test() {
var genericObserver = {
interfaces: [Ci.nsIContentPrefObserver, Ci.nsISupports],
QueryInterface: function ContentPrefTest_QueryInterface(iid) {
if (!this.interfaces.some( function(v) { return iid.equals(v) } ))
throw Cr.NS_ERROR_NO_INTERFACE;
@@ -270,12 +270,16 @@ function run_test() {
},
numTimesSetCalled: 0,
onContentPrefSet: function genericObserver_onContentPrefSet(group, name, value) {
onContentPrefSet: function genericObserver_onContentPrefSet(group, name, value, isPrivate) {
++this.numTimesSetCalled;
do_check_eq(group, "www.example.com");
if (name != "test.observer.1" && name != "test.observer.2")
if (name == "test.observer.private")
do_check_true(isPrivate);
else if (name == "test.observer.normal")
do_check_false(isPrivate);
else if (name != "test.observer.1" && name != "test.observer.2")
do_throw("genericObserver.onContentPrefSet: " +
"name not in (test.observer.1, test.observer.2)");
"name not in (test.observer.(1|2|normal|private))");
do_check_eq(value, "test value");
},
@@ -283,9 +287,11 @@ function run_test() {
onContentPrefRemoved: function genericObserver_onContentPrefRemoved(group, name) {
++this.numTimesRemovedCalled;
do_check_eq(group, "www.example.com");
if (name != "test.observer.1" && name != "test.observer.2")
if (name != "test.observer.1" && name != "test.observer.2" &&
name != "test.observer.normal" && name != "test.observer.private") {
do_throw("genericObserver.onContentPrefSet: " +
"name not in (test.observer.1, test.observer.2)");
"name not in (test.observer.(1|2|normal|private))");
}
}
};
@@ -304,6 +310,13 @@ function run_test() {
do_check_eq(specificObserver.numTimesRemovedCalled, 1);
do_check_eq(genericObserver.numTimesRemovedCalled, 2);
// // Make sure information about private context is properly
// // retrieved by the observer.
cps.setPref(uri, "test.observer.private", "test value", {usePrivateBrowsing: true});
cps.setPref(uri, "test.observer.normal", "test value", {usePrivateBrowsing: false});
cps.removePref(uri, "test.observer.private");
cps.removePref(uri, "test.observer.normal");
// Make sure we can remove observers and they don't get notified
// about changes anymore.
cps.removeObserver("test.observer.1", specificObserver);
@@ -311,14 +324,14 @@ function run_test() {
cps.setPref(uri, "test.observer.1", "test value");
cps.removePref(uri, "test.observer.1", "test value");
do_check_eq(specificObserver.numTimesSetCalled, 1);
do_check_eq(genericObserver.numTimesSetCalled, 2);
do_check_eq(genericObserver.numTimesSetCalled, 4);
do_check_eq(specificObserver.numTimesRemovedCalled, 1);
do_check_eq(genericObserver.numTimesRemovedCalled, 2);
do_check_eq(genericObserver.numTimesRemovedCalled, 3);
//**************************************************************************//
// Get/Remove Prefs By Name
{
var anObserver = {
interfaces: [Ci.nsIContentPrefObserver, Ci.nsISupports],
@@ -356,7 +369,7 @@ function run_test() {
cps.setPref(uri4, "test.byname.1", 16);
cps.setPref(null, "test.byname.1", 32);
cps.setPref(null, "test.byname.2", false);
function enumerateAndCheck(testName, expectedSum, expectedDomains) {
var prefsByName = cps.getPrefsByName(testName);
var enumerator = prefsByName.enumerator;
@@ -374,7 +387,7 @@ function run_test() {
// check all domains have been removed from the array
do_check_eq(expectedDomains.length, 0);
}
enumerateAndCheck("test.byname.1", 53,
["foo.domain1.com", null, "www.domain1.com", "www.domain2.com"]);
enumerateAndCheck("test.byname.2", 2, ["www.domain1.com", null]);
@@ -394,9 +407,9 @@ function run_test() {
do_check_eq(anObserver.numTimesRemovedCalled, 4);
do_check_eq(anObserver.expectedDomains.length, 0);
cps.removeObserver("test.byname.1", anObserver);
// Clean up after ourselves
cps.removePref(uri1, "test.byname.2");
cps.removePref(uri3, "test.byname.3");

Some files were not shown because too many files have changed in this diff Show More