Bug 1469941 Note DOMContentLoaded on the ClientSource and trigger service worker update in appropriate process. r=mrbkap

This commit is contained in:
Ben Kelly 2018-06-23 10:11:47 -07:00
Родитель 9258565483
Коммит a11f4b5b1d
9 изменённых файлов: 69 добавлений и 0 удалений

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

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