Bug 1651519: Remove nsIDOMWindowUtils::currentInnerWindowID. r=nika,remote-protocol-reviewers,webcompat-reviewers,whimboo

It has some properties which make it footgunny, especially in the face of
Fission. Callers should use WindowGlobalChild.innerWindowId instead.

Differential Revision: https://phabricator.services.mozilla.com/D82801
This commit is contained in:
Kris Maglione 2020-08-17 20:20:50 +00:00
parent 949f6d3592
commit 3af8c4138c
44 changed files with 67 additions and 87 deletions

View file

@ -491,5 +491,5 @@ function getTabStateForContentWindow(aContentWindow, aForRemove = false) {
} }
function getInnerWindowIDForWindow(aContentWindow) { function getInnerWindowIDForWindow(aContentWindow) {
return aContentWindow.windowUtils.currentInnerWindowID; return aContentWindow.windowGlobalChild.innerWindowId;
} }

View file

@ -97,7 +97,7 @@ async function promiseBrowserContentUnloaded(browser) {
browser, browser,
MSG_WINDOW_DESTROYED, MSG_WINDOW_DESTROYED,
MSG_WINDOW_DESTROYED => { MSG_WINDOW_DESTROYED => {
let innerWindowId = this.content.windowUtils.currentInnerWindowID; let innerWindowId = this.content.windowGlobalChild.innerWindowId;
let observer = subject => { let observer = subject => {
if ( if (
innerWindowId === subject.QueryInterface(Ci.nsISupportsPRUint64).data innerWindowId === subject.QueryInterface(Ci.nsISupportsPRUint64).data

View file

@ -135,7 +135,7 @@ class ReportSiteIssueHelperChild extends JSWindowActorChild {
} }
_getLoggedMessages(includePrivate = false) { _getLoggedMessages(includePrivate = false) {
const windowId = this.contentWindow.windowUtils.currentInnerWindowID; const windowId = this.contentWindow.windowGlobalChild.innerWindowId;
return this._getConsoleMessages(windowId).concat( return this._getConsoleMessages(windowId).concat(
this._getScriptErrors(windowId, includePrivate) this._getScriptErrors(windowId, includePrivate)
); );

View file

@ -71,7 +71,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=995943
var gGoCount = 0; var gGoCount = 0;
function go() { function go() {
debug("Invoking go for window with id: " + window.windowUtils.currentInnerWindowID); debug("Invoking go for window with id: " + window.windowGlobalChild.innerWindowId);
is(++gGoCount, 1, "Should only call go once!"); is(++gGoCount, 1, "Should only call go once!");
checkLoadFileURI('http://example.com', false).then( checkLoadFileURI('http://example.com', false).then(
pushPrefs.bind(null, [['capability.policy.policynames', ' somepolicy '], pushPrefs.bind(null, [['capability.policy.policynames', ' somepolicy '],

View file

@ -80,7 +80,7 @@ function logAccessDeniedWarning(window, callerInfo, extensionPolicy) {
const msg = `The extension "${name}" is not allowed to access ${reportedURIorPrincipal.spec}`; const msg = `The extension "${name}" is not allowed to access ${reportedURIorPrincipal.spec}`;
const innerWindowId = window.windowUtils.currentInnerWindowID; const innerWindowId = window.windowGlobalChild.innerWindowId;
const errorFlag = 0; const errorFlag = 0;

View file

@ -46,7 +46,7 @@ const EventSourceActor = ActorClassWithSpec(eventSourceSpec, {
startListening: function() { startListening: function() {
this.stopListening(); this.stopListening();
this.innerWindowID = this.targetActor.window.windowUtils.currentInnerWindowID; this.innerWindowID = this.targetActor.window.windowGlobalChild.innerWindowId;
eventSourceEventService.addListener(this.innerWindowID, this); eventSourceEventService.addListener(this.innerWindowID, this);
}, },

View file

@ -50,7 +50,7 @@ const WebSocketActor = ActorClassWithSpec(webSocketSpec, {
startListening: function() { startListening: function() {
this.stopListening(); this.stopListening();
this.innerWindowID = this.targetActor.window.windowUtils.currentInnerWindowID; this.innerWindowID = this.targetActor.window.windowGlobalChild.innerWindowId;
webSocketEventService.addListener(this.innerWindowID, this); webSocketEventService.addListener(this.innerWindowID, this);
}, },

View file

@ -3542,7 +3542,7 @@ const StorageActor = protocol.ActorClassWithSpec(specs.storageSpec, {
getWindowFromInnerWindowID(innerID) { getWindowFromInnerWindowID(innerID) {
innerID = innerID.QueryInterface(Ci.nsISupportsPRUint64).data; innerID = innerID.QueryInterface(Ci.nsISupportsPRUint64).data;
for (const win of this.childWindowPool.values()) { for (const win of this.childWindowPool.values()) {
const id = win.windowUtils.currentInnerWindowID; const id = win.windowGlobalChild.innerWindowId;
if (id == innerID) { if (id == innerID) {
return win; return win;
} }

View file

@ -72,7 +72,7 @@ loader.lazyRequireGetter(
); );
function getWindowID(window) { function getWindowID(window) {
return window.windowUtils.currentInnerWindowID; return window.windowGlobalChild.innerWindowId;
} }
function getDocShellChromeEventHandler(docShell) { function getDocShellChromeEventHandler(docShell) {
@ -112,7 +112,7 @@ exports.getChildDocShells = getChildDocShells;
*/ */
function getInnerId(window) { function getInnerId(window) {
return window.windowUtils.currentInnerWindowID; return window.windowGlobalChild.innerWindowId;
} }
const browsingContextTargetPrototype = { const browsingContextTargetPrototype = {

View file

@ -88,10 +88,10 @@ var WebConsoleUtils = {
* Inner ID for the given window, null if we can't access it. * Inner ID for the given window, null if we can't access it.
*/ */
getInnerWindowId: function(window) { getInnerWindowId: function(window) {
// Might throw with SecurityError: Permission denied to access property "windowUtils" // Might throw with SecurityError: Permission denied to access property
// on cross-origin object. // "windowGlobalChild" on cross-origin object.
try { try {
return window.windowUtils.currentInnerWindowID; return window.windowGlobalChild.innerWindowId;
} catch (e) { } catch (e) {
return null; return null;
} }
@ -546,7 +546,7 @@ WebConsoleCommands._registerOriginal("cd", function(owner, window) {
0, 0,
1, 1,
"content javascript", "content javascript",
owner.window.windowUtils.currentInnerWindowID owner.window.windowGlobalChild.innerWindowId
); );
const Services = require("Services"); const Services = require("Services");
Services.console.logMessage(scriptError); Services.console.logMessage(scriptError);

View file

@ -72,5 +72,5 @@ ContentObserver.prototype = {
// Utility functions. // Utility functions.
ContentObserver.GetInnerWindowID = function(window) { ContentObserver.GetInnerWindowID = function(window) {
return window.windowUtils.currentInnerWindowID; return window.windowGlobalChild.innerWindowId;
}; };

View file

@ -201,7 +201,7 @@ function logInPage(text, flags, window) {
0, 0,
flags, flags,
"screenshot", "screenshot",
window.windowUtils.currentInnerWindowID window.windowGlobalChild.innerWindowId
); );
Services.console.logMessage(scriptError); Services.console.logMessage(scriptError);
} }

View file

@ -22,7 +22,7 @@ function doConsoleCalls(aState)
{ {
const { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm"); const { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm");
const console = new ConsoleAPI({ const console = new ConsoleAPI({
innerID: window.windowUtils.currentInnerWindowID innerID: window.windowGlobalChild.innerWindowId
}); });
const longString = (new Array(DevToolsServer.LONG_STRING_LENGTH + 2)).join("a"); const longString = (new Array(DevToolsServer.LONG_STRING_LENGTH + 2)).join("a");

View file

@ -123,7 +123,7 @@ add_task(async function test() {
let { testFns } = this.content.wrappedJSObject; let { testFns } = this.content.wrappedJSObject;
this.content.onbeforeunload = testFns[testIdx]; this.content.onbeforeunload = testFns[testIdx];
this.content.location = url; this.content.location = url;
return this.content.windowUtils.currentInnerWindowID; return this.content.windowGlobalChild.innerWindowId;
} }
); );
@ -142,7 +142,7 @@ add_task(async function test() {
"Page should have navigated to the correct URL" "Page should have navigated to the correct URL"
); );
Assert.notEqual( Assert.notEqual(
this.content.windowUtils.currentInnerWindowID, this.content.windowGlobalChild.innerWindowId,
winID, winID,
"Page should have a new inner window" "Page should have a new inner window"
); );
@ -157,7 +157,7 @@ add_task(async function test() {
"Page should have the same URL" "Page should have the same URL"
); );
Assert.equal( Assert.equal(
this.content.windowUtils.currentInnerWindowID, this.content.windowGlobalChild.innerWindowId,
winID, winID,
"Page should have the same inner window" "Page should have the same inner window"
); );

View file

@ -157,8 +157,7 @@ DOMRequestIpcHelper.prototype = {
this._window = aWindow; this._window = aWindow;
if (this._window) { if (this._window) {
// We don't use this.innerWindowID, but other classes rely on it. // We don't use this.innerWindowID, but other classes rely on it.
let util = this._window.windowUtils; this.innerWindowID = this._window.windowGlobalChild.innerWindowId;
this.innerWindowID = util.currentInnerWindowID;
} }
this._destroyed = false; this._destroyed = false;

View file

@ -2154,20 +2154,6 @@ nsDOMWindowUtils::GetOuterWindowID(uint64_t* aWindowID) {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsDOMWindowUtils::GetCurrentInnerWindowID(uint64_t* aWindowID) {
nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(window, NS_ERROR_NOT_AVAILABLE);
nsGlobalWindowInner* inner =
nsGlobalWindowOuter::Cast(window)->GetCurrentInnerWindowInternal();
if (!inner) {
return NS_ERROR_NOT_AVAILABLE;
}
*aWindowID = inner->WindowID();
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsDOMWindowUtils::SuspendTimeouts() { nsDOMWindowUtils::SuspendTimeouts() {
nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow); nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);

View file

@ -14,7 +14,7 @@ var service = SpecialPowers.Cc["@mozilla.org/eventsourceevent/service;1"]
.getService(SpecialPowers.Ci.nsIEventSourceEventService); .getService(SpecialPowers.Ci.nsIEventSourceEventService);
ok(!!service, "We have the nsIEventSourceEventService"); ok(!!service, "We have the nsIEventSourceEventService");
var innerId = SpecialPowers.getDOMWindowUtils(window).currentInnerWindowID; var innerId = SpecialPowers.wrap(window).windowGlobalChild.innerWindowId;
ok(innerId, "We have a valid innerWindowID: " + innerId); ok(innerId, "We have a valid innerWindowID: " + innerId);
var channelId = null; var channelId = null;
@ -66,4 +66,4 @@ SimpleTest.waitForExplicitFinish();
</script> </script>
</pre> </pre>
</body> </body>
</html> </html>

View file

@ -14,7 +14,7 @@ var service = SpecialPowers.Cc["@mozilla.org/eventsourceevent/service;1"]
.getService(SpecialPowers.Ci.nsIEventSourceEventService); .getService(SpecialPowers.Ci.nsIEventSourceEventService);
ok(!!service, "We have the nsIEventSourceEventService"); ok(!!service, "We have the nsIEventSourceEventService");
var innerId = SpecialPowers.getDOMWindowUtils(window).currentInnerWindowID; var innerId = SpecialPowers.wrap(window).windowGlobalChild.innerWindowId;
ok(innerId, "We have a valid innerWindowID: " + innerId); ok(innerId, "We have a valid innerWindowID: " + innerId);
var channelId; var channelId;
@ -69,4 +69,4 @@ function checkCallsCount() {
</script> </script>
</pre> </pre>
</body> </body>
</html> </html>

View file

@ -14,7 +14,7 @@ var service = SpecialPowers.Cc["@mozilla.org/eventsourceevent/service;1"]
.getService(SpecialPowers.Ci.nsIEventSourceEventService); .getService(SpecialPowers.Ci.nsIEventSourceEventService);
ok(!!service, "We have the nsIEventSourceEventService"); ok(!!service, "We have the nsIEventSourceEventService");
var innerId = SpecialPowers.getDOMWindowUtils(window).currentInnerWindowID; var innerId = SpecialPowers.wrap(window).windowGlobalChild.innerWindowId;
ok(innerId, "We have a valid innerWindowID: " + innerId); ok(innerId, "We have a valid innerWindowID: " + innerId);
var listener = { var listener = {
@ -64,4 +64,4 @@ function doTest(status) {
</script> </script>
</pre> </pre>
</body> </body>
</html> </html>

View file

@ -14,7 +14,7 @@ var service = SpecialPowers.Cc["@mozilla.org/eventsourceevent/service;1"]
.getService(SpecialPowers.Ci.nsIEventSourceEventService); .getService(SpecialPowers.Ci.nsIEventSourceEventService);
ok(!!service, "We have the nsIEventSourceEventService"); ok(!!service, "We have the nsIEventSourceEventService");
var innerId = SpecialPowers.getDOMWindowUtils(window).currentInnerWindowID; var innerId = SpecialPowers.wrap(window).windowGlobalChild.innerWindowId;
ok(innerId, "We have a valid innerWindowID: " + innerId); ok(innerId, "We have a valid innerWindowID: " + innerId);
var channelId = null; var channelId = null;
@ -58,4 +58,4 @@ SimpleTest.waitForExplicitFinish();
</script> </script>
</pre> </pre>
</body> </body>
</html> </html>

View file

@ -134,9 +134,8 @@ BrowserElementChild.prototype = {
}, },
_tryGetInnerWindowID(win) { _tryGetInnerWindowID(win) {
let utils = win.windowUtils;
try { try {
return utils.currentInnerWindowID; return win.windowGlobalChild.innerWindowId;
} catch (e) { } catch (e) {
return null; return null;
} }

View file

@ -1303,12 +1303,6 @@ interface nsIDOMWindowUtils : nsISupports {
*/ */
readonly attribute unsigned long long outerWindowID; readonly attribute unsigned long long outerWindowID;
/**
* Get the id of the current inner window of this window. If there
* is no current inner window, throws NS_ERROR_NOT_AVAILABLE.
*/
readonly attribute unsigned long long currentInnerWindowID;
/** /**
* Put the window into a state where scripts are frozen and events * Put the window into a state where scripts are frozen and events
* suppressed, for use when the window has launched a modal prompt. * suppressed, for use when the window has launched a modal prompt.

View file

@ -257,7 +257,7 @@ IdpSandbox.prototype = {
// can't rethrow anything else because that could leak information about the // can't rethrow anything else because that could leak information about the
// internal workings of the IdP across origins. // internal workings of the IdP across origins.
_logError(e) { _logError(e) {
let winID = this.window.windowUtils.currentInnerWindowID; let winID = this.window.windowGlobalChild.innerWindowId;
let scriptError = Cc["@mozilla.org/scripterror;1"].createInstance( let scriptError = Cc["@mozilla.org/scripterror;1"].createInstance(
Ci.nsIScriptError Ci.nsIScriptError
); );

View file

@ -253,7 +253,7 @@ setupPrototype(RTCIceCandidate, {
class RTCSessionDescription { class RTCSessionDescription {
init(win) { init(win) {
this._win = win; this._win = win;
this._winID = this._win.windowUtils.currentInnerWindowID; this._winID = this._win.windowGlobalChild.innerWindowId;
} }
__init({ type, sdp }) { __init({ type, sdp }) {
@ -389,7 +389,7 @@ class RTCPeerConnection {
} }
__init(rtcConfig) { __init(rtcConfig) {
this._winID = this._win.windowUtils.currentInnerWindowID; this._winID = this._win.windowGlobalChild.innerWindowId;
// TODO: Update this code once we support pc.setConfiguration, to track // TODO: Update this code once we support pc.setConfiguration, to track
// setting from content independently from pref (Bug 1181768). // setting from content independently from pref (Bug 1181768).
if ( if (
@ -2020,7 +2020,7 @@ setupPrototype(PeerConnectionObserver, {
class RTCPeerConnectionStatic { class RTCPeerConnectionStatic {
init(win) { init(win) {
this._winID = win.windowUtils.currentInnerWindowID; this._winID = win.windowGlobalChild.innerWindowId;
} }
registerPeerConnectionLifecycleCallback(cb) { registerPeerConnectionLifecycleCallback(cb) {

View file

@ -216,8 +216,8 @@ function injectControlledFrame(target = document.body) {
: Promise.reject(new Error("Frame removed from document")); : Promise.reject(new Error("Frame removed from document"));
}, },
innerWindowId() { innerWindowId() {
var utils = SpecialPowers.getDOMWindowUtils(iframe.contentWindow); return SpecialPowers.wrap(iframe).browsingContext.currentWindowContext
return utils.currentInnerWindowID; .innerWindowId;
}, },
}; };

View file

@ -40,7 +40,7 @@ add_task(async function() {
if (aTopic == "console-storage-cache-event") { if (aTopic == "console-storage-cache-event") {
apiCallCount++; apiCallCount++;
if (apiCallCount == 4) { if (apiCallCount == 4) {
let windowId = content.window.windowUtils.currentInnerWindowID; let windowId = content.windowGlobalChild.innerWindowId;
Services.obs.removeObserver(this, "console-storage-cache-event"); Services.obs.removeObserver(this, "console-storage-cache-event");
ok( ok(

View file

@ -17,7 +17,7 @@ function test() {
); );
function getInnerWindowId(aWindow) { function getInnerWindowId(aWindow) {
return aWindow.windowUtils.currentInnerWindowID; return aWindow.windowGlobalChild.innerWindowId;
} }
function whenNewWindowLoaded(aOptions, aCallback) { function whenNewWindowLoaded(aOptions, aCallback) {

View file

@ -2,7 +2,7 @@
<script> <script>
dump("Content running top level script " + window.location.href + "\n"); dump("Content running top level script " + window.location.href + "\n");
var winID = SpecialPowers.getDOMWindowUtils(this).currentInnerWindowID; var winID = SpecialPowers.wrap(this).windowGlobalChild.innerWindowId;
var observer = { var observer = {
observe(subject, topic) { observe(subject, topic) {

View file

@ -23,8 +23,10 @@ function getIDs(iframe) {
// Force inner creation // Force inner creation
win.document; win.document;
var util = SpecialPowers.getDOMWindowUtils(win); return [
return [util.outerWindowID, util.currentInnerWindowID]; SpecialPowers.getDOMWindowUtils(win).outerWindowID,
SpecialPowers.wrap(win).windowGlobalChild.innerWindowId,
];
} }
var i1 = document.createElement("iframe"); var i1 = document.createElement("iframe");

View file

@ -26,7 +26,7 @@ var tests = [
{ payload: (function() { var buffer = ""; for (var i = 0; i < 120; ++i) buffer += i; return buffer; }()) }, { payload: (function() { var buffer = ""; for (var i = 0; i < 120; ++i) buffer += i; return buffer; }()) },
] ]
var innerId = window.top.windowUtils.currentInnerWindowID; var innerId = window.top.windowGlobalChild.innerWindowId;
ok(innerId, "We have a valid innerWindowID: " + innerId); ok(innerId, "We have a valid innerWindowID: " + innerId);
var service = Cc["@mozilla.org/websocketevent/service;1"] var service = Cc["@mozilla.org/websocketevent/service;1"]

View file

@ -38,7 +38,7 @@ function hasExpectedProperties(message, exception) {
is(message.sourceName, location.href, "has correct sourceName/filename"); is(message.sourceName, location.href, "has correct sourceName/filename");
ok(message.lineNumber > 0, "has lineNumber"); ok(message.lineNumber > 0, "has lineNumber");
is(message.innerWindowID, window.windowUtils.currentInnerWindowID, is(message.innerWindowID, window.windowGlobalChild.innerWindowId,
"correct innerWindowID"); "correct innerWindowID");
} }

View file

@ -1439,12 +1439,11 @@ NS_IMETHODIMP HttpBaseChannel::GetTopLevelContentWindowId(uint64_t* aWindowId) {
if (loadContext) { if (loadContext) {
nsCOMPtr<mozIDOMWindowProxy> topWindow; nsCOMPtr<mozIDOMWindowProxy> topWindow;
loadContext->GetTopWindow(getter_AddRefs(topWindow)); loadContext->GetTopWindow(getter_AddRefs(topWindow));
nsCOMPtr<nsIDOMWindowUtils> windowUtils;
if (topWindow) { if (topWindow) {
windowUtils = nsGlobalWindowOuter::Cast(topWindow)->WindowUtils(); if (nsPIDOMWindowInner* inner =
} nsPIDOMWindowOuter::From(topWindow)->GetCurrentInnerWindow()) {
if (windowUtils) { mContentWindowId = inner->WindowID();
windowUtils->GetCurrentInnerWindowID(&mContentWindowId); }
} }
} }
} }

View file

@ -241,7 +241,7 @@ class Page extends ContentProcessDomain {
const window = defaultContext.window; const window = defaultContext.window;
const executionContextId = Runtime._onContextCreated("context-created", { const executionContextId = Runtime._onContextCreated("context-created", {
windowId: window.windowUtils.currentInnerWindowID, windowId: window.windowGlobalChild.innerWindowId,
window, window,
isDefault: false, isDefault: false,
contextName: worldName, contextName: worldName,

View file

@ -89,7 +89,7 @@ class Runtime extends ContentProcessDomain {
// after we replied to `enable` request. // after we replied to `enable` request.
executeSoon(() => { executeSoon(() => {
this._onContextCreated("context-created", { this._onContextCreated("context-created", {
windowId: this.content.windowUtils.currentInnerWindowID, windowId: this.content.windowGlobalChild.innerWindowId,
window: this.content, window: this.content,
isDefault: true, isDefault: true,
}); });
@ -325,8 +325,7 @@ class Runtime extends ContentProcessDomain {
_getDefaultContextForWindow(innerWindowId) { _getDefaultContextForWindow(innerWindowId) {
if (!innerWindowId) { if (!innerWindowId) {
const { windowUtils } = this.content; innerWindowId = this.content.windowGlobalChild.innerWindowId;
innerWindowId = windowUtils.currentInnerWindowID;
} }
const curContexts = this.innerWindowIdToContexts.get(innerWindowId); const curContexts = this.innerWindowIdToContexts.get(innerWindowId);
if (curContexts) { if (curContexts) {

View file

@ -48,7 +48,7 @@ class ExecutionContext {
// Here, we assume that debuggee is a window object and we will propably have // Here, we assume that debuggee is a window object and we will propably have
// to adapt that once we cover workers or contexts that aren't a document. // to adapt that once we cover workers or contexts that aren't a document.
this.window = debuggee; this.window = debuggee;
this.windowId = debuggee.windowUtils.currentInnerWindowID; this.windowId = debuggee.windowGlobalChild.innerWindowId;
this.id = id; this.id = id;
this.frameId = debuggee.docShell.browsingContext.id.toString(); this.frameId = debuggee.docShell.browsingContext.id.toString();
this.isDefault = isDefault; this.isDefault = isDefault;

View file

@ -74,8 +74,8 @@ class ContextObserver {
handleEvent({ type, target, persisted }) { handleEvent({ type, target, persisted }) {
const window = target.defaultView; const window = target.defaultView;
const frameId = window.docShell.browsingContext.id; const frameId = window.browsingContext.id;
const id = window.windowUtils.currentInnerWindowID; const id = window.windowGlobalChild.innerWindowId;
switch (type) { switch (type) {
case "DOMWindowCreated": case "DOMWindowCreated":

View file

@ -231,7 +231,7 @@ class SpecialPowersChild extends JSWindowActorChild {
let window = this.contentWindow; let window = this.contentWindow;
// We should not invoke the getter. // We should not invoke the getter.
if (!("SpecialPowers" in window.wrappedJSObject)) { if (!("SpecialPowers" in window.wrappedJSObject)) {
this._windowID = window.windowUtils.currentInnerWindowID; this._windowID = window.windowGlobalChild.innerWindowId;
defineSpecialPowers(this); defineSpecialPowers(this);
if (this.IsInNestedFrame) { if (this.IsInNestedFrame) {

View file

@ -132,7 +132,9 @@ function wrapPrivileged(obj, win) {
let { windowID, proxies, handler } = perWindowInfo.get(win) || {}; let { windowID, proxies, handler } = perWindowInfo.get(win) || {};
// |windowUtils| is undefined if |win| is a non-window object // |windowUtils| is undefined if |win| is a non-window object
// such as a sandbox. // such as a sandbox.
let currentID = win.windowUtils ? win.windowUtils.currentInnerWindowID : 0; let currentID = win.windowGlobalChild
? win.windowGlobalChild.innerWindowId
: 0;
// Values are dead objects if the inner window is changed. // Values are dead objects if the inner window is changed.
if (windowID !== currentID) { if (windowID !== currentID) {
windowID = currentID; windowID = currentID;

View file

@ -109,7 +109,7 @@ class DefaultMap extends Map {
} }
function getInnerWindowID(window) { function getInnerWindowID(window) {
return window.windowUtils.currentInnerWindowID; return window.windowGlobalChild?.innerWindowId;
} }
/** /**

View file

@ -48,7 +48,7 @@ add_task(async function test_contentscript_devtools_sandbox_metadata() {
let win = window.open("file_sample.html"); let win = window.open("file_sample.html");
let innerWindowID = SpecialPowers.getDOMWindowUtils(win).currentInnerWindowID; let innerWindowID = SpecialPowers.wrap(win).windowGlobalChild.innerWindowId;
await extension.awaitFinish("contentScript.executed"); await extension.awaitFinish("contentScript.executed");

View file

@ -191,7 +191,8 @@ add_task(async function test_ExtensionPageContextChild_in_child_frame() {
let frame = this.content.document.querySelector( let frame = this.content.document.querySelector(
"iframe[src*='iframe.html']" "iframe[src*='iframe.html']"
); );
let innerWindowID = frame.contentWindow.windowUtils.currentInnerWindowID; let innerWindowID =
frame.browsingContext.currentWindowContext.innerWindowId;
let context = ExtensionPageChild.extensionContexts.get(innerWindowID); let context = ExtensionPageChild.extensionContexts.get(innerWindowID);
Assert.ok(context, "Got extension page context for child frame"); Assert.ok(context, "Got extension page context for child frame");
@ -237,7 +238,7 @@ add_task(async function test_ExtensionPageContextChild_in_toplevel() {
"resource://gre/modules/ExtensionPageChild.jsm" "resource://gre/modules/ExtensionPageChild.jsm"
); );
let innerWindowID = this.content.windowUtils.currentInnerWindowID; let innerWindowID = this.content.windowGlobalChild.innerWindowId;
let context = ExtensionPageChild.extensionContexts.get(innerWindowID); let context = ExtensionPageChild.extensionContexts.get(innerWindowID);
Assert.ok(context, "Got extension page context for top-level document"); Assert.ok(context, "Got extension page context for top-level document");

View file

@ -51,7 +51,7 @@ this.InsecurePasswordUtils = {
* Inner ID for the given window. * Inner ID for the given window.
*/ */
_getInnerWindowId(window) { _getInnerWindowId(window) {
return window.windowUtils.currentInnerWindowID; return window.windowGlobalChild.innerWindowId;
}, },
_sendWebConsoleMessage(messageTag, domDoc) { _sendWebConsoleMessage(messageTag, domDoc) {

View file

@ -69,7 +69,7 @@ var AboutReader = function(actor, articlePromise) {
this._docRef = Cu.getWeakReference(doc); this._docRef = Cu.getWeakReference(doc);
this._winRef = Cu.getWeakReference(win); this._winRef = Cu.getWeakReference(win);
this._innerWindowId = win.windowUtils.currentInnerWindowID; this._innerWindowId = win.windowGlobalChild.innerWindowId;
this._article = null; this._article = null;
this._languagePromise = new Promise(resolve => { this._languagePromise = new Promise(resolve => {

View file

@ -37,8 +37,7 @@ function CallbackObject(id, callback, mediator) {
} }
function RemoteMediator(window) { function RemoteMediator(window) {
let utils = window.windowUtils; this._windowID = window.windowGlobalChild.innerWindowId;
this._windowID = utils.currentInnerWindowID;
this.mm = window.docShell.messageManager; this.mm = window.docShell.messageManager;
this.mm.addWeakMessageListener(MSG_INSTALL_CALLBACK, this); this.mm.addWeakMessageListener(MSG_INSTALL_CALLBACK, this);