зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1434342 P3 Make each ServiceWorker DOM object automatically fire its statechange event when appropriate. r=asuth
This commit is contained in:
Родитель
7427e49f90
Коммит
2508c997c6
|
@ -107,7 +107,11 @@ ServiceWorker::State() const
|
|||
void
|
||||
ServiceWorker::SetState(ServiceWorkerState aState)
|
||||
{
|
||||
ServiceWorkerState oldState = mDescriptor.State();
|
||||
mDescriptor.SetState(aState);
|
||||
if (oldState != aState) {
|
||||
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("statechange"));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -116,12 +120,6 @@ ServiceWorker::GetScriptURL(nsString& aURL) const
|
|||
CopyUTF8toUTF16(mDescriptor.ScriptURL(), aURL);
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorker::DispatchStateChange(ServiceWorkerState aState)
|
||||
{
|
||||
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("statechange"));
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
||||
const Sequence<JSObject*>& aTransferable,
|
||||
|
|
|
@ -47,9 +47,6 @@ public:
|
|||
void
|
||||
GetScriptURL(nsString& aURL) const;
|
||||
|
||||
void
|
||||
DispatchStateChange(ServiceWorkerState aState);
|
||||
|
||||
#ifdef XP_WIN
|
||||
#undef PostMessage
|
||||
#endif
|
||||
|
|
|
@ -159,16 +159,9 @@ public:
|
|||
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
// We need to update the state of all instances atomically before notifying
|
||||
// them to make sure that the observed state for all instances inside
|
||||
// statechange event handlers is correct.
|
||||
for (size_t i = 0; i < mInstances.Length(); ++i) {
|
||||
mInstances[i]->SetState(mState);
|
||||
}
|
||||
for (size_t i = 0; i < mInstances.Length(); ++i) {
|
||||
mInstances[i]->DispatchStateChange(mState);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче