diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /toolkit/content/browser-child.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/content/browser-child.js')
-rw-r--r-- | toolkit/content/browser-child.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/toolkit/content/browser-child.js b/toolkit/content/browser-child.js new file mode 100644 index 0000000000..7f9620fc19 --- /dev/null +++ b/toolkit/content/browser-child.js @@ -0,0 +1,50 @@ +/* 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" +); + +try { + docShell + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIBrowserChild) + .beginSendingWebProgressEventsToParent(); +} catch (e) { + // In responsive design mode, we do not have a BrowserChild for the in-parent + // document. +} + +// 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); +}); |