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) * Return main chrome window (crosses chrome boundary)
*/ */
function getMainChromeWindow(aWindow) { function getMainChromeWindow(aWindow) {
return aWindow.document.docShell.rootTreeItem.domWindow; return aWindow.docShell.rootTreeItem.domWindow;
} }
/** Sets the test plugin(s) initially expected enabled state. /** Sets the test plugin(s) initially expected enabled state.

View file

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

View file

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

View file

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

View file

@ -21,7 +21,7 @@ add_task(async function test_principal_click() {
await loadPromise; await loadPromise;
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() { await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let channel = content.document.docShell.currentDocumentChannel; let channel = content.docShell.currentDocumentChannel;
is(channel.originalURI.asciiSpec, is(channel.originalURI.asciiSpec,
"about:test-about-principal-child", "about:test-about-principal-child",
"sanity check - make sure we test the principal for the correct URI"); "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); gBrowser.selectTabAtIndex(2);
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() { await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let channel = content.document.docShell.currentDocumentChannel; let channel = content.docShell.currentDocumentChannel;
is(channel.originalURI.asciiSpec, is(channel.originalURI.asciiSpec,
"about:test-about-principal-child", "about:test-about-principal-child",
"sanity check - make sure we test the principal for the correct URI"); "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); gBrowser.selectTabAtIndex(2);
await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() { await ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
let channel = content.document.docShell.currentDocumentChannel; let channel = content.docShell.currentDocumentChannel;
is(channel.originalURI.asciiSpec, is(channel.originalURI.asciiSpec,
"about:test-about-principal-child", "about:test-about-principal-child",
"sanity check - make sure we test the principal for the correct URI"); "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; iframe.contentWindow.location = testFile;
await iframeLoaded; await iframeLoaded;
let doc = iframe.contentWindow.document; let doc = iframe.contentWindow.document;
doc.docShell.cssErrorReportingEnabled = true; iframe.contentWindow.docShell.cssErrorReportingEnabled = true;
// Parse and remove all manifests from the list. // Parse and remove all manifests from the list.
// NOTE that this must be done before filtering out devtools paths // 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. // "visibilitychange" event rather than polling the docShell.isActive.
await ContentTaskUtils.waitForEvent(content.document, "visibilitychange", await ContentTaskUtils.waitForEvent(content.document, "visibilitychange",
true /* capture */, (aEvent) => { 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") { if (browser.ownerDocument.documentURI === "about:addons") {
// When we're loaded into a <browser> inside about:addons, we need to go up // When we're loaded into a <browser> inside about:addons, we need to go up
// one more level. // one more level.
browser = browser.ownerDocument.docShell.chromeEventHandler; browser = browser.ownerGlobal.docShell.chromeEventHandler;
({gBrowser} = browser.ownerGlobal); ({gBrowser} = browser.ownerGlobal);
} else { } else {

View file

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

View file

@ -670,7 +670,7 @@ function handURIToExistingBrowser(uri, location, cmdLine, forcePrivate, triggeri
return; return;
} }
var bwin = navWin.document.docShell.rootTreeItem.domWindow; var bwin = navWin.docShell.rootTreeItem.domWindow;
bwin.openURI(uri, null, location, bwin.openURI(uri, null, location,
Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL, triggeringPrincipal); 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 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, is(channel.URI.spec, DUMMY_PAGE,
"sanity check to ensure we check principal for right URI"); "sanity check to ensure we check principal for right URI");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -75,7 +75,7 @@ function addWindow(aUrl) {
} }
function getChromeWindow(aWindow) { 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 // 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) { debugService.activationHandler = function(window) {
const chromeWindow = window.document.docShell.rootTreeItem.domWindow const chromeWindow = window.docShell.rootTreeItem.domWindow;
.QueryInterface(Ci.nsIDOMChromeWindow);
let setupFinished = false; let setupFinished = false;
slowScriptDebugHandler(chromeWindow.gBrowser.selectedTab, slowScriptDebugHandler(chromeWindow.gBrowser.selectedTab,

View file

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

View file

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

View file

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

View file

@ -300,7 +300,7 @@ webExtensionTargetPrototype.isExtensionWindow = function(window) {
webExtensionTargetPrototype.isExtensionWindowDescendent = function(window) { webExtensionTargetPrototype.isExtensionWindowDescendent = function(window) {
// Check if the source is coming from a descendant docShell of an extension 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); return this.isExtensionWindow(rootWin);
}; };

View file

@ -12,7 +12,7 @@
<p>Test for cached messages</p> <p>Test for cached messages</p>
<script class="testbody" type="application/javascript"> <script class="testbody" type="application/javascript">
document.docShell.cssErrorReportingEnabled = true; window.docShell.cssErrorReportingEnabled = true;
var ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"] var ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"]
.getService(Ci.nsIConsoleAPIStorage); .getService(Ci.nsIConsoleAPIStorage);
let expectedConsoleCalls = []; 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"]. var webNav = Cc["@mozilla.org/appshell/appShellService;1"].
getService(Ci.nsIAppShellService).createWindowlessBrowser(true); getService(Ci.nsIAppShellService).createWindowlessBrowser(true);
var docShell = webNav.QueryInterface(Ci.nsIInterfaceRequestor). let docShell = webNav.QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDocShell); getInterface(Ci.nsIDocShell);
docShell.createAboutBlankContentViewer( docShell.createAboutBlankContentViewer(
Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal)); 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"> <script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish(); 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 // We need to wait for the hidden window to load, but can't access
// an event target for a regular event listener. // an event target for a regular event listener.

View file

@ -8,7 +8,7 @@
function checkResults() { function checkResults() {
// query the uri of the loadingPrincipal and the TriggeringPrincipal and pass // query the uri of the loadingPrincipal and the TriggeringPrincipal and pass
// that information on to the parent for verification. // 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 triggeringPrincipalURI = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
var loadingPrincipalURI = channel.loadInfo.loadingPrincipal.URI.asciiSpec; var loadingPrincipalURI = channel.loadInfo.loadingPrincipal.URI.asciiSpec;
var referrerURI = document.referrer; var referrerURI = document.referrer;

View file

@ -51,7 +51,7 @@ var frameA = document.getElementById("framea");
function checkResults() { function checkResults() {
frameA.removeEventListener('load', 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 triggeringPrincipal = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
var loadingPrincipal = channel.loadInfo.loadingPrincipal.URI.asciiSpec; var loadingPrincipal = channel.loadInfo.loadingPrincipal.URI.asciiSpec;

View file

@ -37,7 +37,7 @@ var testframe = document.getElementById("testframe");
function checkResults() { function checkResults() {
testframe.removeEventListener('load', 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 triggeringPrincipal = channel.loadInfo.triggeringPrincipal.URI.asciiSpec;
var loadingPrincipal = channel.loadInfo.loadingPrincipal.URI.asciiSpec; var loadingPrincipal = channel.loadInfo.loadingPrincipal.URI.asciiSpec;

View file

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

View file

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

View file

@ -247,7 +247,7 @@
// as an XPCOM interface. But elements are losing all their XPCOM // as an XPCOM interface. But elements are losing all their XPCOM
// interfaces, so let's use an object that will likely stay an XPCOM // interfaces, so let's use an object that will likely stay an XPCOM
// one. // one.
let docshell = savedElement.ownerDocument.docShell; let docshell = savedElement.ownerGlobal.docShell;
ok(docshell, "We should have a docshell here!"); ok(docshell, "We should have a docshell here!");
let secureUI = Cc['@mozilla.org/secure_browser_ui;1'] 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 // 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 // HTML parser to call the CSS parser once and only once when it
// encounters a new <style> element. // encounters a new <style> element.
SpecialPowers.wrap(document).docShell.cssErrorReportingEnabled = true; SpecialPowers.wrap(window).docShell.cssErrorReportingEnabled = true;
SimpleTest.runTestExpectingConsoleMessages( SimpleTest.runTestExpectingConsoleMessages(
function () { document.write("<style>qux { foo : bar; }<\/style>") }, function () { document.write("<style>qux { foo : bar; }<\/style>") },
[{ errorMessage: /Unknown property/ }] [{ errorMessage: /Unknown property/ }]

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -43,7 +43,7 @@ var onSpellCheck =
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() { SimpleTest.waitForFocus(function() {
script = SpecialPowers.loadChromeScript(function() { script = SpecialPowers.loadChromeScript(function() {
var chromeWin = browserElement.ownerDocument.docShell var chromeWin = browserElement.ownerGlobal.docShell
.rootTreeItem.domWindow .rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow); .QueryInterface(Ci.nsIDOMChromeWindow);
var contextMenu = chromeWin.document.getElementById("contentAreaContextMenu"); 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 // 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 // if we have to repaint to fulfill this drawWindow request then it will be impossible to
// observe the bug // 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"); var el = window.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
el.width = chromewin.innerWidth; el.width = chromewin.innerWidth;

View file

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

View file

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

View file

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

View file

@ -129,7 +129,7 @@ function endTest() {
SimpleTest.finish(); 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"; var contentPage = "http://mochi.test:8888/chrome/layout/forms/test/bug536567_iframe.html";
function whenDelayedStartupFinished(aWindow, aCallback) { 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>. Style attr: <span id="setStyle">4</span>.
Properties: <span id="setStyleProp" style="">5</span>.</p> Properties: <span id="setStyleProp" style="">5</span>.</p>
<script> <script>
SpecialPowers.wrap(document).docShell.cssErrorReportingEnabled = true; SpecialPowers.wrap(window).docShell.cssErrorReportingEnabled = true;
var tests = [ var tests = [
function() { function() {

View file

@ -9,7 +9,7 @@
<body> <body>
<style id="testbench"></style> <style id="testbench"></style>
<script> <script>
SpecialPowers.wrap(document).docShell.cssErrorReportingEnabled = true; SpecialPowers.wrap(window).docShell.cssErrorReportingEnabled = true;
var tests = [ var tests = [
{ css: "@unknown {}", error: "Unrecognized at-rule or error parsing at-rule @unknown." }, { 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's not the point of the test, though; the point is only that
// *that text* is properly escaped. // *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 // There is one "pattern" for each code path through the error reporter
// that might need to escape some kind of user-supplied text. // 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; sandbox.browserIsRemote = g.browserIsRemote;
try { try {
sandbox.asyncPan = g.containingWindow.document.docShell.asyncPanZoomEnabled; sandbox.asyncPan = g.containingWindow.docShell.asyncPanZoomEnabled;
} catch (e) { } catch (e) {
sandbox.asyncPan = false; sandbox.asyncPan = false;
} }

View file

@ -304,7 +304,7 @@ document.addEventListener("DOMContentLoaded", function() {
// messageManager of that <browser> element, or null. // messageManager of that <browser> element, or null.
function getBrowserMessageManager() { function getBrowserMessageManager() {
let browser = window let browser = window
.document.docShell.rootTreeItem.domWindow .docShell.rootTreeItem.domWindow
.BrowserApp .BrowserApp
.getBrowserForDocument(document); .getBrowserForDocument(document);
if (browser) { 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"); var gStringBundle = Services.strings.createBundle("chrome://browser/locale/aboutAddons.properties");
XPCOMUtils.defineLazyGetter(window, "gChromeWin", function() { XPCOMUtils.defineLazyGetter(window, "gChromeWin", function() {
return window.document.docShell.rootTreeItem.domWindow return window.docShell.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow); .QueryInterface(Ci.nsIDOMChromeWindow);
}); });
ChromeUtils.defineModuleGetter(window, "Preferences", ChromeUtils.defineModuleGetter(window, "Preferences",

View file

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

View file

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

View file

@ -86,7 +86,7 @@ ContentDispatchChooser.prototype =
let dwu = window.windowUtils; let dwu = window.windowUtils;
let millis = dwu.millisSinceLastUserInput; let millis = dwu.millisSinceLastUserInput;
if (millis < 0 || millis >= 1000) { 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 { } else {
this._closeBlankWindow(window); this._closeBlankWindow(window);
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -29,7 +29,7 @@
// When the round begins, this will be initialized. // When the round begins, this will be initialized.
var testsleftinround = 0; var testsleftinround = 0;
var currentround = ""; var currentround = "";
var mainWindow = window.document.docShell.rootTreeItem.domWindow; var mainWindow = window.docShell.rootTreeItem.domWindow;
SpecialPowers.Services.prefs.setIntPref("browser.startup.page", 0); 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. // XXX: these APIs really ought to be removed, they're not e10s-safe.
// (also they're pretty Firefox-specific) // (also they're pretty Firefox-specific)
_getTopChromeWindow(window) { _getTopChromeWindow(window) {
return window.document.docShell.rootTreeItem.domWindow return window.docShell.rootTreeItem.domWindow
.QueryInterface(Ci.nsIDOMChromeWindow); .QueryInterface(Ci.nsIDOMChromeWindow);
}, },
_getAutoCompletePopup(window) { _getAutoCompletePopup(window) {

View file

@ -368,8 +368,7 @@ class BaseContext {
} }
setContentWindow(contentWindow) { setContentWindow(contentWindow) {
let {document} = contentWindow; let {document, docShell} = contentWindow;
let {docShell} = document;
this.innerWindowID = getInnerWindowID(contentWindow); this.innerWindowID = getInnerWindowID(contentWindow);
this.messageManager = docShell.QueryInterface(Ci.nsIInterfaceRequestor) 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"); throw new Error("An extension context was already initialized for this frame");
} }
let mm = contentWindow.document.docShell let mm = contentWindow.docShell
.QueryInterface(Ci.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager); .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. // The window that contains this context. This may change due to moving tabs.
get xulWindow() { get xulWindow() {
let win = this.xulBrowser.ownerGlobal; let win = this.xulBrowser.ownerGlobal;
return win.document.docShell.rootTreeItem.domWindow; return win.docShell.rootTreeItem.domWindow;
} }
get currentWindow() { get currentWindow() {

View file

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

View file

@ -788,7 +788,7 @@ class WindowBase {
* @readonly * @readonly
*/ */
get xulWindow() { get xulWindow() {
return this.window.document.docShell.treeOwner return this.window.docShell.treeOwner
.QueryInterface(Ci.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIXULWindow); .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 contentPage = "http://mochi.test:8888/chrome/toolkit/components/passwordmgr/test/chrome/privbrowsing_perwindowpb_iframe.html";
var testWindows = []; var testWindows = [];

View file

@ -2459,9 +2459,7 @@ Engine.prototype = {
let attrs = options.originAttributes; let attrs = options.originAttributes;
if (!attrs) { if (!attrs) {
attrs = options.window.document attrs = options.window.docShell.getOriginAttributes();
.docShell
.getOriginAttributes();
} }
let principal = Services.scriptSecurityManager 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/TestUtils.jsm");
ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm"); ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
var mainWindow = window.document.docShell.rootTreeItem.domWindow; var mainWindow = window.docShell.rootTreeItem.domWindow;
var testDatas = [ var testDatas = [
{ url: "itisaphishingsite.org/phishing.html", { url: "itisaphishingsite.org/phishing.html",

View file

@ -14,7 +14,7 @@
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
var mainWindow = window.document.docShell.rootTreeItem.domWindow; var mainWindow = window.docShell.rootTreeItem.domWindow;
const tests = [ const tests = [
// DNT turned on and TP turned off, DNT signal sent in both private browsing // 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"> <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"; var contentPage = "http://www.itisatrap.org/tests/toolkit/components/url-classifier/tests/mochitest/classifiedAnnotatedPBFrame.html";
ChromeUtils.import("resource://gre/modules/Services.jsm"); 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/ContentTask.jsm");
ChromeUtils.import("resource://testing-common/TestUtils.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 SJS = "mochi.test:8888/chrome/toolkit/components/url-classifier/tests/mochitest/report.sjs";
const BASE_URL = "http://" + 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://testing-common/BrowserTestUtils.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.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"]. var listmanager = Cc["@mozilla.org/url-classifier/listmanager;1"].
getService(Ci.nsIUrlListManager); getService(Ci.nsIUrlListManager);
@ -192,7 +192,7 @@ function testOnWindow(aTestData) {
let expected; let expected;
let browser = win.gBrowser.selectedBrowser; 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 = { let progressListener = {
onSecurityChange(aWebProgress, aRequest, aState) { onSecurityChange(aWebProgress, aRequest, aState) {
expected = aTestData.reportUrl; expected = aTestData.reportUrl;

View file

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

View file

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

View file

@ -16,7 +16,7 @@
<script class="testbody" type="text/javascript"> <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 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"; 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. * Obtain the main DOMWindow for the current context.
*/ */
function getMainWindow() { 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, saveImageURL(url, "image.jpg", null, true, false, null, null, null, null,
false, gBrowser.contentPrincipal); false, gBrowser.contentPrincipal);
let channel = gBrowser.contentDocumentAsCPOW.docShell.currentDocumentChannel; let channel = gBrowser.contentWindowAsCPOW.docShell.currentDocumentChannel;
if (channel) { if (channel) {
ok(true, channel.QueryInterface(Ci.nsIHttpChannelInternal) ok(true, channel.QueryInterface(Ci.nsIHttpChannelInternal)
.channelIsForDownload); .channelIsForDownload);
@ -74,7 +74,7 @@ add_task(async function deprecated_API() {
// pass the XUL document instead to test this interface. // pass the XUL document instead to test this interface.
let doc = document; let doc = document;
let channel = gBrowser.contentDocumentAsCPOW.docShell.currentDocumentChannel; let channel = gBrowser.contentWindowAsCPOW.docShell.currentDocumentChannel;
if (channel) { if (channel) {
ok(true, channel.QueryInterface(Ci.nsIHttpChannelInternal) ok(true, channel.QueryInterface(Ci.nsIHttpChannelInternal)
.channelIsForDownload); .channelIsForDownload);

View file

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

View file

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

View file

@ -29,7 +29,7 @@ function finish() {
SimpleTest.finish(); SimpleTest.finish();
} }
var mainWindow = window.document.docShell.rootTreeItem.domWindow; var mainWindow = window.docShell.rootTreeItem.domWindow;
var offscreenWindow = mainWindow.openDialog("window_bug593307_offscreen.xul", "", var offscreenWindow = mainWindow.openDialog("window_bug593307_offscreen.xul", "",
"dialog=no,chrome,width=200,height=200,screenX=-3000,screenY=-3000", "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 wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser"); var win = wm.getMostRecentWindow("navigator:browser");
var docShell = getBaseWindowInterfaceFromDocShell(win); let docShell = getBaseWindowInterfaceFromDocShell(win);
ok( ok(
shouldThrowException(function(){docShell.nativeHandle;}, shouldThrowException(function(){docShell.nativeHandle;},

View file

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