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

--HG--
extra : rebase_source : 5cb6cd38cd099abbbc9fa9c73e3726cc729b6bf5
This commit is contained in:
Andrew Sutherland 2017-01-31 03:42:38 -05:00
Родитель 2da25e9c13
Коммит 246770dae0
3 изменённых файлов: 19 добавлений и 5 удалений

Просмотреть файл

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

Просмотреть файл

@ -228,7 +228,7 @@ Storage::BroadcastChangeNotification(const nsSubstring& aKey,
}
DispatchStorageEvent(GetType(), mDocumentURI, aKey, aOldValue, aNewValue,
mPrincipal, mIsPrivate, this);
mPrincipal, mIsPrivate, this, false);
}
/* static */ void
@ -239,7 +239,8 @@ Storage::DispatchStorageEvent(StorageType aStorageType,
const nsAString& aNewValue,
nsIPrincipal* aPrincipal,
bool aIsPrivate,
Storage* aStorage)
Storage* aStorage,
bool aImmediateDispatch)
{
StorageEventInit dict;
dict.mBubbles = false;
@ -263,7 +264,12 @@ Storage::DispatchStorageEvent(StorageType aStorageType,
? u"localStorage"
: u"sessionStorage",
aIsPrivate);
NS_DispatchToMainThread(r);
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.

Просмотреть файл

@ -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);