Bug 1285898 - [e10s-multi] fixup PContent ordering via immediate event dispatch. r=baku

This commit is contained in:
Andrew Sutherland
2017-01-31 03:42:38 -05:00
parent ab62b3f75f
commit 9dd61a8f4c
3 changed files with 19 additions and 5 deletions

View File

@@ -3046,7 +3046,7 @@ ContentChild::RecvDispatchLocalStorageChange(const nsString& aDocumentURI,
{
Storage::DispatchStorageEvent(Storage::LocalStorage,
aDocumentURI, aKey, aOldValue, aNewValue,
aPrincipal, aIsPrivate, nullptr);
aPrincipal, aIsPrivate, nullptr, true);
return IPC_OK();
}

View File

@@ -231,7 +231,7 @@ Storage::BroadcastChangeNotification(const nsSubstring& aKey,
}
DispatchStorageEvent(GetType(), mDocumentURI, aKey, aOldValue, aNewValue,
mPrincipal, mIsPrivate, this);
mPrincipal, mIsPrivate, this, false);
}
/* static */ void
@@ -242,7 +242,8 @@ Storage::DispatchStorageEvent(StorageType aStorageType,
const nsAString& aNewValue,
nsIPrincipal* aPrincipal,
bool aIsPrivate,
Storage* aStorage)
Storage* aStorage,
bool aImmediateDispatch)
{
StorageEventInit dict;
dict.mBubbles = false;
@@ -266,7 +267,12 @@ Storage::DispatchStorageEvent(StorageType aStorageType,
? u"localStorage"
: u"sessionStorage",
aIsPrivate);
if (aImmediateDispatch) {
Unused << r->Run();
} else {
NS_DispatchToMainThread(r);
}
// If we are in the parent process and we have the principal, we want to
// broadcast this event to every other process.

View File

@@ -131,6 +131,13 @@ public:
}
// aStorage can be null if this method is called by ContentChild.
//
// aImmediateDispatch is for use by (main-thread) IPC code so that PContent
// ordering can be maintained. Without this, the event would be enqueued and
// run in a future turn of the event loop, potentially allowing other PContent
// Recv* methods to trigger script that wants to assume our localstorage
// changes have already been applied. This is the case for message manager
// messages which are used by ContentTask testing logic and webextensions.
static void
DispatchStorageEvent(StorageType aStorageType,
const nsAString& aDocumentURI,
@@ -139,7 +146,8 @@ public:
const nsAString& aNewValue,
nsIPrincipal* aPrincipal,
bool aIsPrivate,
Storage* aStorage);
Storage* aStorage,
bool aImmediateDispatch);
void
ApplyEvent(StorageEvent* aStorageEvent);