Bug 1582523: Part 1 - Actually block document load event during OOP frame loads. r=nika

This fixes both our failure to register load blockers for remote frames and
our failure to keep the load event blocked during frameloader rebuilding on
remoteness change.

Differential Revision: https://phabricator.services.mozilla.com/D46503

--HG--
extra : source : dff7756afe8ede1e03d775ec4999d4807d82c1da
extra : histedit_source : b02eae2b652683ef17be3e0ff6a908b4bec311f5%2Cc62c8e5e4ca066f8f526a81a9aae0feeb84326a5
This commit is contained in:
Kris Maglione 2019-09-19 11:45:36 -07:00
parent 7b434cc2d3
commit 847fce5501
2 changed files with 21 additions and 5 deletions

View File

@ -14,6 +14,7 @@
#include "mozilla/dom/FrameLoaderBinding.h"
#include "mozilla/dom/HTMLIFrameElement.h"
#include "mozilla/dom/MozFrameLoaderOwnerBinding.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/StaticPrefs_fission.h"
#include "mozilla/EventStateManager.h"
@ -69,6 +70,23 @@ void nsFrameLoaderOwner::ChangeRemoteness(
RefPtr<mozilla::dom::BrowsingContext> bc;
bool networkCreated = false;
// In this case, we're not reparenting a frameloader, we're just destroying
// our current one and creating a new one, so we can use ourselves as the
// owner.
RefPtr<Element> owner = do_QueryObject(this);
MOZ_ASSERT(owner);
// When we destroy the original frameloader, it will stop blocking the parent
// document's load event, and immediately trigger the load event if there are
// no other blockers. Since we're going to be adding a new blocker as soon as
// we recreate the frame loader, this is not what we want, so add our own
// blocker until the process is complete.
Document* doc = owner->OwnerDoc();
doc->BlockOnload();
auto cleanup = MakeScopeExit([&]() {
doc->UnblockOnload(false);
});
// If we already have a Frameloader, destroy it, possibly preserving its
// browsing context.
if (mFrameLoader) {
@ -84,11 +102,6 @@ void nsFrameLoaderOwner::ChangeRemoteness(
mFrameLoader = nullptr;
}
// In this case, we're not reparenting a frameloader, we're just destroying
// our current one and creating a new one, so we can use ourselves as the
// owner.
RefPtr<Element> owner = do_QueryObject(this);
MOZ_ASSERT(owner);
mFrameLoader =
nsFrameLoader::Recreate(owner, bc, aOptions.mRemoteType, networkCreated);

View File

@ -2121,6 +2121,9 @@ already_AddRefed<RemoteBrowser> ContentChild::CreateBrowser(
TabId tabId(nsContentUtils::GenerateTabId());
RefPtr<BrowserBridgeChild> browserBridge =
new BrowserBridgeChild(aFrameLoader, aBrowsingContext, tabId);
nsDocShell::Cast(docShell)->OOPChildLoadStarted(browserBridge);
browserChild->SendPBrowserBridgeConstructor(
browserBridge, PromiseFlatString(aContext.PresentationURL()), aRemoteType,
aBrowsingContext, chromeFlags, tabId);