зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1469941 Note DOMContentLoaded on the ClientSource and trigger service worker update in appropriate process. r=mrbkap
This commit is contained in:
Родитель
9258565483
Коммит
a11f4b5b1d
|
@ -5097,6 +5097,12 @@ nsIDocument::DispatchContentLoadedEvents()
|
|||
true, true);
|
||||
}
|
||||
|
||||
nsPIDOMWindowInner* inner = GetInnerWindow();
|
||||
if (inner) {
|
||||
inner->NoteDOMContentLoaded();
|
||||
}
|
||||
|
||||
// TODO
|
||||
if (mMaybeServiceWorkerControlled) {
|
||||
using mozilla::dom::ServiceWorkerManager;
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
|
|
|
@ -2355,6 +2355,12 @@ nsPIDOMWindowInner::NoteCalledRegisterForServiceWorkerScope(const nsACString& aS
|
|||
nsGlobalWindowInner::Cast(this)->NoteCalledRegisterForServiceWorkerScope(aScope);
|
||||
}
|
||||
|
||||
void
|
||||
nsPIDOMWindowInner::NoteDOMContentLoaded()
|
||||
{
|
||||
nsGlobalWindowInner::Cast(this)->NoteDOMContentLoaded();
|
||||
}
|
||||
|
||||
bool
|
||||
nsGlobalWindowInner::ShouldReportForServiceWorkerScope(const nsAString& aScope)
|
||||
{
|
||||
|
@ -2471,6 +2477,16 @@ nsGlobalWindowInner::NoteCalledRegisterForServiceWorkerScope(const nsACString& a
|
|||
mClientSource->NoteCalledRegisterForServiceWorkerScope(aScope);
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindowInner::NoteDOMContentLoaded()
|
||||
{
|
||||
if (!mClientSource) {
|
||||
return;
|
||||
}
|
||||
|
||||
mClientSource->NoteDOMContentLoaded();
|
||||
}
|
||||
|
||||
void
|
||||
nsGlobalWindowInner::MigrateStateForDocumentOpen(nsGlobalWindowInner* aOldInner)
|
||||
{
|
||||
|
|
|
@ -365,6 +365,8 @@ public:
|
|||
|
||||
void NoteCalledRegisterForServiceWorkerScope(const nsACString& aScope);
|
||||
|
||||
void NoteDOMContentLoaded();
|
||||
|
||||
virtual nsresult FireDelayedDOMEvents() override;
|
||||
|
||||
virtual nsresult SetNewDocument(nsIDocument *aDocument,
|
||||
|
|
|
@ -332,6 +332,8 @@ public:
|
|||
|
||||
void NoteCalledRegisterForServiceWorkerScope(const nsACString& aScope);
|
||||
|
||||
void NoteDOMContentLoaded();
|
||||
|
||||
mozilla::dom::TabGroup* TabGroup();
|
||||
|
||||
virtual nsPIDOMWindowOuter* GetPrivateRoot() = 0;
|
||||
|
|
|
@ -477,6 +477,22 @@ ClientSource::GetController() const
|
|||
return mController;
|
||||
}
|
||||
|
||||
void
|
||||
ClientSource::NoteDOMContentLoaded()
|
||||
{
|
||||
if (mController.isSome() && !ServiceWorkerParentInterceptEnabled()) {
|
||||
AssertIsOnMainThread();
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
if (swm) {
|
||||
swm->MaybeCheckNavigationUpdate(mClientInfo);
|
||||
}
|
||||
}
|
||||
|
||||
MaybeExecute([] (PClientSourceChild* aActor) {
|
||||
aActor->SendNoteDOMContentLoaded();
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<ClientOpPromise>
|
||||
ClientSource::Focus(const ClientFocusArgs& aArgs)
|
||||
{
|
||||
|
|
|
@ -150,6 +150,11 @@ public:
|
|||
const Maybe<ServiceWorkerDescriptor>&
|
||||
GetController() const;
|
||||
|
||||
// Note that the client has reached DOMContentLoaded. Only applies to window
|
||||
// clients.
|
||||
void
|
||||
NoteDOMContentLoaded();
|
||||
|
||||
RefPtr<ClientOpPromise>
|
||||
Focus(const ClientFocusArgs& aArgs);
|
||||
|
||||
|
|
|
@ -170,6 +170,24 @@ ClientSourceParent::RecvInheritController(const ClientControlledArgs& aArgs)
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
IPCResult
|
||||
ClientSourceParent::RecvNoteDOMContentLoaded()
|
||||
{
|
||||
if (mController.isSome() && ServiceWorkerParentInterceptEnabled()) {
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||
"ClientSourceParent::RecvNoteDOMContentLoaded",
|
||||
[clientInfo = mClientInfo] () {
|
||||
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
|
||||
NS_ENSURE_TRUE_VOID(swm);
|
||||
|
||||
swm->MaybeCheckNavigationUpdate(clientInfo);
|
||||
});
|
||||
|
||||
MOZ_ALWAYS_SUCCEEDS(SystemGroup::Dispatch(TaskCategory::Other, r.forget()));
|
||||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
void
|
||||
ClientSourceParent::ActorDestroy(ActorDestroyReason aReason)
|
||||
{
|
||||
|
|
|
@ -48,6 +48,9 @@ class ClientSourceParent final : public PClientSourceParent
|
|||
mozilla::ipc::IPCResult
|
||||
RecvInheritController(const ClientControlledArgs& aArgs) override;
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
RecvNoteDOMContentLoaded() override;
|
||||
|
||||
void
|
||||
ActorDestroy(ActorDestroyReason aReason) override;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ parent:
|
|||
async Freeze();
|
||||
async Thaw();
|
||||
async InheritController(ClientControlledArgs aArgs);
|
||||
async NoteDOMContentLoaded();
|
||||
|
||||
child:
|
||||
async PClientSourceOp(ClientOpConstructorArgs aArgs);
|
||||
|
|
Загрузка…
Ссылка в новой задаче