Bug 1463291: Move docShell getter from Document to Window. r=bz

DocShells are associated with outer DOM Windows, rather than Documents, so
having the getter on the document is a bit odd to begin with. But it's also
considerably less convenient, since most of the times when we want a docShell
from JS, we're dealing most directly with a window, and have to detour through
the document to get it.

MozReview-Commit-ID: LUj1H9nG3QL

--HG--
extra : source : fcfb99baa0f0fb60a7c420a712c6ae7c72576871
extra : histedit_source : 5be9b7b29a52a4b8376ee0bdfc5c08b12e3c775a
This commit is contained in:
Kris Maglione 2018-05-21 16:58:23 -07:00
parent 02ba563399
commit 031076f2f3
91 changed files with 116 additions and 121 deletions

View file

@ -857,7 +857,7 @@ function shortenString(aString, aMaxLength) {
* Return main chrome window (crosses chrome boundary)
*/
function getMainChromeWindow(aWindow) {
return aWindow.document.docShell.rootTreeItem.domWindow;
return aWindow.docShell.rootTreeItem.domWindow;
}
/** Sets the test plugin(s) initially expected enabled state.

View file

@ -7080,8 +7080,7 @@ function BrowserOpenAddonsMgr(aView) {
let browserWindow;
var receivePong = function(aSubject, aTopic, aData) {
let browserWin = aSubject.document.docShell
.rootTreeItem.domWindow;
let browserWin = aSubject.docShell.rootTreeItem.domWindow;
if (!emWindow || browserWin == window /* favor the current window */) {
emWindow = aSubject;
browserWindow = browserWin;

View file

@ -302,7 +302,8 @@ add_task(async function checkAdvancedDetails() {
is(message.tagName, "a", "Error message is a link");
message = await ContentTask.spawn(browser, {frame: useFrame}, async function({frame}) {
let doc = frame ? content.document.querySelector("iframe").contentDocument : content.document;
let win = frame ? content.document.querySelector("iframe").contentWindow : content;
let doc = win.document;
let errorCode = doc.getElementById("errorCode");
errorCode.click();
@ -311,7 +312,7 @@ add_task(async function checkAdvancedDetails() {
let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
.getService(Ci.nsISerializationHelper);
let serializable = doc.docShell.failedChannel.securityInfo
let serializable = win.docShell.failedChannel.securityInfo
.QueryInterface(Ci.nsITransportSecurityInfo)
.QueryInterface(Ci.nsISerializable);
let serializedSecurityInfo = serhelper.serializeToString(serializable);
@ -388,7 +389,8 @@ add_task(async function checkAdvancedDetailsForHSTS() {
is(message.cdlTagName, "a", "cert_domain_link is a link");
message = await ContentTask.spawn(browser, {frame: useFrame}, async function({frame}) {
let doc = frame ? content.document.querySelector("iframe").contentDocument : content.document;
let win = frame ? content.document.querySelector("iframe").contentWindow : content;
let doc = win.document;
let errorCode = doc.getElementById("errorCode");
errorCode.click();
@ -397,7 +399,7 @@ add_task(async function checkAdvancedDetailsForHSTS() {
let serhelper = Cc["@mozilla.org/network/serialization-helper;1"]
.getService(Ci.nsISerializationHelper);
let serializable = doc.docShell.failedChannel.securityInfo
let serializable = win.docShell.failedChannel.securityInfo
.QueryInterface(Ci.nsITransportSecurityInfo)
.QueryInterface(Ci.nsISerializable);
let serializedSecurityInfo = serhelper.serializeToString(serializable);

View file

@ -28,8 +28,7 @@ function frameScript() {
});
});
function waitUntilActive() {
let doc = content.document;
if (doc.docShell.isActive && doc.hasFocus()) {
if (docShell.isActive && content.document.hasFocus()) {
sendAsyncMessage("Test:Activated");
} else {
setTimeout(waitUntilActive, 10);

View file

@ -21,7 +21,7 @@ add_task(async function test_principal_click() {
await loadPromise;
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let channel = content.document.docShell.currentDocumentChannel;
let channel = content.docShell.currentDocumentChannel;
is(channel.originalURI.asciiSpec,
"about:test-about-principal-child",
"sanity check - make sure we test the principal for the correct URI");
@ -57,7 +57,7 @@ add_task(async function test_principal_ctrl_click() {
gBrowser.selectTabAtIndex(2);
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let channel = content.document.docShell.currentDocumentChannel;
let channel = content.docShell.currentDocumentChannel;
is(channel.originalURI.asciiSpec,
"about:test-about-principal-child",
"sanity check - make sure we test the principal for the correct URI");
@ -102,7 +102,7 @@ add_task(async function test_principal_right_click_open_link_in_new_tab() {
gBrowser.selectTabAtIndex(2);
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let channel = content.document.docShell.currentDocumentChannel;
let channel = content.docShell.currentDocumentChannel;
is(channel.originalURI.asciiSpec,
"about:test-about-principal-child",
"sanity check - make sure we test the principal for the correct URI");

View file

@ -356,7 +356,7 @@ add_task(async function checkAllTheCSS() {
iframe.contentWindow.location = testFile;
await iframeLoaded;
let doc = iframe.contentWindow.document;
doc.docShell.cssErrorReportingEnabled = true;
iframe.contentWindow.docShell.cssErrorReportingEnabled = true;
// Parse and remove all manifests from the list.
// NOTE that this must be done before filtering out devtools paths

View file

@ -10,7 +10,7 @@ function waitForDocshellActivated() {
// "visibilitychange" event rather than polling the docShell.isActive.
await ContentTaskUtils.waitForEvent(content.document, "visibilitychange",
true /* capture */, (aEvent) => {
return content.document.docShell.isActive;
return content.docShell.isActive;
});
});
}

View file

@ -612,7 +612,7 @@ class TabTracker extends TabTrackerBase {
if (browser.ownerDocument.documentURI === "about:addons") {
// When we're loaded into a <browser> inside about:addons, we need to go up
// one more level.
browser = browser.ownerDocument.docShell.chromeEventHandler;
browser = browser.ownerGlobal.docShell.chromeEventHandler;
({gBrowser} = browser.ownerGlobal);
} else {

View file

@ -287,7 +287,7 @@ WebContentConverterRegistrar.prototype = {
* Returns the browser chrome window in which the content window is in
*/
_getBrowserWindowForContentWindow(aContentWindow) {
return aContentWindow.document.docShell.rootTreeItem.domWindow
return aContentWindow.docShell.rootTreeItem.domWindow
.wrappedJSObject;
},

View file

@ -670,7 +670,7 @@ function handURIToExistingBrowser(uri, location, cmdLine, forcePrivate, triggeri
return;
}
var bwin = navWin.document.docShell.rootTreeItem.domWindow;
var bwin = navWin.docShell.rootTreeItem.domWindow;
bwin.openURI(uri, null, location,
Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL, triggeringPrincipal);
}

View file

@ -21,7 +21,7 @@ add_task(async function test_principal_right_click_open_link_in_new_private_win(
await ContentTask.spawn(privateWin.gBrowser.selectedBrowser, {DUMMY_PAGE, TEST_PAGE}, async function({DUMMY_PAGE, TEST_PAGE}) { // eslint-disable-line
let channel = content.document.docShell.currentDocumentChannel;
let channel = content.docShell.currentDocumentChannel;
is(channel.URI.spec, DUMMY_PAGE,
"sanity check to ensure we check principal for right URI");

View file

@ -46,7 +46,7 @@ function doSearch() {
window.removeEventListener("unload", recordPageClosed);
let win = window.document.docShell.rootTreeItem.domWindow;
let win = window.docShell.rootTreeItem.domWindow;
win.openTrustedLinkIn(submission.uri.spec, "current", {
allowThirdPartyFixup: false,
postData: submission.postData,

View file

@ -225,7 +225,7 @@ function onListKeyDown(aEvent) {
// Helper functions
function getBrowserWindow() {
return window.document.docShell.rootTreeItem.domWindow;
return window.docShell.rootTreeItem.domWindow;
}
function toggleRowChecked(aIx) {

View file

@ -10,6 +10,6 @@ var EXPORTED_SYMBOLS = [
// Get the chrome (ie, browser) window hosting this content.
function getChromeWindow(window) {
return window.document.docShell.rootTreeItem.domWindow
return window.docShell.rootTreeItem.domWindow
.wrappedJSObject;
}

View file

@ -89,7 +89,7 @@ class ClickEventHandler {
// Only when the owner doc has |mixedContentChannel| and the same origin
// should we allow mixed content.
json.allowMixedContent = false;
let docshell = ownerDoc.docShell;
let docshell = ownerDoc.defaultView.docShell;
if (this.mm.docShell.mixedContentChannel) {
const sm = Services.scriptSecurityManager;
try {

View file

@ -27,8 +27,8 @@ const BRAND_PROPERTIES = "chrome://branding/locale/brand.properties";
const HTML_NS = "http://www.w3.org/1999/xhtml";
function getTabBrowser(browser) {
while (browser.ownerDocument.docShell.itemType !== Ci.nsIDocShell.typeChrome) {
browser = browser.ownerDocument.docShell.chromeEventHandler;
while (browser.ownerGlobal.docShell.itemType !== Ci.nsIDocShell.typeChrome) {
browser = browser.ownerGlobal.docShell.chromeEventHandler;
}
return {browser, window: browser.ownerGlobal};
}
@ -106,7 +106,7 @@ var ExtensionsUI = {
showAddonsManager(browser, strings, icon, histkey) {
let global = browser.selectedBrowser.ownerGlobal;
return global.BrowserOpenAddonsMgr("addons://list/extension").then(aomWin => {
let aomBrowser = aomWin.document.docShell.chromeEventHandler;
let aomBrowser = aomWin.docShell.chromeEventHandler;
return this.showPermissionsPrompt(aomBrowser, strings, icon, histkey);
});
},

View file

@ -552,7 +552,7 @@ var NetErrorContent = {
Services.prefs.getBoolPref("security.certerror.hideAddException", false);
}
if (this.isAboutNetError(win.document)) {
let docShell = win.document.docShell;
let docShell = win.docShell;
if (docShell) {
let {securityInfo} = docShell.failedChannel;
// We don't have a securityInfo when this is for example a DNS error.
@ -597,7 +597,7 @@ var NetErrorContent = {
// If we're enabling reports, send a report for this failure.
if (evt.detail) {
let win = evt.originalTarget.ownerGlobal;
let docShell = win.document.docShell;
let docShell = win.docShell;
let {securityInfo} = docShell.failedChannel;
securityInfo.QueryInterface(Ci.nsITransportSecurityInfo);
@ -610,7 +610,7 @@ var NetErrorContent = {
},
onCertError(global, targetElement, win) {
let docShell = win.document.docShell;
let docShell = win.docShell;
global.sendAsyncMessage("Browser:CertExceptionError", {
frameId: WebNavigationFrames.getFrameId(win),
location: win.document.location.href,

View file

@ -8,7 +8,7 @@ var EXPORTED_SYMBOLS = ["PageStyleHandler"];
var PageStyleHandler = {
getViewer(content) {
return content.document.docShell.contentViewer;
return content.docShell.contentViewer;
},
sendStyleSheetInfo(mm) {
@ -50,7 +50,7 @@ var PageStyleHandler = {
return;
}
let mm = win.document.docShell
let mm = win.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
this.sendStyleSheetInfo(mm);

View file

@ -52,8 +52,8 @@ var webProgressListener;
function waitForLoadAndStopIt(expectedURL) {
return new Promise(resolve => {
let webProgress = content.document.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress);
let webProgress = content.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress);
webProgressListener = {
onStateChange(webProg, req, flags, status) {
if (req instanceof Ci.nsIChannel) {

View file

@ -75,7 +75,7 @@ function addWindow(aUrl) {
}
function getChromeWindow(aWindow) {
return aWindow.document.docShell.rootTreeItem.domWindow;
return aWindow.docShell.rootTreeItem.domWindow;
}
// Override addTab/removeTab as defined by shared-head, since these have

View file

@ -519,8 +519,7 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
}
debugService.activationHandler = function(window) {
const chromeWindow = window.document.docShell.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow);
const chromeWindow = window.docShell.rootTreeItem.domWindow;
let setupFinished = false;
slowScriptDebugHandler(chromeWindow.gBrowser.selectedTab,

View file

@ -18,7 +18,7 @@ add_task(async function() {
// perform sanity checks for URI and pricnipals in loadInfo
await ContentTask.spawn(tab.linkedBrowser, {TEST_JSON_FILE}, async function ({TEST_JSON_FILE}) { // eslint-disable-line
const channel = content.document.docShell.currentDocumentChannel;
const channel = content.docShell.currentDocumentChannel;
const channelURI = channel.URI.spec;
ok(channelURI.startsWith("file://") && channelURI.includes(TEST_JSON_FILE),
"sanity: correct channel uri");
@ -44,7 +44,7 @@ add_task(async function() {
// check principals in loadInfo are still correct
await ContentTask.spawn(tab.linkedBrowser, {TEST_JSON_FILE}, async function ({TEST_JSON_FILE}) { // eslint-disable-line
const channel = content.document.docShell.currentDocumentChannel;
const channel = content.docShell.currentDocumentChannel;
const channelURI = channel.URI.spec;
ok(channelURI.startsWith("file://") && channelURI.includes(TEST_JSON_FILE),
"reloaded: correct channel uri");

View file

@ -10,7 +10,7 @@ const Services = require("Services");
* Returns the `nsIDOMWindow` toplevel window for any child/inner window
*/
function getToplevelWindow(window) {
return window.document.docShell.rootTreeItem.domWindow;
return window.docShell.rootTreeItem.domWindow;
}
exports.getToplevelWindow = getToplevelWindow;

View file

@ -373,7 +373,7 @@ async function generateCssMessageStubs() {
gBrowser.selectedBrowser,
[key, code],
function([subKey, subCode]) {
content.document.docShell.cssErrorReportingEnabled = true;
content.docShell.cssErrorReportingEnabled = true;
const style = content.document.createElement("style");
// eslint-disable-next-line no-unsanitized/property
style.innerHTML = subCode;

View file

@ -300,7 +300,7 @@ webExtensionTargetPrototype.isExtensionWindow = function(window) {
webExtensionTargetPrototype.isExtensionWindowDescendent = function(window) {
// Check if the source is coming from a descendant docShell of an extension window.
const rootWin = window.document.docShell.sameTypeRootTreeItem.domWindow;
const rootWin = window.docShell.sameTypeRootTreeItem.domWindow;
return this.isExtensionWindow(rootWin);
};

View file

@ -12,7 +12,7 @@
<p>Test for cached messages</p>
<script class="testbody" type="application/javascript">
document.docShell.cssErrorReportingEnabled = true;
window.docShell.cssErrorReportingEnabled = true;
var ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
.getService(Ci.nsIConsoleAPIStorage);
let expectedConsoleCalls = [];

View file

@ -71,7 +71,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1342989
var webNav = Cc["@mozilla.org/appshell/appShellService;1"].
getService(Ci.nsIAppShellService).createWindowlessBrowser(true);
var docShell = webNav.QueryInterface(Ci.nsIInterfaceRequestor).
let docShell = webNav.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDocShell);
docShell.createAboutBlankContentViewer(
Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal));

View file

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=829383
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
// We need to wait for the hidden window to load, but can't access
// an event target for a regular event listener.

View file

@ -8,7 +8,7 @@
function checkResults() {
// query the uri of the loadingPrincipal and the TriggeringPrincipal and pass
// that information on to the parent for verification.
var channel = SpecialPowers.wrap(document).docShell.currentDocumentChannel;
var channel = SpecialPowers.wrap(window).docShell.currentDocumentChannel;
var triggeringPrincipalURI = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
var loadingPrincipalURI = channel.loadInfo.loadingPrincipal.URI.asciiSpec;
var referrerURI = document.referrer;

View file

@ -51,7 +51,7 @@ var frameA = document.getElementById("framea");
function checkResults() {
frameA.removeEventListener('load', checkResults);
var channel = SpecialPowers.wrap(frameA.contentDocument).docShell.currentDocumentChannel;
var channel = SpecialPowers.wrap(frameA.contentWindow).docShell.currentDocumentChannel;
var triggeringPrincipal = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
var loadingPrincipal = channel.loadInfo.loadingPrincipal.URI.asciiSpec;

View file

@ -37,7 +37,7 @@ var testframe = document.getElementById("testframe");
function checkResults() {
testframe.removeEventListener('load', checkResults);
var channel = SpecialPowers.wrap(testframe.contentDocument).docShell.currentDocumentChannel;
var channel = SpecialPowers.wrap(testframe.contentWindow).docShell.currentDocumentChannel;
var triggeringPrincipal = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
var loadingPrincipal = channel.loadInfo.loadingPrincipal.URI.asciiSpec;

View file

@ -35,7 +35,7 @@ function checkFinish() {
// Test 1: window.open(http:)
var httpWin = window.open("file_triggeringprincipal_window_open.html", "_blank", "width=10,height=10");
httpWin.onload = function() {
var httpChannel = SpecialPowers.wrap(httpWin.document).docShell.currentDocumentChannel;
var httpChannel = SpecialPowers.wrap(httpWin).docShell.currentDocumentChannel;
var httpTriggeringPrincipal = httpChannel.loadInfo.triggeringPrincipal.URI.asciiSpec;
var httpLoadingPrincipal = httpChannel.loadInfo.loadingPrincipal;
@ -56,7 +56,7 @@ httpWin.onload = function() {
// Test 2: window.open(javascript:)
var jsWin = window.open("javascript:'<html><body>js</body></html>';", "_blank", "width=10,height=10");
jsWin.onload = function() {
var jsChannel = SpecialPowers.wrap(jsWin.document).docShell.currentDocumentChannel;
var jsChannel = SpecialPowers.wrap(jsWin).docShell.currentDocumentChannel;
var jsTriggeringPrincipal = jsChannel.loadInfo.triggeringPrincipal.URI.asciiSpec;
var jsLoadingPrincipal = jsChannel.loadInfo.loadingPrincipal;

View file

@ -8,7 +8,7 @@
<script type="text/javascript">
var channel = SpecialPowers.wrap(document).docShell.currentDocumentChannel;
var channel = SpecialPowers.wrap(window).docShell.currentDocumentChannel;
var loadInfo = channel.loadInfo;
// 1) perform some sanity checks

View file

@ -247,7 +247,7 @@
// as an XPCOM interface. But elements are losing all their XPCOM
// interfaces, so let's use an object that will likely stay an XPCOM
// one.
let docshell = savedElement.ownerDocument.docShell;
let docshell = savedElement.ownerGlobal.docShell;
ok(docshell, "We should have a docshell here!");
let secureUI = Cc['@mozilla.org/secure_browser_ui;1']

View file

@ -17,7 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=513194
// The use of document.write is deliberate. We are testing for the
// HTML parser to call the CSS parser once and only once when it
// encounters a new <style> element.
SpecialPowers.wrap(document).docShell.cssErrorReportingEnabled = true;
SpecialPowers.wrap(window).docShell.cssErrorReportingEnabled = true;
SimpleTest.runTestExpectingConsoleMessages(
function () { document.write("<style>qux { foo : bar; }<\/style>") },
[{ errorMessage: /Unknown property/ }]

View file

@ -38,7 +38,7 @@ function frameScript() {
doc.addEventListener("keypress", keyHandler, true);
function waitUntilActive() {
if (doc.docShell.isActive && doc.hasFocus()) {
if (docShell.isActive && doc.hasFocus()) {
sendAsyncMessage("Test:Activated");
} else {
setTimeout(waitUntilActive, 10);

View file

@ -13,8 +13,7 @@ function frameScript() {
!!content.document.fullscreenElement);
});
function waitUntilActive() {
let doc = content.document;
if (doc.docShell.isActive && doc.hasFocus()) {
if (docShell.isActive && content.document.hasFocus()) {
sendAsyncMessage("Test:Activated");
} else {
setTimeout(waitUntilActive, 10);

View file

@ -51,7 +51,7 @@ function runTestsCallback() {
is(state2, false, "Browser returned incorrect private mode state.");
// open a window with private mode and get the references of the elements.
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var contentPage = getRootDirectory(window.location.href) + "privatemode_perwindowpb.xul";
function testOnWindow(aIsPrivate, aCallback) {

View file

@ -1,6 +1,6 @@
<!DOCTYPE html>
<script>
var securityInfoPresent = !!SpecialPowers.wrap(document).docShell.currentDocumentChannel.securityInfo;
var securityInfoPresent = !!SpecialPowers.wrap(window).docShell.currentDocumentChannel.securityInfo;
window.parent.postMessage({status: "protocol",
data: location.protocol,
securityInfoPresent: securityInfoPresent},

View file

@ -34,7 +34,7 @@ function testOnWindow(aIsPrivate, aCallback) {
}
function setupWindow() {
mainWindow = window.document.docShell.rootTreeItem.domWindow;
mainWindow = window.docShell.rootTreeItem.domWindow;
runTest();
}

View file

@ -35,7 +35,7 @@ function whenDelayedStartupFinished(aWindow, aCallback) {
}
function testOnWindow(options, callback) {
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var win = mainWindow.OpenBrowserWindow(options);
windowsToClose.push(win);

View file

@ -274,7 +274,7 @@ function checkSelection(node, testid)
function getTopWindow(win)
{
return win.document.docShell.rootTreeItem.domWindow;
return win.docShell.rootTreeItem.domWindow;
}
function mouseWillTriggerFocus(element)

View file

@ -15,7 +15,7 @@ prefBranch.setIntPref("browser.startup.page", 0);
prefBranch.setCharPref("browser.startup.homepage_override.mstone", "ignore");
function startTest() {
mainWindow = window.document.docShell.rootTreeItem.domWindow;
mainWindow = window.docShell.rootTreeItem.domWindow;
doTest();
}

View file

@ -161,7 +161,7 @@ function whenDelayedStartupFinished(aCallback) {
}
function testOnWindow(aIsPrivate, callback) {
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
mainWindow.openWebLinkIn(CONTENT_PAGE, "window", {
private: aIsPrivate });

View file

@ -383,8 +383,6 @@ partial interface Document {
[ChromeOnly]
attribute boolean styleSheetChangeEventsEnabled;
[ChromeOnly] readonly attribute nsIDocShell? docShell;
[ChromeOnly] readonly attribute DOMString contentLanguage;
[ChromeOnly] readonly attribute nsILoadGroup? documentLoadGroup;

View file

@ -255,6 +255,8 @@ partial interface Window {
[ChromeOnly, Throws] readonly attribute Element? realFrameElement;
[ChromeOnly] readonly attribute nsIDocShell? docShell;
[Throws, NeedsCallerType]
readonly attribute float mozInnerScreenX;
[Throws, NeedsCallerType]

View file

@ -32,7 +32,7 @@ function testOnWindow(aIsPrivate, aCallback) {
}
function setupWindow() {
mainWindow = window.document.docShell.rootTreeItem.domWindow;
mainWindow = window.docShell.rootTreeItem.domWindow;
runTest();
}

View file

@ -43,7 +43,7 @@ var onSpellCheck =
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
script = SpecialPowers.loadChromeScript(function() {
var chromeWin = browserElement.ownerDocument.docShell
var chromeWin = browserElement.ownerGlobal.docShell
.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow);
var contextMenu = chromeWin.document.getElementById("contentAreaContextMenu");

View file

@ -53,7 +53,7 @@ function continueTest() {
// we need to drawWindow the chrome window so we can get a dump of the retained widget layers
// if we have to repaint to fulfill this drawWindow request then it will be impossible to
// observe the bug
var chromewin = SpecialPowers.wrap(win).document.docShell.rootTreeItem.domWindow;
var chromewin = SpecialPowers.wrap(win).docShell.rootTreeItem.domWindow;
var el = window.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
el.width = chromewin.innerWidth;

View file

@ -17,7 +17,7 @@ var todo = window.opener.wrappedJSObject.todo;
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
var gWbp;
function printpreview() {
gWbp = window.frames[1].document.docShell.printPreview;
gWbp = window.frames[1].docShell.printPreview;
var listener = {
onLocationChange: function(webProgress, request, location, flags) { },
onProgressChange: function(webProgress, request, curSelfProgress,
@ -43,7 +43,7 @@ function printpreview() {
}
function exitprintpreview() {
window.frames[1].document.docShell.printPreview.exitPrintPreview();
window.frames[1].docShell.printPreview.exitPrintPreview();
}
function finish() {
@ -89,7 +89,7 @@ function run2() {
}
function run3() {
gWbp = window.frames[1].document.docShell.printPreview;
gWbp = window.frames[1].docShell.printPreview;
ok(gWbp.doingPrintPreview, "Should be doing print preview");
exitprintpreview();
setTimeout(run4, 0);
@ -108,7 +108,7 @@ function run4() {
}
function run5() {
gWbp = window.frames[0].document.docShell.printPreview;
gWbp = window.frames[0].docShell.printPreview;
ok(!gWbp.doingPrintPreview, "Should not be doing print preview anymore2");
//XXX this shouldn't be necessary, see bug 405555

View file

@ -17,7 +17,7 @@ var todo = window.opener.wrappedJSObject.todo;
var SimpleTest = window.opener.wrappedJSObject.SimpleTest;
var gWbp;
function printpreview() {
gWbp = window.frames[1].document.docShell.printPreview;
gWbp = window.frames[1].docShell.printPreview;
var listener = {
onLocationChange: function(webProgress, request, location, flags) { },
onProgressChange: function(webProgress, request, curSelfProgress,
@ -43,7 +43,7 @@ function printpreview() {
}
function exitprintpreview() {
window.frames[1].document.docShell.printPreview.exitPrintPreview();
window.frames[1].docShell.printPreview.exitPrintPreview();
}
function finish() {

View file

@ -24,7 +24,7 @@ var file = Cc["@mozilla.org/file/directory_service;1"]
filePath = file.path;
function printpreview() {
gWbp = window.frames[1].document.docShell.printPreview;
gWbp = window.frames[1].docShell.printPreview;
var listener = {
onLocationChange: function(webProgress, request, location, flags) { },
onProgressChange: function(webProgress, request, curSelfProgress,
@ -60,7 +60,7 @@ function printpreview() {
}
function exitprintpreview() {
window.frames[1].document.docShell.printPreview.exitPrintPreview();
window.frames[1].docShell.printPreview.exitPrintPreview();
}
function finish() {

View file

@ -60,7 +60,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=420499
SimpleTest.waitForExplicitFinish();
function getSelectionController() {
return document.docShell
return window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsISelectionDisplay)
.QueryInterface(Ci.nsISelectionController);

View file

@ -129,7 +129,7 @@ function endTest() {
SimpleTest.finish();
}
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var contentPage = "http://mochi.test:8888/chrome/layout/forms/test/bug536567_iframe.html";
function whenDelayedStartupFinished(aWindow, aCallback) {

View file

@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=413958
Style attr: <span id="setStyle">4</span>.
Properties: <span id="setStyleProp" style="">5</span>.</p>
<script>
SpecialPowers.wrap(document).docShell.cssErrorReportingEnabled = true;
SpecialPowers.wrap(window).docShell.cssErrorReportingEnabled = true;
var tests = [
function() {

View file

@ -9,7 +9,7 @@
<body>
<style id="testbench"></style>
<script>
SpecialPowers.wrap(document).docShell.cssErrorReportingEnabled = true;
SpecialPowers.wrap(window).docShell.cssErrorReportingEnabled = true;
var tests = [
{ css: "@unknown {}", error: "Unrecognized at-rule or error parsing at-rule @unknown." },

View file

@ -18,7 +18,7 @@
// That's not the point of the test, though; the point is only that
// *that text* is properly escaped.
SpecialPowers.wrap(document).docShell.cssErrorReportingEnabled = true;
SpecialPowers.wrap(window).docShell.cssErrorReportingEnabled = true;
// There is one "pattern" for each code path through the error reporter
// that might need to escape some kind of user-supplied text.

View file

@ -527,7 +527,7 @@ sandbox.compareRetainedDisplayLists = g.compareRetainedDisplayLists;
sandbox.browserIsRemote = g.browserIsRemote;
try {
sandbox.asyncPan = g.containingWindow.document.docShell.asyncPanZoomEnabled;
sandbox.asyncPan = g.containingWindow.docShell.asyncPanZoomEnabled;
} catch (e) {
sandbox.asyncPan = false;
}

View file

@ -304,7 +304,7 @@ document.addEventListener("DOMContentLoaded", function() {
// messageManager of that <browser> element, or null.
function getBrowserMessageManager() {
let browser = window
.document.docShell.rootTreeItem.domWindow
.docShell.rootTreeItem.domWindow
.BrowserApp
.getBrowserForDocument(document);
if (browser) {

View file

@ -16,7 +16,7 @@ const UPDATE_INDICATOR = "chrome://browser/skin/images/extension-update.svg";
var gStringBundle = Services.strings.createBundle("chrome://browser/locale/aboutAddons.properties");
XPCOMUtils.defineLazyGetter(window, "gChromeWin", function() {
return window.document.docShell.rootTreeItem.domWindow
return window.docShell.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow);
});
ChromeUtils.defineModuleGetter(window, "Preferences",

View file

@ -8,7 +8,7 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/TelemetryStopwatch.jsm");
XPCOMUtils.defineLazyGetter(window, "gChromeWin", () =>
window.document.docShell.rootTreeItem.domWindow
window.docShell.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow));
ChromeUtils.defineModuleGetter(this, "EventDispatcher",

View file

@ -9,7 +9,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyGetter(window, "gChromeWin", () =>
window.document.docShell.rootTreeItem.domWindow
window.docShell.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow));
document.addEventListener("DOMContentLoaded", function() {

View file

@ -86,7 +86,7 @@ ContentDispatchChooser.prototype =
let dwu = window.windowUtils;
let millis = dwu.millisSinceLastUserInput;
if (millis < 0 || millis >= 1000) {
window.document.docShell.displayLoadError(Cr.NS_ERROR_UNKNOWN_PROTOCOL, aURI, null);
window.docShell.displayLoadError(Cr.NS_ERROR_UNKNOWN_PROTOCOL, aURI, null);
} else {
this._closeBlankWindow(window);
}

View file

@ -51,7 +51,7 @@ ContentPermissionPrompt.prototype = {
},
getChromeWindow: function getChromeWindow(aWindow) {
let chromeWin = aWindow.document.docShell.rootTreeItem.domWindow
let chromeWin = aWindow.docShell.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow);
return chromeWin;
},

View file

@ -6,7 +6,7 @@ ChromeUtils.defineModuleGetter(this, "PromiseUtils",
"resource://gre/modules/PromiseUtils.jsm");
const getBrowserWindow = window => {
return window.document.docShell.rootTreeItem.domWindow;
return window.docShell.rootTreeItem.domWindow;
};
let tabListener = {

View file

@ -283,7 +283,7 @@ var WebrtcUI = {
},
getChromeWindow: function getChromeWindow(aWindow) {
let chromeWin = aWindow.document.docShell.rootTreeItem.domWindow
let chromeWin = aWindow.docShell.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow);
return chromeWin;
},

View file

@ -22,7 +22,7 @@ add_task(async function() {
ok(!content.document.nodePrincipal.isSystemPrincipal,
"about:cache should not have system principal");
let principalURI = content.document.nodePrincipal.URI;
let channel = content.document.docShell.currentDocumentChannel;
let channel = content.docShell.currentDocumentChannel;
ok(!channel.loadInfo.loadingPrincipal, "Loading principal should be null.");
is(principalURI && principalURI.spec, content.document.location.href, "Principal matches location");
let links = [... content.document.querySelectorAll("a[href*=disk]")];
@ -43,7 +43,7 @@ add_task(async function() {
"about:cache with query params should still not have system principal");
let principalURI = content.document.nodePrincipal.URI;
is(principalURI && principalURI.spec, content.document.location.href, "Principal matches location");
let channel = content.document.docShell.currentDocumentChannel;
let channel = content.docShell.currentDocumentChannel;
principalURI = channel.loadInfo.triggeringPrincipal.URI;
is(principalURI && principalURI.spec, "about:cache", "Triggering principal matches previous location");
ok(!channel.loadInfo.loadingPrincipal, "Loading principal should be null.");
@ -60,7 +60,7 @@ add_task(async function() {
"about:cache-entry should also not have system principal");
let principalURI = content.document.nodePrincipal.URI;
is(principalURI && principalURI.spec, content.document.location.href, "Principal matches location");
let channel = content.document.docShell.currentDocumentChannel;
let channel = content.docShell.currentDocumentChannel;
principalURI = channel.loadInfo.triggeringPrincipal.URI;
is(principalURI && principalURI.spec, triggeringURISpec, "Triggering principal matches previous location");
ok(!channel.loadInfo.loadingPrincipal, "Loading principal should be null.");

View file

@ -29,7 +29,7 @@
// When the round begins, this will be initialized.
var testsleftinround = 0;
var currentround = "";
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
SpecialPowers.Services.prefs.setIntPref("browser.startup.page", 0);

View file

@ -1415,7 +1415,7 @@ SpecialPowersAPI.prototype = {
// XXX: these APIs really ought to be removed, they're not e10s-safe.
// (also they're pretty Firefox-specific)
_getTopChromeWindow(window) {
return window.document.docShell.rootTreeItem.domWindow
return window.docShell.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow);
},
_getAutoCompletePopup(window) {

View file

@ -368,8 +368,7 @@ class BaseContext {
}
setContentWindow(contentWindow) {
let {document} = contentWindow;
let {docShell} = document;
let {document, docShell} = contentWindow;
this.innerWindowID = getInnerWindowID(contentWindow);
this.messageManager = docShell.QueryInterface(Ci.nsIInterfaceRequestor)

View file

@ -399,7 +399,7 @@ ExtensionPageChild = {
throw new Error("An extension context was already initialized for this frame");
}
let mm = contentWindow.document.docShell
let mm = contentWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);

View file

@ -661,7 +661,7 @@ class ExtensionPageContextParent extends ProxyContextParent {
// The window that contains this context. This may change due to moving tabs.
get xulWindow() {
let win = this.xulBrowser.ownerGlobal;
return win.document.docShell.rootTreeItem.domWindow;
return win.docShell.rootTreeItem.domWindow;
}
get currentWindow() {

View file

@ -89,7 +89,7 @@ var contentScripts = new DefaultWeakMap(matcher => {
});
function getMessageManager(window) {
let docShell = window.document.docShell.QueryInterface(Ci.nsIInterfaceRequestor);
let docShell = window.docShell.QueryInterface(Ci.nsIInterfaceRequestor);
try {
return docShell.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {

View file

@ -788,7 +788,7 @@ class WindowBase {
* @readonly
*/
get xulWindow() {
return this.window.document.docShell.treeOwner
return this.window.docShell.treeOwner
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIXULWindow);
}

View file

@ -194,7 +194,7 @@ function checkTest() {
}
}
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var contentPage = "http://mochi.test:8888/chrome/toolkit/components/passwordmgr/test/chrome/privbrowsing_perwindowpb_iframe.html";
var testWindows = [];

View file

@ -2459,9 +2459,7 @@ Engine.prototype = {
let attrs = options.originAttributes;
if (!attrs) {
attrs = options.window.document
.docShell
.getOriginAttributes();
attrs = options.window.docShell.getOriginAttributes();
}
let principal = Services.scriptSecurityManager

View file

@ -20,7 +20,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://testing-common/TestUtils.jsm");
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var testDatas = [
{ url: "itisaphishingsite.org/phishing.html",

View file

@ -14,7 +14,7 @@
<script class="testbody" type="text/javascript">
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
const tests = [
// DNT turned on and TP turned off, DNT signal sent in both private browsing

View file

@ -16,7 +16,7 @@
<script class="testbody" type="text/javascript">
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var contentPage = "http://www.itisatrap.org/tests/toolkit/components/url-classifier/tests/mochitest/classifiedAnnotatedPBFrame.html";
ChromeUtils.import("resource://gre/modules/Services.jsm");

View file

@ -21,7 +21,7 @@ ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
ChromeUtils.import("resource://testing-common/ContentTask.jsm");
ChromeUtils.import("resource://testing-common/TestUtils.jsm");
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
const SJS = "mochi.test:8888/chrome/toolkit/components/url-classifier/tests/mochitest/report.sjs";
const BASE_URL = "http://" + SJS + "?";

View file

@ -21,7 +21,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var listmanager = Cc["@mozilla.org/url-classifier/listmanager;1"].
getService(Ci.nsIUrlListManager);
@ -192,7 +192,7 @@ function testOnWindow(aTestData) {
let expected;
let browser = win.gBrowser.selectedBrowser;
let wp = win.gBrowser.contentDocument.docShell.QueryInterface(Ci.nsIWebProgress);
let wp = win.gBrowser.contentWindow.docShell.QueryInterface(Ci.nsIWebProgress);
let progressListener = {
onSecurityChange(aWebProgress, aRequest, aState) {
expected = aTestData.reportUrl;

View file

@ -16,7 +16,7 @@
<script class="testbody" type="text/javascript">
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var contentPage = "chrome://mochitests/content/chrome/toolkit/components/url-classifier/tests/mochitest/classifiedAnnotatedPBFrame.html";
ChromeUtils.import("resource://gre/modules/Services.jsm");

View file

@ -16,7 +16,7 @@
<script class="testbody" type="text/javascript">
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var contentPage = "http://www.itisatrap.org/tests/toolkit/components/url-classifier/tests/mochitest/trackingRequest.html";
ChromeUtils.import("resource://gre/modules/Services.jsm");

View file

@ -16,7 +16,7 @@
<script class="testbody" type="text/javascript">
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var contentPage1 = "http://www.itisatrap.org/tests/toolkit/components/url-classifier/tests/mochitest/whitelistFrame.html";
var contentPage2 = "http://example.com/tests/toolkit/components/url-classifier/tests/mochitest/whitelistFrame.html";

View file

@ -129,7 +129,7 @@ function sectionalizeObject(obj) {
* Obtain the main DOMWindow for the current context.
*/
function getMainWindow() {
return window.document.docShell.rootTreeItem.domWindow;
return window.docShell.rootTreeItem.domWindow;
}
/**

View file

@ -38,7 +38,7 @@ add_task(async function preferred_API() {
saveImageURL(url, "image.jpg", null, true, false, null, null, null, null,
false, gBrowser.contentPrincipal);
let channel = gBrowser.contentDocumentAsCPOW.docShell.currentDocumentChannel;
let channel = gBrowser.contentWindowAsCPOW.docShell.currentDocumentChannel;
if (channel) {
ok(true, channel.QueryInterface(Ci.nsIHttpChannelInternal)
.channelIsForDownload);
@ -74,7 +74,7 @@ add_task(async function deprecated_API() {
// pass the XUL document instead to test this interface.
let doc = document;
let channel = gBrowser.contentDocumentAsCPOW.docShell.currentDocumentChannel;
let channel = gBrowser.contentWindowAsCPOW.docShell.currentDocumentChannel;
if (channel) {
ok(true, channel.QueryInterface(Ci.nsIHttpChannelInternal)
.channelIsForDownload);

View file

@ -12,7 +12,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
function getMessageManager(event) {
let window = Cu.getGlobalForObject(event.target);
return window.document.docShell
return window.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
}

View file

@ -278,7 +278,7 @@ function isDiscoverEnabled() {
* Obtain the main DOMWindow for the current context.
*/
function getMainWindow() {
return window.document.docShell.rootTreeItem.domWindow;
return window.docShell.rootTreeItem.domWindow;
}
function getBrowserElement() {
@ -3450,7 +3450,7 @@ var gDragDrop = {
// (See Bug 1385548 for rationale).
var gBrowser = {
getTabModalPromptBox(browser) {
const parentWindow = document.docShell.chromeEventHandler.ownerGlobal;
const parentWindow = window.docShell.chromeEventHandler.ownerGlobal;
if (parentWindow.gBrowser) {
return parentWindow.gBrowser.getTabModalPromptBox(browser);

View file

@ -29,7 +29,7 @@ function finish() {
SimpleTest.finish();
}
var mainWindow = window.document.docShell.rootTreeItem.domWindow;
var mainWindow = window.docShell.rootTreeItem.domWindow;
var offscreenWindow = mainWindow.openDialog("window_bug593307_offscreen.xul", "",
"dialog=no,chrome,width=200,height=200,screenX=-3000,screenY=-3000",

View file

@ -58,7 +58,7 @@ $("display").innerHTML = "found nativeHandle for this window: "+nativeHandle;
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
var docShell = getBaseWindowInterfaceFromDocShell(win);
let docShell = getBaseWindowInterfaceFromDocShell(win);
ok(
shouldThrowException(function(){docShell.nativeHandle;},

View file

@ -40,7 +40,7 @@
// HACK from mconnor:
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
let win = wm.getMostRecentWindow("navigator:browser");
let docShell = win.document.docShell;
let docShell = win.docShell;
let progress = taskbar.getTaskbarProgress(docShell);
isnot(progress, null, "Progress is not null");