fune/toolkit/content/browser-child.js
Nika Layzell 1dfe5d5e5b Bug 1663757 - Part 3: Start sending web progress events in oop subframes, r=annyG
Previously, we would only send web progress events from the toplevel
BrowserParent, as other frames would never have the browser-child.js framescript
loaded in them, and so would never start sending events. This change moves the
decision to begin sending events into BrowserChild itself around the same time
as it would've happened previously with the framescript.

This new callsite should still avoid sending events for the creation of the
initial about:blank document in the BrowserChild, while not skipping any other
events, as before.

Differential Revision: https://phabricator.services.mozilla.com/D105558
2021-03-09 15:29:41 +00:00

40 lines
1.5 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/frame-script */
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.defineModuleGetter(
this,
"BrowserUtils",
"resource://gre/modules/BrowserUtils.jsm"
);
// This message is used to measure content process startup performance in Talos
// tests.
sendAsyncMessage("Content:BrowserChildReady", {
time: Services.telemetry.msSystemNow(),
});
// This is here for now until we find a better way of forcing an about:blank load
// with a particular principal that doesn't involve the message manager. We can't
// do this with JS Window Actors for now because JS Window Actors are tied to the
// document principals themselves, so forcing the load with a new principal is
// self-destructive in that case.
addMessageListener("BrowserElement:CreateAboutBlank", message => {
if (!content.document || content.document.documentURI != "about:blank") {
throw new Error("Can't create a content viewer unless on about:blank");
}
let { principal, partitionedPrincipal } = message.data;
principal = BrowserUtils.principalWithMatchingOA(
principal,
content.document.nodePrincipal
);
partitionedPrincipal = BrowserUtils.principalWithMatchingOA(
partitionedPrincipal,
content.document.partitionedPrincipal
);
docShell.createAboutBlankContentViewer(principal, partitionedPrincipal);
});