2013-04-25 09:29:31 +04:00
|
|
|
/* 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/. */
|
|
|
|
|
2017-02-07 13:52:06 +03:00
|
|
|
/* eslint-env mozilla/frame-script */
|
|
|
|
|
2019-05-30 22:01:29 +03:00
|
|
|
ChromeUtils.defineModuleGetter(
|
|
|
|
this,
|
|
|
|
"BrowserUtils",
|
|
|
|
"resource://gre/modules/BrowserUtils.jsm"
|
|
|
|
);
|
|
|
|
|
2019-01-17 21:18:31 +03:00
|
|
|
const { WebProgressChild } = ChromeUtils.import(
|
|
|
|
"resource://gre/modules/WebProgressChild.jsm"
|
|
|
|
);
|
2013-04-25 09:29:31 +04:00
|
|
|
|
2018-07-30 03:08:58 +03:00
|
|
|
this.WebProgress = new WebProgressChild(this);
|
2017-01-18 10:24:55 +03:00
|
|
|
|
2019-05-23 21:48:18 +03:00
|
|
|
docShell
|
|
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIBrowserChild)
|
|
|
|
.beginSendingWebProgressEventsToParent();
|
|
|
|
|
2019-06-14 00:00:14 +03:00
|
|
|
// This message is used to measure content process startup performance in Talos
|
|
|
|
// tests.
|
|
|
|
sendAsyncMessage("Content:BrowserChildReady", {
|
|
|
|
time: Services.telemetry.msSystemNow(),
|
|
|
|
});
|
2019-07-05 12:14:49 +03:00
|
|
|
|
2016-11-12 02:22:34 +03:00
|
|
|
addEventListener(
|
|
|
|
"DOMTitleChanged",
|
|
|
|
function(aEvent) {
|
2017-07-26 16:18:05 +03:00
|
|
|
if (!aEvent.isTrusted || aEvent.target.defaultView != content) {
|
2013-07-29 19:03:41 +04:00
|
|
|
return;
|
2019-07-05 12:14:49 +03:00
|
|
|
}
|
2013-07-29 19:03:41 +04:00
|
|
|
sendAsyncMessage("DOMTitleChanged", { title: content.document.title });
|
2019-07-05 12:14:49 +03:00
|
|
|
},
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
2016-11-12 02:22:34 +03:00
|
|
|
addEventListener(
|
|
|
|
"ImageContentLoaded",
|
|
|
|
function(aEvent) {
|
2013-07-29 19:03:41 +04:00
|
|
|
if (content.document instanceof Ci.nsIImageDocument) {
|
|
|
|
let req = content.document.imageRequest;
|
|
|
|
if (!req.image) {
|
2019-07-05 12:14:49 +03:00
|
|
|
return;
|
|
|
|
}
|
2013-07-29 19:03:41 +04:00
|
|
|
sendAsyncMessage("ImageDocumentLoaded", {
|
|
|
|
width: req.image.width,
|
|
|
|
height: req.image.height,
|
|
|
|
});
|
|
|
|
}
|
2013-08-29 08:43:00 +04:00
|
|
|
},
|
|
|
|
false
|
|
|
|
);
|
|
|
|
|
2019-05-30 22:01:29 +03:00
|
|
|
// 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");
|
|
|
|
}
|
2019-06-12 12:04:41 +03:00
|
|
|
let { principal, storagePrincipal } = message.data;
|
2019-05-30 22:01:29 +03:00
|
|
|
principal = BrowserUtils.principalWithMatchingOA(
|
|
|
|
principal,
|
|
|
|
content.document.nodePrincipal
|
|
|
|
);
|
2019-06-12 12:04:41 +03:00
|
|
|
storagePrincipal = BrowserUtils.principalWithMatchingOA(
|
|
|
|
storagePrincipal,
|
|
|
|
content.document.effectiveStoragePrincipal
|
|
|
|
);
|
|
|
|
docShell.createAboutBlankContentViewer(principal, storagePrincipal);
|
2019-05-30 22:01:29 +03:00
|
|
|
});
|
|
|
|
|
2014-08-20 02:48:58 +04:00
|
|
|
// We may not get any responses to Browser:Init if the browser element
|
|
|
|
// is torn down too quickly.
|
2018-11-06 12:48:46 +03:00
|
|
|
var outerWindowID = docShell.outerWindowID;
|
2018-11-12 20:57:48 +03:00
|
|
|
var browsingContextId = docShell.browsingContext.id;
|
|
|
|
sendAsyncMessage("Browser:Init", { outerWindowID, browsingContextId });
|