diff --git a/accessible/tests/mochitest/common.js b/accessible/tests/mochitest/common.js index 9006d92396f8..35ad4fa3fd18 100644 --- a/accessible/tests/mochitest/common.js +++ b/accessible/tests/mochitest/common.js @@ -712,9 +712,7 @@ function relationTypeToString(aRelationType) { } function getLoadContext() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return window.docShell.QueryInterface(Ci.nsILoadContext); } /** diff --git a/accessible/tests/mochitest/layout.js b/accessible/tests/mochitest/layout.js index bf164259cdd9..c28b5939814b 100644 --- a/accessible/tests/mochitest/layout.js +++ b/accessible/tests/mochitest/layout.js @@ -59,10 +59,7 @@ function testOffsetAtPoint(aHyperTextID, aX, aY, aCoordType, aExpectedOffset) { * Zoom the given document. */ function zoomDocument(aDocument, aZoom) { - var docShell = aDocument.defaultView. - QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIWebNavigation). - QueryInterface(Ci.nsIDocShell); + var docShell = aDocument.defaultView.docShell; var docViewer = docShell.contentViewer; docViewer.fullZoom = aZoom; diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 64e3f25a5b72..fa0e1484aa94 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -237,8 +237,7 @@ var gLastValidURLStr = ""; var gInPrintPreviewMode = false; var gContextMenu = null; // nsContextMenu instance var gMultiProcessBrowser = - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + window.docShell .QueryInterface(Ci.nsILoadContext) .useRemoteTabs; @@ -1238,9 +1237,7 @@ var gBrowserInit = { delete window._gBrowser; gBrowser.init(); - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner + window.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIXULWindow) .XULBrowserWindow = window.XULBrowserWindow; @@ -1323,9 +1320,7 @@ var gBrowserInit = { let mm = window.getGroupMessageManager("browsers"); mm.loadFrameScript("chrome://browser/content/tab-content.js", true); mm.loadFrameScript("chrome://browser/content/content.js", true); - mm.loadFrameScript("chrome://browser/content/content-UITour.js", true); mm.loadFrameScript("chrome://global/content/content-HybridContentTelemetry.js", true); - mm.loadFrameScript("chrome://global/content/manifestMessages.js", true); window.messageManager.addMessageListener("Browser:LoadURI", RedirectLoad); @@ -1936,9 +1931,7 @@ var gBrowserInit = { // Final window teardown, do this last. gBrowser.destroy(); window.XULBrowserWindow = null; - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner + window.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIXULWindow) .XULBrowserWindow = null; @@ -2481,9 +2474,7 @@ function getPostDataStream(aPostDataString, } function getLoadContext() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return window.docShell.QueryInterface(Ci.nsILoadContext); } function readFromClipboard() { @@ -2553,9 +2544,7 @@ async function BrowserViewSourceOfDocument(aArgsOrDocument) { } let win = doc.defaultView; - let browser = win.getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .chromeEventHandler; + let browser = win.docShell.chromeEventHandler; let outerWindowID = win.windowUtils.outerWindowID; let URL = browser.currentURI.spec; args = { browser, outerWindowID, URL }; diff --git a/browser/base/content/content-refreshblocker.js b/browser/base/content/content-refreshblocker.js index a1f2cdd63985..aacfbc0a10c6 100644 --- a/browser/base/content/content-refreshblocker.js +++ b/browser/base/content/content-refreshblocker.js @@ -160,9 +160,7 @@ var RefreshBlocker = { if (message.name == "RefreshBlocker:Refresh") { let win = Services.wm.getOuterWindowWithId(data.outerWindowID); - let refreshURI = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIRefreshURI); + let refreshURI = win.docShell.QueryInterface(Ci.nsIRefreshURI); let URI = Services.io.newURI(data.URI); diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index d925754f23c2..c23912968ed0 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -230,11 +230,7 @@ nsContextMenu.prototype = { this.browser = gContextMenuContentData.browser; this.selectionInfo = gContextMenuContentData.selectionInfo; } else { - this.browser = this.ownerDoc.defaultView - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .chromeEventHandler; + this.browser = this.ownerDoc.defaultView.docShell.chromeEventHandler; this.selectionInfo = BrowserUtils.getSelectionDetails(window); } @@ -260,8 +256,7 @@ nsContextMenu.prototype = { InlineSpellCheckerUI.initFromRemote(gContextMenuContentData.spellInfo); } else { var targetWin = this.ownerDoc.defaultView; - var editingSession = targetWin.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + var editingSession = targetWin.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIEditingSession); diff --git a/browser/base/content/pageinfo/pageInfo.js b/browser/base/content/pageinfo/pageInfo.js index 0d1a8dfa7dbd..0d340cda62a8 100644 --- a/browser/base/content/pageinfo/pageInfo.js +++ b/browser/base/content/pageinfo/pageInfo.js @@ -238,9 +238,7 @@ const nsICacheStorage = Ci.nsICacheStorage; const cacheService = Cc["@mozilla.org/netwerk/cache-storage-service;1"].getService(nsICacheStorageService); var loadContextInfo = Services.loadContextInfo.fromLoadContext( - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext), false); + window.docShell.QueryInterface(Ci.nsILoadContext), false); var diskStorage = cacheService.diskCacheStorage(loadContextInfo, false); const nsICookiePermission = Ci.nsICookiePermission; diff --git a/browser/base/content/tab-content.js b/browser/base/content/tab-content.js index 694bfdc3024a..bd32bc7bb684 100644 --- a/browser/base/content/tab-content.js +++ b/browser/base/content/tab-content.js @@ -90,6 +90,12 @@ addMessageListener("MixedContent:ReenableProtection", function() { XPCOMUtils.defineLazyProxy(this, "LightweightThemeChildHelper", "resource:///modules/LightweightThemeChildHelper.jsm"); +XPCOMUtils.defineLazyProxy(this, "ManifestMessages", () => { + let tmp = {}; + ChromeUtils.import("resource://gre/modules/ManifestMessages.jsm", tmp); + return new tmp.ManifestMessages(global); +}); + let themeablePagesWhitelist = new Set([ "about:home", "about:newtab", @@ -517,3 +523,8 @@ addEventListener("MozAfterPaint", function onFirstNonBlankPaint() { removeEventListener("MozAfterPaint", onFirstNonBlankPaint); sendAsyncMessage("Browser:FirstNonBlankPaint"); }); + +addMessageListener("DOM:WebManifest:hasManifestLink", ManifestMessages); +addMessageListener("DOM:ManifestObtainer:Obtain", ManifestMessages); +addMessageListener("DOM:Manifest:FireAppInstalledEvent", ManifestMessages); +addMessageListener("DOM:WebManifest:fetchIcon", ManifestMessages); diff --git a/browser/base/content/tabbrowser.js b/browser/base/content/tabbrowser.js index 4beb180f6871..dd11ab1d19b6 100644 --- a/browser/base/content/tabbrowser.js +++ b/browser/base/content/tabbrowser.js @@ -660,10 +660,7 @@ window._gBrowser = { // directly from the content window to the browser without looping // over all browsers. if (!gMultiProcessBrowser) { - let browser = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .chromeEventHandler; + let browser = aWindow.docShell.chromeEventHandler; return this.getTabForBrowser(browser); } @@ -3070,11 +3067,7 @@ window._gBrowser = { win.windowUtils.suppressAnimation(true); // Only suppressing window animations isn't enough to avoid // an empty content area being painted. - let baseWin = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIDocShellTreeItem) - .treeOwner - .QueryInterface(Ci.nsIBaseWindow); + let baseWin = win.docShell.treeOwner.QueryInterface(Ci.nsIBaseWindow); baseWin.visibility = false; } diff --git a/browser/base/content/test/general/browser_bug1297539.js b/browser/base/content/test/general/browser_bug1297539.js index 0c503743c3f0..c570803c450b 100644 --- a/browser/base/content/test/general/browser_bug1297539.js +++ b/browser/base/content/test/general/browser_bug1297539.js @@ -18,9 +18,7 @@ "use strict"; function getLoadContext() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return window.docShell.QueryInterface(Ci.nsILoadContext); } function getTransferableFromClipboard(asHTML) { diff --git a/browser/base/content/test/performance/browser_startup_content.js b/browser/base/content/test/performance/browser_startup_content.js index a5b2bed65aaf..ff8cbfc2a25d 100644 --- a/browser/base/content/test/performance/browser_startup_content.js +++ b/browser/base/content/test/performance/browser_startup_content.js @@ -23,18 +23,12 @@ const whitelist = { "extension-process-script.js", ]), modules: new Set([ - // From the test harness "chrome://mochikit/content/ShutdownLeaksCollector.jsm", - "resource://specialpowers/MockColorPicker.jsm", - "resource://specialpowers/MockFilePicker.jsm", - "resource://specialpowers/MockPermissionPrompt.jsm", // General utilities "resource://gre/modules/AppConstants.jsm", "resource://gre/modules/AsyncShutdown.jsm", "resource://gre/modules/DeferredTask.jsm", - "resource://gre/modules/FileUtils.jsm", - "resource://gre/modules/NetUtil.jsm", "resource://gre/modules/PromiseUtils.jsm", "resource://gre/modules/Services.jsm", // bug 1464542 "resource://gre/modules/Timer.jsm", @@ -76,9 +70,6 @@ const whitelist = { "resource://gre/modules/ExtensionUtils.jsm", "resource://gre/modules/MessageChannel.jsm", - // Service workers - "resource://gre/modules/ServiceWorkerCleanUp.jsm", - // Shield "resource://normandy-content/AboutPages.jsm", ]), diff --git a/browser/base/content/test/performance/head.js b/browser/base/content/test/performance/head.js index 9c7ee26011bf..2009c8e863e4 100644 --- a/browser/base/content/test/performance/head.js +++ b/browser/base/content/test/performance/head.js @@ -57,9 +57,7 @@ async function recordReflows(testPromise, win = window) { Ci.nsISupportsWeakReference]) }; - let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docShell = win.docShell; docShell.addWeakReflowObserver(observer); let dirtyFrameFn = event => { diff --git a/browser/base/content/test/siteIdentity/test_no_mcb_on_http_site_font.html b/browser/base/content/test/siteIdentity/test_no_mcb_on_http_site_font.html index de8040465293..29f78734f571 100644 --- a/browser/base/content/test/siteIdentity/test_no_mcb_on_http_site_font.html +++ b/browser/base/content/test/siteIdentity/test_no_mcb_on_http_site_font.html @@ -12,11 +12,7 @@ diff --git a/docshell/test/chrome/test_viewsource_forbidden_in_iframe.xul b/docshell/test/chrome/test_viewsource_forbidden_in_iframe.xul index f9d8a16c5ee0..fd5c2a7b0408 100644 --- a/docshell/test/chrome/test_viewsource_forbidden_in_iframe.xul +++ b/docshell/test/chrome/test_viewsource_forbidden_in_iframe.xul @@ -63,8 +63,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=624883 Ci.nsISupportsWeakReference]) }; - frame.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + frame.contentWindow.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebProgress) .addProgressListener(progressListener, diff --git a/docshell/test/navigation/NavigationUtils.js b/docshell/test/navigation/NavigationUtils.js index a73f7e4999ba..4822ff0e6ade 100644 --- a/docshell/test/navigation/NavigationUtils.js +++ b/docshell/test/navigation/NavigationUtils.js @@ -109,9 +109,7 @@ function xpcEnumerateContentWindows(callback) { while (enumerator.hasMoreElements()) { var win = enumerator.getNext(); if (win.isChromeWindow) { - var docshellTreeNode = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem); + var docshellTreeNode = win.docShell; var childCount = docshellTreeNode.childCount; for (var i = 0; i < childCount; ++i) { var childTreeNode = docshellTreeNode.getChildAt(i); diff --git a/docshell/test/navigation/browser_bug343515.js b/docshell/test/navigation/browser_bug343515.js index c6e07b4bf6cc..2bbeafac07fe 100644 --- a/docshell/test/navigation/browser_bug343515.js +++ b/docshell/test/navigation/browser_bug343515.js @@ -95,9 +95,7 @@ function step3() { Assert.equal(content.frames.length, 2, "Tab 2 should have 2 iframes"); for (var i = 0; i < content.frames.length; i++) { info("step 3, frame " + i + " info: " + content.frames[i].location); - let docshell = content.frames[i].QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docshell = content.frames[i].docShell; Assert.ok(!docShell.isActive, `Tab2 iframe ${i} should be inactive`); } @@ -115,9 +113,7 @@ function step4() { function checkTab2Active(expected) { return ContentTask.spawn(ctx.tab2Browser, expected, async function(expected) { function isActive(aWindow) { - var docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + var docshell = aWindow.docShell; return docshell.isActive; } @@ -165,9 +161,7 @@ function step5() { ok(ctx.tab2Browser.docShellIsActive, "Tab 2 should be active"); ContentTask.spawn(ctx.tab2Browser, null, async function() { for (var i = 0; i < content.frames.length; i++) { - let docshell = content.frames[i].QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docshell = content.frames[i].docShell; Assert.ok(docShell.isActive, `Tab2 iframe ${i} should be active`); } @@ -191,9 +185,7 @@ function step6() { ok(ctx.tab1Browser.docShellIsActive, "Tab 1 should be active"); ContentTask.spawn(ctx.tab1Browser, null, async function() { function isActive(aWindow) { - var docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + var docshell = aWindow.docShell; return docshell.isActive; } @@ -204,9 +196,7 @@ function step6() { ok(!ctx.tab2Browser.docShellIsActive, "Tab 2 should be inactive"); return ContentTask.spawn(ctx.tab2Browser, null, async function() { for (var i = 0; i < content.frames.length; i++) { - let docshell = content.frames[i].QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docshell = content.frames[i].docShell; Assert.ok(!docShell.isActive, `Tab2 iframe ${i} should be inactive`); } @@ -223,9 +213,7 @@ function step7() { return ContentTask.spawn(browser, { tabNum, active }, async function({ tabNum, active }) { function isActive(aWindow) { - var docshell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + var docshell = aWindow.docShell; return docshell.isActive; } diff --git a/docshell/test/navigation/browser_test-content-chromeflags.js b/docshell/test/navigation/browser_test-content-chromeflags.js index 6409c3e136dc..17c8e2473df2 100644 --- a/docshell/test/navigation/browser_test-content-chromeflags.js +++ b/docshell/test/navigation/browser_test-content-chromeflags.js @@ -25,9 +25,7 @@ add_task(async function() { BrowserTestUtils.synthesizeMouse("a", 0, 0, {}, browser); let win = await openedPromise; - let chromeFlags = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) + let chromeFlags = win.docShell .treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIXULWindow) diff --git a/docshell/test/navigation/file_bug1300461.html b/docshell/test/navigation/file_bug1300461.html index 790a90d54ed6..bb7e827d98e2 100644 --- a/docshell/test/navigation/file_bug1300461.html +++ b/docshell/test/navigation/file_bug1300461.html @@ -25,8 +25,8 @@ */ let Ci = SpecialPowers.Ci; let webNav = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation); + .docShell + .QueryInterface(Ci.nsIWebNavigation); let shistory = webNav.sessionHistory; let testSteps = [ function() { diff --git a/docshell/test/navigation/file_bug1300461_back.html b/docshell/test/navigation/file_bug1300461_back.html index 84ab034aba16..7f2488e27a81 100644 --- a/docshell/test/navigation/file_bug1300461_back.html +++ b/docshell/test/navigation/file_bug1300461_back.html @@ -9,8 +9,8 @@ diff --git a/docshell/test/test_bug509055.html b/docshell/test/test_bug509055.html index d8b78196f38e..4517c283b4ce 100644 --- a/docshell/test/test_bug509055.html +++ b/docshell/test/test_bug509055.html @@ -71,8 +71,8 @@ function* runTest() { yield undefined; var sh = SpecialPowers.wrap(popup) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) + .docShell + .QueryInterface(SpecialPowers.Ci.nsIWebNavigation) .sessionHistory; // Get the title of the inner popup's current SHEntry diff --git a/docshell/test/test_bug590573.html b/docshell/test/test_bug590573.html index c010cef842a3..ee93fc28c6e1 100644 --- a/docshell/test/test_bug590573.html +++ b/docshell/test/test_bug590573.html @@ -96,8 +96,8 @@ function page2PageShow() function dumpSHistory(theWindow) { - let sh = SpecialPowers.wrap(theWindow).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) + let sh = SpecialPowers.wrap(theWindow).docShell + .QueryInterface(SpecialPowers.Ci.nsIWebNavigation) .sessionHistory; if (!sh) { dump(" window has no shistory.\n"); diff --git a/dom/animation/test/mozilla/file_restyles.html b/dom/animation/test/mozilla/file_restyles.html index 46e401370a9e..635fe65e2a5d 100644 --- a/dom/animation/test/mozilla/file_restyles.html +++ b/dom/animation/test/mozilla/file_restyles.html @@ -60,11 +60,7 @@ body { 'use strict'; function getDocShellForObservingRestylesForWindow(aWindow) { - const docShell = - SpecialPowers.wrap(aWindow) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell); + const docShell = SpecialPowers.wrap(aWindow).docShell; docShell.recordProfileTimelineMarkers = true; docShell.popProfileTimelineMarkers(); diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 16b7e67b429b..58e2a46c8ee9 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -4226,131 +4226,6 @@ nsGlobalWindowInner::GetFrameElement() return GetRealFrameElement(IgnoreErrors()); } -/* static */ bool -nsGlobalWindowInner::TokenizeDialogOptions(nsAString& aToken, - nsAString::const_iterator& aIter, - nsAString::const_iterator aEnd) -{ - while (aIter != aEnd && nsCRT::IsAsciiSpace(*aIter)) { - ++aIter; - } - - if (aIter == aEnd) { - return false; - } - - if (*aIter == ';' || *aIter == ':' || *aIter == '=') { - aToken.Assign(*aIter); - ++aIter; - return true; - } - - nsAString::const_iterator start = aIter; - - // Skip characters until we find whitespace, ';', ':', or '=' - while (aIter != aEnd && !nsCRT::IsAsciiSpace(*aIter) && - *aIter != ';' && - *aIter != ':' && - *aIter != '=') { - ++aIter; - } - - aToken.Assign(Substring(start, aIter)); - return true; -} - -// Helper for converting window.showModalDialog() options (list of ';' -// separated name (:|=) value pairs) to a format that's parsable by -// our normal window opening code. - -/* static */ -void -nsGlobalWindowInner::ConvertDialogOptions(const nsAString& aOptions, - nsAString& aResult) -{ - nsAString::const_iterator end; - aOptions.EndReading(end); - - nsAString::const_iterator iter; - aOptions.BeginReading(iter); - - nsAutoString token; - nsAutoString name; - nsAutoString value; - - while (true) { - if (!TokenizeDialogOptions(name, iter, end)) { - break; - } - - // Invalid name. - if (name.EqualsLiteral("=") || - name.EqualsLiteral(":") || - name.EqualsLiteral(";")) { - break; - } - - if (!TokenizeDialogOptions(token, iter, end)) { - break; - } - - if (!token.EqualsLiteral(":") && !token.EqualsLiteral("=")) { - continue; - } - - // We found name followed by ':' or '='. Look for a value. - if (!TokenizeDialogOptions(value, iter, end)) { - break; - } - - if (name.LowerCaseEqualsLiteral("center")) { - if (value.LowerCaseEqualsLiteral("on") || - value.LowerCaseEqualsLiteral("yes") || - value.LowerCaseEqualsLiteral("1")) { - aResult.AppendLiteral(",centerscreen=1"); - } - } else if (name.LowerCaseEqualsLiteral("dialogwidth")) { - if (!value.IsEmpty()) { - aResult.AppendLiteral(",width="); - aResult.Append(value); - } - } else if (name.LowerCaseEqualsLiteral("dialogheight")) { - if (!value.IsEmpty()) { - aResult.AppendLiteral(",height="); - aResult.Append(value); - } - } else if (name.LowerCaseEqualsLiteral("dialogtop")) { - if (!value.IsEmpty()) { - aResult.AppendLiteral(",top="); - aResult.Append(value); - } - } else if (name.LowerCaseEqualsLiteral("dialogleft")) { - if (!value.IsEmpty()) { - aResult.AppendLiteral(",left="); - aResult.Append(value); - } - } else if (name.LowerCaseEqualsLiteral("resizable")) { - if (value.LowerCaseEqualsLiteral("on") || - value.LowerCaseEqualsLiteral("yes") || - value.LowerCaseEqualsLiteral("1")) { - aResult.AppendLiteral(",resizable=1"); - } - } else if (name.LowerCaseEqualsLiteral("scroll")) { - if (value.LowerCaseEqualsLiteral("off") || - value.LowerCaseEqualsLiteral("no") || - value.LowerCaseEqualsLiteral("0")) { - aResult.AppendLiteral(",scrollbars=0"); - } - } - - if (iter == end || - !TokenizeDialogOptions(token, iter, end) || - !token.EqualsLiteral(";")) { - break; - } - } -} - void nsGlobalWindowInner::UpdateCommands(const nsAString& anAction, Selection* aSel, diff --git a/dom/base/nsGlobalWindowInner.h b/dom/base/nsGlobalWindowInner.h index 4f7f4df0f570..a6f9e6af9cbe 100644 --- a/dom/base/nsGlobalWindowInner.h +++ b/dom/base/nsGlobalWindowInner.h @@ -699,13 +699,6 @@ public: mozilla::ErrorResult& aRv); already_AddRefed GetExternal(mozilla::ErrorResult& aRv); - // Exposed only for testing - static bool - TokenizeDialogOptions(nsAString& aToken, nsAString::const_iterator& aIter, - nsAString::const_iterator aEnd); - static void - ConvertDialogOptions(const nsAString& aOptions, nsAString& aResult); - mozilla::dom::Worklet* GetPaintWorklet(mozilla::ErrorResult& aRv); diff --git a/dom/base/nsIMessageManager.idl b/dom/base/nsIMessageManager.idl index dd880c70d467..3ef062dd1ecd 100644 --- a/dom/base/nsIMessageManager.idl +++ b/dom/base/nsIMessageManager.idl @@ -7,14 +7,14 @@ interface nsIContent; -[shim(MessageSender), shimfile(MessageManager), - uuid(bb5d79e4-e73c-45e7-9651-4d718f4b994c)] +// NOTE: Only scriptable for Ci.nsIMessageSender +[scriptable, builtinclass, uuid(bb5d79e4-e73c-45e7-9651-4d718f4b994c)] interface nsIMessageSender : nsISupports { }; -[shim(ContentFrameMessageManager), shimfile(MessageManager), - uuid(694e367c-aa25-4446-8499-2c527c4bd838)] +// NOTE: Only scriptable for Ci.nsIContentFrameMessageManager +[scriptable, builtinclass, uuid(694e367c-aa25-4446-8499-2c527c4bd838)] interface nsIContentFrameMessageManager : nsIMessageSender { }; diff --git a/dom/base/test/browser_promiseDocumentFlushed.js b/dom/base/test/browser_promiseDocumentFlushed.js index 8e356a6a8f9c..c0678437b32b 100644 --- a/dom/base/test/browser_promiseDocumentFlushed.js +++ b/dom/base/test/browser_promiseDocumentFlushed.js @@ -124,9 +124,7 @@ add_task(async function test_can_get_results_from_callback() { Ci.nsISupportsWeakReference]) }; - let docShell = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docShell = window.docShell; docShell.addWeakReflowObserver(observer); let toolboxRect = gNavToolbox.getBoundingClientRect(); @@ -157,8 +155,7 @@ add_task(async function test_resolved_in_window_close() { await win.promiseDocumentFlushed(() => {}); - let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell); + let docShell = win.docShell; docShell.contentViewer.pausePainting(); win.gNavToolbox.style.padding = "5px"; diff --git a/dom/base/test/chrome/file_bug1209621.xul b/dom/base/test/chrome/file_bug1209621.xul index 3242bfe554e7..066570f035a6 100644 --- a/dom/base/test/chrome/file_bug1209621.xul +++ b/dom/base/test/chrome/file_bug1209621.xul @@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1209621 } function run() { - var docshell = window.getInterface(Ci.nsIDocShell); + var docshell = window.docShell; ok(docshell, "Active window should have a DocShell"); var treeOwner = docshell.treeOwner; ok(treeOwner, "Active docshell should have a TreeOwner!"); diff --git a/dom/base/test/chrome/file_bug549682.xul b/dom/base/test/chrome/file_bug549682.xul index c67dc7bd794d..a0eee7c0185e 100644 --- a/dom/base/test/chrome/file_bug549682.xul +++ b/dom/base/test/chrome/file_bug549682.xul @@ -140,11 +140,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549682 function run() { var localmm = document.getElementById('ifr').messageManager; - var wn = document.getElementById('ifr').contentWindow - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor); - ok(wn, "Should have webnavigation"); - var cfmm = wn.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIContentFrameMessageManager); + var docShell = document.getElementById('ifr').contentWindow.docShell; + ok(docShell, "Should have docshell"); + var cfmm = docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIContentFrameMessageManager); ok(cfmm, "Should have content messageManager"); var didGetSyncMessage = false; diff --git a/dom/base/test/chrome/test_bug1339722.html b/dom/base/test/chrome/test_bug1339722.html index ec4d19961b77..e5aeecb6f707 100644 --- a/dom/base/test/chrome/test_bug1339722.html +++ b/dom/base/test/chrome/test_bug1339722.html @@ -34,9 +34,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1339722 } }, TOPIC); - let docShell = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell); + let docShell = SpecialPowers.wrap(window).docShell; docShell.chromeEventHandler.addEventListener('DOMWindowCreated', function handler(e) { docShell.chromeEventHandler.removeEventListener('DOMWindowCreated', handler); let iframe = document.getElementById('testFrame'); diff --git a/dom/base/test/copypaste.js b/dom/base/test/copypaste.js index f3b7593bbb4f..585c5e447fcc 100644 --- a/dom/base/test/copypaste.js +++ b/dom/base/test/copypaste.js @@ -24,8 +24,7 @@ function modifySelection(s) { function getLoadContext() { var Ci = SpecialPowers.Ci; - return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + return SpecialPowers.wrap(window).docShell .QueryInterface(Ci.nsILoadContext); } @@ -33,10 +32,7 @@ async function testCopyPaste (isXHTML) { var suppressUnicodeCheckIfHidden = !!isXHTML; var suppressHTMLCheck = !!isXHTML; - var webnav = SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - - var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell); + var docShell = SpecialPowers.wrap(window).docShell; var documentViewer = docShell.contentViewer .QueryInterface(SpecialPowers.Ci.nsIContentViewerEdit); diff --git a/dom/base/test/gtest/TestParserDialogOptions.cpp b/dom/base/test/gtest/TestParserDialogOptions.cpp deleted file mode 100644 index 79b0e8c9e8af..000000000000 --- a/dom/base/test/gtest/TestParserDialogOptions.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "gtest/gtest.h" -#include "nsGlobalWindow.h" - -// XXX(nika): I can't find any non-test callers of this code, can we remove it? - -struct dialog_test { - const char* input; - const char* output; -}; - -void runTokenizeTest(dialog_test& test) -{ - NS_ConvertUTF8toUTF16 input(test.input); - - nsAString::const_iterator end; - input.EndReading(end); - - nsAString::const_iterator iter; - input.BeginReading(iter); - - nsAutoString result; - nsAutoString token; - - while (nsGlobalWindowInner::TokenizeDialogOptions(token, iter, end)) { - if (!result.IsEmpty()) { - result.Append(','); - } - - result.Append(token); - } - - ASSERT_STREQ(test.output, NS_ConvertUTF16toUTF8(result).get()) << "Testing " << test.input; -} - -void runTest(dialog_test& test) -{ - NS_ConvertUTF8toUTF16 input(test.input); - - nsAutoString result; - nsGlobalWindowInner::ConvertDialogOptions(input, result); - - ASSERT_STREQ(test.output, NS_ConvertUTF16toUTF8(result).get()) << "Testing " << test.input; -} - -TEST(GlobalWindowDialogOptions, TestDialogTokenize) -{ - dialog_test tests[] = { - /// Empty strings - { "", "" }, - { " ", "" }, - { " ", "" }, - - // 1 token - { "a", "a" }, - { " a", "a" }, - { " a ", "a" }, - { "aa", "aa" }, - { " aa", "aa" }, - { " aa ", "aa" }, - { ";", ";" }, - { ":", ":" }, - { "=", "=" }, - - // 2 tokens - { "a=", "a,=" }, - { " a= ", "a,=" }, - { " a = ", "a,=" }, - { "aa=", "aa,=" }, - { " aa= ", "aa,=" }, - { " aa = ", "aa,=" }, - { ";= ", ";,=" }, - { "==", "=,=" }, - { "::", ":,:" }, - - // 3 tokens - { "a=2", "a,=,2" }, - { "===", "=,=,=" }, - { ";:=", ";,:,=" }, - - // more - { "aaa;bbb:ccc", "aaa,;,bbb,:,ccc" }, - - // sentinel - { nullptr, nullptr } - }; - - for (uint32_t i = 0; tests[i].input; ++i) { - runTokenizeTest(tests[i]); - } -} -TEST(GlobalWindowDialogOptions, TestDialogOptions) -{ - dialog_test tests[] = { - /// Empty strings - { "", "" }, - { " ", "" }, - { " ", "" }, - - // Name without params - { "a", "" }, - { " a", "" }, - { " a ", "" }, - { "a=", "" }, - { " a= ", "" }, - { " a = ", "" }, - - // 1 unknown value - { "a=2", "" }, - { " a=2 ", "" }, - { " a = 2 ", "" }, - { "a:2", "" }, - { " a:2 ", "" }, - { " a : 2 ", "" }, - - // 1 known value, wrong value - { "center=2", "" }, - { "center:2", "" }, - - // 1 known value, good value - { "center=on", ",centerscreen=1" }, - { "center:on", ",centerscreen=1" }, - { " center : on ", ",centerscreen=1" }, - - // nonsense stuff - { " ; ", "" }, - - // sentinel - { nullptr, nullptr } - }; - - for (uint32_t i = 0; tests[i].input; ++i) { - runTest(tests[i]); - } -} diff --git a/dom/base/test/gtest/moz.build b/dom/base/test/gtest/moz.build index 7031239d32a8..87c7193ccc7f 100644 --- a/dom/base/test/gtest/moz.build +++ b/dom/base/test/gtest/moz.build @@ -5,7 +5,6 @@ # file, you can obtain one at http://mozilla.org/MPL/2.0/. UNIFIED_SOURCES += [ - 'TestParserDialogOptions.cpp', 'TestPlainTextSerializer.cpp', 'TestXPathGenerator.cpp', ] diff --git a/dom/base/test/test_bug1101364.html b/dom/base/test/test_bug1101364.html index 665b9f9a8624..3a75dc3d3ec9 100644 --- a/dom/base/test/test_bug1101364.html +++ b/dom/base/test/test_bug1101364.html @@ -30,10 +30,7 @@ function test() { var iframe1 = document.getElementById('test1'); iframe1.focus(); - var Ci = SpecialPowers.Ci; - var webnav = SpecialPowers.wrap(iframe1.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - var docShell = webnav.QueryInterface(Ci.nsIDocShell); + var docShell = SpecialPowers.wrap(iframe1.contentWindow).docShell; // test1 docShell.doCommand("cmd_selectAll"); @@ -50,9 +47,7 @@ function test() // test2 var iframe2 = document.getElementById('test2'); iframe2.focus(); - var webnav = SpecialPowers.wrap(iframe2.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - var docShell = webnav.QueryInterface(Ci.nsIDocShell); + var docShell = SpecialPowers.wrap(iframe2.contentWindow).docShell; var test2Inner = iframe2.contentDocument.getElementById('test2Inner'); test2Inner.style.MozUserSelect = 'text'; docShell.doCommand("cmd_selectAll"); diff --git a/dom/base/test/test_bug166235.html b/dom/base/test/test_bug166235.html index 90bafd196a0b..9211edf059d2 100644 --- a/dom/base/test/test_bug166235.html +++ b/dom/base/test/test_bug166235.html @@ -29,10 +29,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=816298 var Cc = SpecialPowers.Cc; var Ci = SpecialPowers.Ci; - var webnav = SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - - var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell); + var docShell = SpecialPowers.wrap(window).docShell; var documentViewer = docShell.contentViewer .QueryInterface(SpecialPowers.Ci.nsIContentViewerEdit); @@ -43,8 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=816298 var textarea = SpecialPowers.wrap(document.getElementById('input')); function getLoadContext() { - return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + return SpecialPowers.wrap(window).docShell .QueryInterface(Ci.nsILoadContext); } diff --git a/dom/base/test/test_copyimage.html b/dom/base/test/test_copyimage.html index 7d0a611c596d..8e05b3f5c5d3 100644 --- a/dom/base/test/test_copyimage.html +++ b/dom/base/test/test_copyimage.html @@ -26,8 +26,7 @@ function testCopyImage () { function getClipboardData(mime) { var transferable = Cc['@mozilla.org/widget/transferable;1'] .createInstance(Ci.nsITransferable); - var loadingContext = SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + var loadingContext = SpecialPowers.wrap(window).docShell .QueryInterface(Ci.nsILoadContext); transferable.init(loadingContext); transferable.addDataFlavor(mime); @@ -50,10 +49,7 @@ function testCopyImage () { var node = document.getElementById('logo'); // Set node and copy image. - var webnav = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - var docShell = webnav.QueryInterface(Ci.nsIDocShell); + var docShell = SpecialPowers.wrap(window).docShell; var documentViewer = docShell.contentViewer .QueryInterface(Ci.nsIContentViewerEdit); documentViewer.setCommandNode(node); diff --git a/dom/base/test/test_copypaste.xul b/dom/base/test/test_copypaste.xul index a7aeccaad728..a5f0fcae504d 100644 --- a/dom/base/test/test_copypaste.xul +++ b/dom/base/test/test_copypaste.xul @@ -19,9 +19,7 @@ function runTest() { let expected = "\n hello\n world\n "; SimpleTest.waitForClipboard(expected, function() { - let webnav = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation); - webnav.QueryInterface(Ci.nsIDocShell) + window.docShell .contentViewer .QueryInterface(Ci.nsIContentViewerEdit) .copySelection(); diff --git a/dom/base/test/test_postMessage_originAttributes.html b/dom/base/test/test_postMessage_originAttributes.html index 9a03a2f8a21e..20facafab7f5 100644 --- a/dom/base/test/test_postMessage_originAttributes.html +++ b/dom/base/test/test_postMessage_originAttributes.html @@ -20,8 +20,7 @@ add_task(async function() { let iframe = document.querySelector("#target-iframe"); let win = SpecialPowers.wrap(iframe).contentWindow; - let docShell = win.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIDocShell); + let docShell = win.docShell; // Add private browsing ID to docShell origin and load document. docShell.setOriginAttributes({privateBrowsingId: 1}); diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js index 01706b29e323..47e028c99112 100644 --- a/dom/browser-element/BrowserElementChildPreload.js +++ b/dom/browser-element/BrowserElementChildPreload.js @@ -742,9 +742,7 @@ BrowserElementChild.prototype = { }, _windowCreatedHandler: function(e) { - let targetDocShell = e.target.defaultView - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation); + let targetDocShell = e.target.defaultView.docShell; if (targetDocShell != docShell) { return; } diff --git a/dom/browser-element/BrowserElementCopyPaste.js b/dom/browser-element/BrowserElementCopyPaste.js index 72722c1dd103..bf81d0276fc0 100644 --- a/dom/browser-element/BrowserElementCopyPaste.js +++ b/dom/browser-element/BrowserElementCopyPaste.js @@ -108,9 +108,7 @@ var CopyPasteAssistent = { detail.rect.right += currentRect.left; currentWindow = currentWindow.realFrameElement.ownerGlobal; - let targetDocShell = currentWindow - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation); + let targetDocShell = currentWindow.docShell; if(targetDocShell.isMozBrowser) { break; } diff --git a/dom/events/test/test_bug1412775.xul b/dom/events/test/test_bug1412775.xul index 006b264515e2..d91e8fc24f0a 100644 --- a/dom/events/test/test_bug1412775.xul +++ b/dom/events/test/test_bug1412775.xul @@ -30,8 +30,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1412775 b.addEventListener("foo", function(e) { didCallChromeSide = true; var path = e.composedPath(); - var mm = d.defaultView.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + var mm = d.defaultView.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIContentFrameMessageManager); is(path.length, 5, "Should have 5 items in composedPath in chrome."); diff --git a/dom/events/test/test_paste_image.html b/dom/events/test/test_paste_image.html index 716fafeaf05b..2d2de9877371 100644 --- a/dom/events/test/test_paste_image.html +++ b/dom/events/test/test_paste_image.html @@ -71,11 +71,7 @@ function copyImage(aImageId) { // selection of the node var node = document.getElementById(aImageId); - var webnav = SpecialPowers.wrap(window) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - - var docShell = webnav.QueryInterface(SpecialPowers.Ci.nsIDocShell); + var docShell = SpecialPowers.wrap(window).docShell; // let's copy the node var documentViewer = docShell.contentViewer diff --git a/dom/html/test/browser_bug649778.js b/dom/html/test/browser_bug649778.js index 7a18f091f105..6c517f04d66e 100644 --- a/dom/html/test/browser_bug649778.js +++ b/dom/html/test/browser_bug649778.js @@ -39,8 +39,8 @@ function checkCache(url, inMemory, shouldExist, cb) new CheckCacheListener(inMemory, shouldExist)); } function getPopupURL() { - var sh = popup.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + var sh = popup.docShell + .QueryInterface(Ci.nsIWebNavigation) .sessionHistory; return sh.legacySHistory.getEntryAtIndex(sh.index, false).URI.spec; diff --git a/dom/html/test/test_bug460568.html b/dom/html/test/test_bug460568.html index 9bfef1e39d79..c7808a1a32e4 100644 --- a/dom/html/test/test_bug460568.html +++ b/dom/html/test/test_bug460568.html @@ -36,10 +36,7 @@ function runTest() range.selectNodeContents(editor); var prevStr = range.toString(); - var docShell = SpecialPowers.wrap(window) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell); + var docShell = SpecialPowers.wrap(window).docShell; var controller = docShell.QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) .getInterface(SpecialPowers.Ci.nsISelectionDisplay) diff --git a/dom/html/test/test_bug512367.html b/dom/html/test/test_bug512367.html index be10345a95e7..4f80d6a3331c 100644 --- a/dom/html/test/test_bug512367.html +++ b/dom/html/test/test_bug512367.html @@ -24,12 +24,7 @@ var frame = document.getElementById("i"); SimpleTest.waitForExplicitFinish(); addLoadEvent(function() { - var viewer = - SpecialPowers.wrap(frame.contentWindow) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell) - .contentViewer; + var viewer = SpecialPowers.wrap(frame.contentWindow).docShell.contentViewer; viewer.fullZoom = 1.5; diff --git a/dom/ipc/manifestMessages.js b/dom/ipc/ManifestMessages.jsm similarity index 61% rename from dom/ipc/manifestMessages.js rename to dom/ipc/ManifestMessages.jsm index 864a8bb4b5da..d559da16b27a 100644 --- a/dom/ipc/manifestMessages.js +++ b/dom/ipc/ManifestMessages.jsm @@ -11,54 +11,52 @@ * * BUG: https://bugzilla.mozilla.org/show_bug.cgi?id=1083410 */ -/*globals Task, ManifestObtainer, ManifestFinder, content, sendAsyncMessage, addMessageListener, Components*/ "use strict"; -const { - utils: Cu, -} = Components; + +var EXPORTED_SYMBOLS = ["ManifestMessages"]; + ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.defineModuleGetter(this, "ManifestObtainer", - "resource://gre/modules/ManifestObtainer.jsm"); + "resource://gre/modules/ManifestObtainer.jsm"); ChromeUtils.defineModuleGetter(this, "ManifestFinder", - "resource://gre/modules/ManifestFinder.jsm"); + "resource://gre/modules/ManifestFinder.jsm"); ChromeUtils.defineModuleGetter(this, "ManifestIcons", - "resource://gre/modules/ManifestIcons.jsm"); + "resource://gre/modules/ManifestIcons.jsm"); -const MessageHandler = { - registerListeners() { - addMessageListener( - "DOM:WebManifest:hasManifestLink", - this.hasManifestLink.bind(this) - ); - addMessageListener( - "DOM:ManifestObtainer:Obtain", - this.obtainManifest.bind(this) - ); - addMessageListener( - "DOM:Manifest:FireAppInstalledEvent", - this.fireAppInstalledEvent.bind(this) - ); - addMessageListener( - "DOM:WebManifest:fetchIcon", - this.fetchIcon.bind(this) - ); - }, +class ManifestMessages { + constructor(mm) { + this.mm = mm; + } + + receiveMessage(message) { + switch (message.name) { + case "DOM:WebManifest:hasManifestLink": + return this.hasManifestLink(message); + case "DOM:ManifestObtainer:Obtain": + return this.obtainManifest(message); + case "DOM:Manifest:FireAppInstalledEvent": + return this.fireAppInstalledEvent(message); + case "DOM:WebManifest:fetchIcon": + return this.fetchIcon(message); + } + return undefined; + } /** - * Check if the content document includes a link to a web manifest. + * Check if the this.mm.content document includes a link to a web manifest. * @param {Object} aMsg The IPC message, which is destructured to just * get the id. */ hasManifestLink({data: {id}}) { const response = makeMsgResponse(id); - response.result = ManifestFinder.contentHasManifestLink(content); + response.result = ManifestFinder.contentHasManifestLink(this.mm.content); response.success = true; - sendAsyncMessage("DOM:WebManifest:hasManifestLink", response); - }, + this.mm.sendAsyncMessage("DOM:WebManifest:hasManifestLink", response); + } /** - * Asynchronously obtains a web manifest from content by using the + * Asynchronously obtains a web manifest from this.mm.content by using the * ManifestObtainer and messages back the result. * @param {Object} aMsg The IPC message, which is destructured to just * get the id. @@ -66,26 +64,26 @@ const MessageHandler = { async obtainManifest({data: {id}}) { const response = makeMsgResponse(id); try { - response.result = await ManifestObtainer.contentObtainManifest(content); + response.result = await ManifestObtainer.contentObtainManifest(this.mm.content); response.success = true; } catch (err) { response.result = serializeError(err); } - sendAsyncMessage("DOM:ManifestObtainer:Obtain", response); - }, + this.mm.sendAsyncMessage("DOM:ManifestObtainer:Obtain", response); + } - fireAppInstalledEvent({data: {id}}){ + fireAppInstalledEvent({data: {id}}) { const ev = new Event("appinstalled"); const response = makeMsgResponse(id); - if (!content || content.top !== content) { + if (!this.mm.content || this.mm.content.top !== this.mm.content) { const msg = "Can only dispatch install event on top-level browsing contexts."; response.result = serializeError(new Error(msg)); } else { response.success = true; - content.dispatchEvent(ev); + this.mm.content.dispatchEvent(ev); } - sendAsyncMessage("DOM:Manifest:FireAppInstalledEvent", response); - }, + this.mm.sendAsyncMessage("DOM:Manifest:FireAppInstalledEvent", response); + } /** * Given a manifest and an expected icon size, ask ManifestIcons @@ -95,15 +93,15 @@ const MessageHandler = { const response = makeMsgResponse(id); try { response.result = - await ManifestIcons.contentFetchIcon(content, manifest, iconSize); + await ManifestIcons.contentFetchIcon(this.mm.content, manifest, iconSize); response.success = true; } catch (err) { response.result = serializeError(err); } - sendAsyncMessage("DOM:WebManifest:fetchIcon", response); - }, + this.mm.sendAsyncMessage("DOM:WebManifest:fetchIcon", response); + } +} -}; /** * Utility function to Serializes an JS Error, so it can be transferred over * the message channel. @@ -124,11 +122,9 @@ function serializeError(aError) { } function makeMsgResponse(aId) { - return { - id: aId, - success: false, - result: undefined - }; - } - -MessageHandler.registerListeners(); + return { + id: aId, + success: false, + result: undefined + }; +} diff --git a/dom/ipc/jar.mn b/dom/ipc/jar.mn index dd9f65427526..5c88deeebee5 100644 --- a/dom/ipc/jar.mn +++ b/dom/ipc/jar.mn @@ -8,4 +8,3 @@ toolkit.jar: content/global/BrowserElementChild.js (../browser-element/BrowserElementChild.js) content/global/BrowserElementChildPreload.js (../browser-element/BrowserElementChildPreload.js) content/global/BrowserElementCopyPaste.js (../browser-element/BrowserElementCopyPaste.js) - content/global/manifestMessages.js (manifestMessages.js) diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build index a1ed51fa7b40..0a1d817f6e8f 100644 --- a/dom/ipc/moz.build +++ b/dom/ipc/moz.build @@ -13,6 +13,10 @@ XPIDL_SOURCES += [ XPIDL_MODULE = 'dom' +EXTRA_JS_MODULES += [ + 'ManifestMessages.jsm', +] + EXPORTS.mozilla.dom.ipc += [ 'IdType.h', 'MemMapSnapshot.h', diff --git a/dom/ipc/remote-test.js b/dom/ipc/remote-test.js index 0ba2226f87b1..72b31b29e611 100644 --- a/dom/ipc/remote-test.js +++ b/dom/ipc/remote-test.js @@ -13,11 +13,7 @@ cpm.addMessageListener("cpm-async", cpm.sendAsyncMessage("ppm-async"); }); -var dshell = content.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) - .rootTreeItem - .QueryInterface(Ci.nsIDocShell); +var dshell = content.docShell.rootTreeItem.QueryInterface(Ci.nsIDocShell); addEventListener("click", diff --git a/dom/ipc/tests/test_child_docshell.html b/dom/ipc/tests/test_child_docshell.html index fd612cf22549..638a4a72aef9 100644 --- a/dom/ipc/tests/test_child_docshell.html +++ b/dom/ipc/tests/test_child_docshell.html @@ -66,9 +66,7 @@ SpecialPowers.pushPrefEnv({'set':[ } chromeEventHandler.removeEventListener("DOMWindowCreated", listener); let new_win = evt.target.defaultView; - let new_docShell = new_win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let new_docShell = new_win.docShell; sendAsyncMessage("DOMWindowCreatedReceived", { stableChromeEventHandler: chromeEventHandler === docShell.chromeEventHandler, iframeHasNewDocShell: new_docShell !== docShell, diff --git a/dom/serviceworkers/test/test_devtools_bypass_serviceworker.html b/dom/serviceworkers/test/test_devtools_bypass_serviceworker.html index 9ca794c5b884..2dc42dfa955d 100644 --- a/dom/serviceworkers/test/test_devtools_bypass_serviceworker.html +++ b/dom/serviceworkers/test/test_devtools_bypass_serviceworker.html @@ -15,6 +15,8 @@ "use strict"; async function testBypassSW () { + let Ci = SpecialPowers.Ci; + // Bypass SW imitates the "Disable Cache" option in dev-tools. // Note: if we put the setter/getter into dev-tools, we should take care of // the implementation of enabling/disabling cache since it just overwrite the @@ -55,11 +57,7 @@ async function testBypassSW () { return; } - let Ci = SpecialPowers.Ci; - let docShell = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docShell = SpecialPowers.wrap(window).docShell; info("Test 1: Enable bypass service worker for the docShell"); diff --git a/dom/tests/mochitest/ajax/offline/460353_iframe_ownmanifest.html b/dom/tests/mochitest/ajax/offline/460353_iframe_ownmanifest.html index 2ce13fd37d1d..2bcdb4611ed2 100644 --- a/dom/tests/mochitest/ajax/offline/460353_iframe_ownmanifest.html +++ b/dom/tests/mochitest/ajax/offline/460353_iframe_ownmanifest.html @@ -10,20 +10,6 @@ applicationCache.onerror = function() { applicationCache.oncached = function() { parent.frameOnUpdate("diff", true, applicationCache.status); - - /* This code tries to figure out what cache is really - associated to this document, but hangs on getter2.getInterface - from for now unknown reasons. Commenting this out. - - netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - - var getter1 = window.QueryInterface(Ci.nsIInterfaceRequestor); - var webnav = getter1.getInterface(Ci.nsIWebNavigation); - var getter2 = webnav.QueryInterface(Ci.nsIInterfaceRequestor); - var cacheCont = getter2.getInterface(Ci.nsIApplicationCacheContainer); - var cache = cacheCont.applicationCache; - dump(cache.groupID); - */ } diff --git a/dom/tests/mochitest/ajax/offline/offlineTests.js b/dom/tests/mochitest/ajax/offline/offlineTests.js index ddcc2f387b42..f176ec6aaf86 100644 --- a/dom/tests/mochitest/ajax/offline/offlineTests.js +++ b/dom/tests/mochitest/ajax/offline/offlineTests.js @@ -306,10 +306,8 @@ manifestURL: function(overload) loadContext: function() { - return SpecialPowers.wrap(window).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsILoadContext); + return SpecialPowers.wrap(window).docShell + .QueryInterface(SpecialPowers.Ci.nsILoadContext); }, loadContextInfo: function() diff --git a/dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html b/dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html index f655e4718766..02352e1582f7 100644 --- a/dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html +++ b/dom/tests/mochitest/gamepad/test_gamepad_extensions_iframe.html @@ -111,7 +111,7 @@ function posecheck() { function setFrameVisible(f, visible) { var Ci = SpecialPowers.Ci; - var docshell = SpecialPowers.wrap(f.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell); + var docshell = SpecialPowers.wrap(f.contentWindow).docShell; docshell.isActive = visible; } diff --git a/dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html b/dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html index 0bedb71c786b..71fdd83b8654 100644 --- a/dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html +++ b/dom/tests/mochitest/gamepad/test_gamepad_frame_state_sync_iframe.html @@ -19,7 +19,7 @@ var index; function setFrameVisible(f, visible) { var Ci = SpecialPowers.Ci; - var docshell = SpecialPowers.wrap(f.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell); + var docshell = SpecialPowers.wrap(f.contentWindow).docShell; docshell.isActive = visible; } diff --git a/dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html b/dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html index ef9232dff25c..c12b773cb233 100644 --- a/dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html +++ b/dom/tests/mochitest/gamepad/test_gamepad_hidden_frame_iframe.html @@ -26,7 +26,7 @@ function pressButton() { function setFrameVisible(f, visible) { var Ci = SpecialPowers.Ci; - var docshell = SpecialPowers.wrap(f.contentWindow).QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell); + var docshell = SpecialPowers.wrap(f.contentWindow).docShell; docshell.isActive = visible; } diff --git a/dom/tests/mochitest/general/test_innerScreen.xul b/dom/tests/mochitest/general/test_innerScreen.xul index d6dcc8425228..1ce22aaa1310 100644 --- a/dom/tests/mochitest/general/test_innerScreen.xul +++ b/dom/tests/mochitest/general/test_innerScreen.xul @@ -49,7 +49,7 @@ function doTests() var f = document.getElementById("f"); var fBounds = f.getBoundingClientRect(); - var fshell = f.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShell); + var fshell = f.contentWindow.docShell; var fmudv = fshell.contentViewer; isRounded(f.contentWindow.mozInnerScreenX, diff --git a/dom/tests/mochitest/whatwg/test_bug500328.html b/dom/tests/mochitest/whatwg/test_bug500328.html index bb9ff6f10590..7c6d6725f0e3 100644 --- a/dom/tests/mochitest/whatwg/test_bug500328.html +++ b/dom/tests/mochitest/whatwg/test_bug500328.html @@ -160,8 +160,8 @@ function getColor(elem) { function getSHistory(theWindow) { const Ci = SpecialPowers.Ci; - var sh = SpecialPowers.wrap(theWindow.QueryInterface(Ci.nsIInterfaceRequestor)) - .getInterface(Ci.nsIWebNavigation) + var sh = SpecialPowers.wrap(theWindow).docShell + .QueryInterface(Ci.nsIWebNavigation) .sessionHistory; if (!sh || sh == null) throw("Couldn't get shistory for window!"); diff --git a/dom/websocket/tests/websocket_tests.js b/dom/websocket/tests/websocket_tests.js index 31246ff7b777..90986f348760 100644 --- a/dom/websocket/tests/websocket_tests.js +++ b/dom/websocket/tests/websocket_tests.js @@ -991,8 +991,7 @@ function test41() { // clean up the STS state const Ci = SpecialPowers.Ci; var loadContext = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + .docShell .QueryInterface(Ci.nsILoadContext); var flags = 0; if (loadContext.usePrivateBrowsing) diff --git a/editor/AsyncSpellCheckTestHelper.jsm b/editor/AsyncSpellCheckTestHelper.jsm index 27a08fcc4118..a5716dbc4b37 100644 --- a/editor/AsyncSpellCheckTestHelper.jsm +++ b/editor/AsyncSpellCheckTestHelper.jsm @@ -30,11 +30,7 @@ function onSpellCheck(editableElement, callback) { let editor = editableElement.editor; if (!editor) { let win = editableElement.ownerGlobal; - editor = win.QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIWebNavigation). - QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIEditingSession). - getEditorForWindow(win); + editor = win.docShell.editingSession.getEditorForWindow(win); } if (!editor) throw new Error("Unable to find editor for element " + editableElement); diff --git a/editor/composer/test/test_bug1266815.html b/editor/composer/test/test_bug1266815.html index ded408c1b85f..2b5fc31b89ea 100644 --- a/editor/composer/test/test_bug1266815.html +++ b/editor/composer/test/test_bug1266815.html @@ -63,10 +63,7 @@ add_task(async function() { await promise; let iframe = document.getElementById("testframe"); - let docShell = SpecialPowers.wrap(iframe.contentWindow) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docShell = SpecialPowers.wrap(iframe.contentWindow).docShell; ok(docShell.hasEditingSession, "Should have editing session"); diff --git a/editor/composer/test/test_bug519928.html b/editor/composer/test/test_bug519928.html index f5712914b742..df6a1c1b5fb4 100644 --- a/editor/composer/test/test_bug519928.html +++ b/editor/composer/test/test_bug519928.html @@ -22,11 +22,7 @@ var iframe = document.getElementById("load-frame"); function enableJS() { allowJS(true, iframe); } function disableJS() { allowJS(false, iframe); } function allowJS(allow, frame) { - SpecialPowers.wrap(frame.contentWindow) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell) - .allowJavascript = allow; + SpecialPowers.wrap(frame.contentWindow).docShell.allowJavascript = allow; } function expectJSAllowed(allowed, testCondition, callback) { diff --git a/editor/libeditor/tests/test_CF_HTML_clipboard.html b/editor/libeditor/tests/test_CF_HTML_clipboard.html index da3ca99dd6b8..3f67af1bcf90 100644 --- a/editor/libeditor/tests/test_CF_HTML_clipboard.html +++ b/editor/libeditor/tests/test_CF_HTML_clipboard.html @@ -27,8 +27,8 @@ function copyCF_HTML(cfhtml, success, failure) { const CF_HTML = "application/x-moz-nativehtml"; function getLoadContext() { - return SpecialPowers.wrap(window).QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + return SpecialPowers.wrap(window) + .docShell .QueryInterface(Ci.nsILoadContext); } diff --git a/editor/libeditor/tests/test_bug1100966.html b/editor/libeditor/tests/test_bug1100966.html index b873032f918a..da45196a2ae9 100644 --- a/editor/libeditor/tests/test_bug1100966.html +++ b/editor/libeditor/tests/test_bug1100966.html @@ -54,11 +54,7 @@ SimpleTest.waitForFocus(function() { function getEditor() { var Ci = SpecialPowers.Ci; - var editingSession = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(window).docShell.editingSession; return editingSession.getEditorForWindow(window); } diff --git a/editor/libeditor/tests/test_bug1140105.html b/editor/libeditor/tests/test_bug1140105.html index 646e33fcf3ab..226b15894880 100644 --- a/editor/libeditor/tests/test_bug1140105.html +++ b/editor/libeditor/tests/test_bug1140105.html @@ -53,11 +53,7 @@ SimpleTest.waitForFocus(function() { function getEditor() { var Ci = SpecialPowers.Ci; - var editingSession = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(window).docShell.editingSession; var editor = editingSession.getEditorForWindow(window); editor.QueryInterface(Ci.nsIHTMLEditor); return editor; diff --git a/editor/libeditor/tests/test_bug1154791.html b/editor/libeditor/tests/test_bug1154791.html index 213d63100bc6..ef74d92415f4 100644 --- a/editor/libeditor/tests/test_bug1154791.html +++ b/editor/libeditor/tests/test_bug1154791.html @@ -54,11 +54,7 @@ SimpleTest.waitForFocus(function() { function getEditor() { var Ci = SpecialPowers.Ci; - var editingSession = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(window).docShell.editingSession; return editingSession.getEditorForWindow(window); } diff --git a/editor/libeditor/tests/test_bug1186799.html b/editor/libeditor/tests/test_bug1186799.html index b0b583a7e2e0..5fbbef05782f 100644 --- a/editor/libeditor/tests/test_bug1186799.html +++ b/editor/libeditor/tests/test_bug1186799.html @@ -54,10 +54,8 @@ SimpleTest.waitForFocus(function() { function isThereIMESelection() { var selCon = SpecialPowers.wrap(window). - QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). - getInterface(SpecialPowers.Ci.nsIWebNavigation). - QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). - getInterface(SpecialPowers.Ci.nsIEditingSession). + docShell. + editingSession. getEditorForWindow(window). selectionController; const kIMESelections = [ diff --git a/editor/libeditor/tests/test_bug1230473.html b/editor/libeditor/tests/test_bug1230473.html index 5635179a1b05..f6b1a3b4fa59 100644 --- a/editor/libeditor/tests/test_bug1230473.html +++ b/editor/libeditor/tests/test_bug1230473.html @@ -35,9 +35,7 @@ SimpleTest.waitForFocus(()=>{ .editor .composing : SpecialPowers.wrap(window) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell) + .docShell .editor .composing; } diff --git a/editor/libeditor/tests/test_bug1268736.html b/editor/libeditor/tests/test_bug1268736.html index fb1f341b5128..f9692c8d9c46 100644 --- a/editor/libeditor/tests/test_bug1268736.html +++ b/editor/libeditor/tests/test_bug1268736.html @@ -37,11 +37,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1268736 function getEditor() { const Ci = SpecialPowers.Ci; - var editingSession = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(window).docShell.editingSession; return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor); } diff --git a/editor/libeditor/tests/test_bug1330796.html b/editor/libeditor/tests/test_bug1330796.html index a6ed950be297..864a0b03b98f 100644 --- a/editor/libeditor/tests/test_bug1330796.html +++ b/editor/libeditor/tests/test_bug1330796.html @@ -86,11 +86,7 @@ SimpleTest.waitForFocus(function() { function makeMailEditor() { var Ci = SpecialPowers.Ci; - var editingSession = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(window).docShell.editingSession; var editor = editingSession.getEditorForWindow(window); editor.flags |= Ci.nsIPlaintextEditor.eEditorMailMask; } diff --git a/editor/libeditor/tests/test_bug1397412.xul b/editor/libeditor/tests/test_bug1397412.xul index 24a6fc829fec..6a1b63ae40b6 100644 --- a/editor/libeditor/tests/test_bug1397412.xul +++ b/editor/libeditor/tests/test_bug1397412.xul @@ -33,9 +33,7 @@ function runTest() { var expectedHTML1 = "xx
t
"; var initialHTML2 = "xx

yy
"; var expectedHTML2 = "xx
t
yy
"; - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) + window.docShell .rootTreeItem .QueryInterface(Ci.nsIDocShell) .appType = Ci.nsIDocShell.APP_TYPE_EDITOR; diff --git a/editor/libeditor/tests/test_bug366682.html b/editor/libeditor/tests/test_bug366682.html index 18e4a7eea419..f1a5b8df233b 100644 --- a/editor/libeditor/tests/test_bug366682.html +++ b/editor/libeditor/tests/test_bug366682.html @@ -36,11 +36,7 @@ function editDoc() { function getEditor() { var Ci = SpecialPowers.Ci; var win = editDoc().defaultView; - var editingSession = SpecialPowers.wrap(win) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(win).docShell.editingSession; return editingSession.getEditorForWindow(win); } diff --git a/editor/libeditor/tests/test_bug432225.html b/editor/libeditor/tests/test_bug432225.html index e0e98476df2a..fcb135229c91 100644 --- a/editor/libeditor/tests/test_bug432225.html +++ b/editor/libeditor/tests/test_bug432225.html @@ -39,11 +39,7 @@ function editDoc() { function getEditor() { var Ci = SpecialPowers.Ci; var win = editDoc().defaultView; - var editingSession = SpecialPowers.wrap(win) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(win).docShell.editingSession; return editingSession.getEditorForWindow(win); } diff --git a/editor/libeditor/tests/test_bug484181.html b/editor/libeditor/tests/test_bug484181.html index bb107612e348..becf779516b4 100644 --- a/editor/libeditor/tests/test_bug484181.html +++ b/editor/libeditor/tests/test_bug484181.html @@ -29,10 +29,7 @@ var gMisspeltWords; function getEditor() { var Ci = SpecialPowers.Ci; var win = window; - var editingSession = SpecialPowers.wrap(win).QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(win).docShell.editingSession; return editingSession.getEditorForWindow(win); } diff --git a/editor/libeditor/tests/test_bug489202.xul b/editor/libeditor/tests/test_bug489202.xul index 5c9091ad57b2..ef65d1e4d82b 100644 --- a/editor/libeditor/tests/test_bug489202.xul +++ b/editor/libeditor/tests/test_bug489202.xul @@ -31,9 +31,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=489202 var utils = SpecialPowers.getDOMWindowUtils(window); function getLoadContext() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return window.docShell.QueryInterface(Ci.nsILoadContext); } function runTest() { @@ -47,9 +45,7 @@ function runTest() { cstr.data = test_data; trans.setTransferData("text/html", cstr, test_data.length*2); - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) + window.docShell .rootTreeItem .QueryInterface(Ci.nsIDocShell) .appType = Ci.nsIDocShell.APP_TYPE_EDITOR; diff --git a/editor/libeditor/tests/test_bug520189.html b/editor/libeditor/tests/test_bug520189.html index e48586e0de75..ce0f49c0d477 100644 --- a/editor/libeditor/tests/test_bug520189.html +++ b/editor/libeditor/tests/test_bug520189.html @@ -550,10 +550,7 @@ function doNextTest() { function getLoadContext() { const Ci = SpecialPowers.Ci; - return SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return SpecialPowers.wrap(window).docShell.QueryInterface(Ci.nsILoadContext); } function runTest(test) { @@ -581,10 +578,7 @@ function runTest(test) { getSelection().collapse(elem, 0); win = window; } - editor = SpecialPowers.wrap(win).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell) - .editor; + editor = SpecialPowers.wrap(win).docShell.editor; editor.pasteTransferable(trans); } else { var clipboard = SpecialPowers.Cc["@mozilla.org/widget/clipboard;1"] diff --git a/editor/libeditor/tests/test_bug525389.html b/editor/libeditor/tests/test_bug525389.html index 57ce7b02f463..744acef33f68 100644 --- a/editor/libeditor/tests/test_bug525389.html +++ b/editor/libeditor/tests/test_bug525389.html @@ -13,10 +13,7 @@ var Ci = SpecialPowers.Ci; function getLoadContext() { - return SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return SpecialPowers.wrap(window).docShell.QueryInterface(Ci.nsILoadContext); } async function runTest() { diff --git a/editor/libeditor/tests/test_bug596333.html b/editor/libeditor/tests/test_bug596333.html index a96d8202e0c8..df0c3b8b761f 100644 --- a/editor/libeditor/tests/test_bug596333.html +++ b/editor/libeditor/tests/test_bug596333.html @@ -40,10 +40,7 @@ function append(str) { } function getLoadContext() { - return SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return SpecialPowers.wrap(window).docShell.QueryInterface(Ci.nsILoadContext); } function paste(str) { diff --git a/editor/libeditor/tests/test_bug790475.html b/editor/libeditor/tests/test_bug790475.html index fa235f834d40..46f84f5d234e 100644 --- a/editor/libeditor/tests/test_bug790475.html +++ b/editor/libeditor/tests/test_bug790475.html @@ -29,11 +29,7 @@ var gMisspeltWords; function getEditor() { const Ci = SpecialPowers.Ci; - var editingSession = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(window).docShell.editingSession; return editingSession.getEditorForWindow(window); } diff --git a/editor/libeditor/tests/test_bug857487.html b/editor/libeditor/tests/test_bug857487.html index a3746d44c698..8cf817427194 100644 --- a/editor/libeditor/tests/test_bug857487.html +++ b/editor/libeditor/tests/test_bug857487.html @@ -42,11 +42,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=857487 function getEditor() { const Ci = SpecialPowers.Ci; - var editingSession = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(window).docShell.editingSession; return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor); } diff --git a/editor/libeditor/tests/test_bug974309.html b/editor/libeditor/tests/test_bug974309.html index e3caa87fb8f6..2ac4e83d94c5 100644 --- a/editor/libeditor/tests/test_bug974309.html +++ b/editor/libeditor/tests/test_bug974309.html @@ -44,11 +44,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=974309 function getEditor() { const Ci = SpecialPowers.Ci; - var editingSession = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(window).docShell.editingSession; return editingSession.getEditorForWindow(window).QueryInterface(Ci.nsITableEditor); } diff --git a/editor/libeditor/tests/test_contenteditable_focus.html b/editor/libeditor/tests/test_contenteditable_focus.html index 33e10c6db71a..30805bb37901 100644 --- a/editor/libeditor/tests/test_contenteditable_focus.html +++ b/editor/libeditor/tests/test_contenteditable_focus.html @@ -56,9 +56,7 @@ function runTestsInternal() // XXX using selCon for checking the visibility of the caret, however, // selCon is shared in document, cannot get the element of owner of the // caret from javascript? - var selCon = SpecialPowers.wrap(window). - QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). - getInterface(SpecialPowers.Ci.nsIWebNavigation). + var selCon = SpecialPowers.wrap(window).docShell. QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). getInterface(SpecialPowers.Ci.nsISelectionDisplay). QueryInterface(SpecialPowers.Ci.nsISelectionController); diff --git a/editor/libeditor/tests/test_css_chrome_load_access.html b/editor/libeditor/tests/test_css_chrome_load_access.html index b6bb3fb46aac..6f8d7ef01bdd 100644 --- a/editor/libeditor/tests/test_css_chrome_load_access.html +++ b/editor/libeditor/tests/test_css_chrome_load_access.html @@ -25,11 +25,7 @@ function runTest() { var editframe = window.frames[0]; var editdoc = editframe.document; editdoc.designMode = 'on'; - var editor = SpecialPowers.wrap(editframe) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession) + var editor = SpecialPowers.wrap(editframe).docShell.editingSession .getEditorForWindow(editframe); styleSheets = editor.QueryInterface(Ci.nsIEditorStyleSheets); diff --git a/editor/libeditor/tests/test_documentCharacterSet.html b/editor/libeditor/tests/test_documentCharacterSet.html index 02defe5763a0..b0e2a1690844 100644 --- a/editor/libeditor/tests/test_documentCharacterSet.html +++ b/editor/libeditor/tests/test_documentCharacterSet.html @@ -18,11 +18,7 @@ function getEditor() { const Ci = SpecialPowers.Ci; let editframe = window.frames[0]; - return SpecialPowers.wrap(editframe) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession) + return SpecialPowers.wrap(editframe).docShell.editingSession .getEditorForWindow(editframe); } diff --git a/editor/libeditor/tests/test_htmleditor_keyevent_handling.html b/editor/libeditor/tests/test_htmleditor_keyevent_handling.html index 3a629e054d56..c3b50ceb5de6 100644 --- a/editor/libeditor/tests/test_htmleditor_keyevent_handling.html +++ b/editor/libeditor/tests/test_htmleditor_keyevent_handling.html @@ -609,10 +609,7 @@ function runTests() doTest(htmlEditor, "contenteditable=\"true\"", false, true, false); const nsIPlaintextEditor = SpecialPowers.Ci.nsIPlaintextEditor; - var editor = SpecialPowers.wrap(window). - QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). - getInterface(SpecialPowers.Ci.nsIWebNavigation). - QueryInterface(SpecialPowers.Ci.nsIDocShell).editor; + var editor = SpecialPowers.wrap(window).docShell.editor; var flags = editor.flags; // readonly editor.flags = flags | nsIPlaintextEditor.eEditorReadonlyMask; diff --git a/editor/libeditor/tests/test_root_element_replacement.html b/editor/libeditor/tests/test_root_element_replacement.html index e60dd2592836..db4815e74dc9 100644 --- a/editor/libeditor/tests/test_root_element_replacement.html +++ b/editor/libeditor/tests/test_root_element_replacement.html @@ -84,8 +84,7 @@ function onLoadIFrame() var frameDoc = gIFrame.contentWindow.document; var selCon = SpecialPowers.wrap(gIFrame).contentWindow. - QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). - getInterface(SpecialPowers.Ci.nsIWebNavigation). + docShell. QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). getInterface(SpecialPowers.Ci.nsISelectionDisplay). QueryInterface(SpecialPowers.Ci.nsISelectionController); diff --git a/editor/spellchecker/tests/test_bug1205983.html b/editor/spellchecker/tests/test_bug1205983.html index d702827901ee..27623ec03bd8 100644 --- a/editor/spellchecker/tests/test_bug1205983.html +++ b/editor/spellchecker/tests/test_bug1205983.html @@ -66,11 +66,7 @@ function deFocus() { onSpellCheck(elem_de, function () { var Ci = SpecialPowers.Ci; - var editingSession = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(window).docShell.editingSession; editor_de = editingSession.getEditorForWindow(window); selcon_de = editor_de.selectionController; var sel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK); diff --git a/editor/spellchecker/tests/test_bug1219928.html b/editor/spellchecker/tests/test_bug1219928.html index 4a4c05c7e7fc..95e6d338b391 100644 --- a/editor/spellchecker/tests/test_bug1219928.html +++ b/editor/spellchecker/tests/test_bug1219928.html @@ -37,11 +37,7 @@ SimpleTest.waitForFocus(function() { onSpellCheck(elem, function () { var Ci = SpecialPowers.Ci; - var editingSession = SpecialPowers.wrap(window) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIEditingSession); + var editingSession = SpecialPowers.wrap(window).docShell.editingSession; var editor = editingSession.getEditorForWindow(window); var selcon = editor.selectionController; var sel = selcon.getSelection(selcon.SELECTION_SPELLCHECK); diff --git a/gfx/2d/FontVariation.h b/gfx/2d/FontVariation.h index 9fa590c7af1e..a9a3aab035ff 100644 --- a/gfx/2d/FontVariation.h +++ b/gfx/2d/FontVariation.h @@ -7,6 +7,8 @@ #ifndef MOZILLA_GFX_FONTVARIATION_H_ #define MOZILLA_GFX_FONTVARIATION_H_ +#include + namespace mozilla { namespace gfx { diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 1a84b4a231b6..056e91359869 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -133,6 +133,9 @@ typedef PlatformSpecificStateBase PlatformSpecificState; // no extra state, jus * \li\b apz.allow_checkerboarding * Pref that allows or disallows checkerboarding * + * \li\b apz.allow_double_tap_zooming + * Pref that allows or disallows double tap to zoom + * * \li\b apz.allow_immediate_handoff * If set to true, scroll can be handed off from one APZC to another within * a single input block. If set to false, a single input block can only diff --git a/gfx/tests/browser/browser_windowless_troubleshoot_crash.js b/gfx/tests/browser/browser_windowless_troubleshoot_crash.js index 5957e6061467..1f86a8a0f4e7 100644 --- a/gfx/tests/browser/browser_windowless_troubleshoot_crash.js +++ b/gfx/tests/browser/browser_windowless_troubleshoot_crash.js @@ -8,9 +8,7 @@ add_task(async function test_windowlessBrowserTroubleshootCrash() { .getInterface(Ci.nsIDocShell); let listener = { observe(contentWindow, topic, data) { - let observedDocShell = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) + let observedDocShell = contentWindow.docShell .sameTypeRootTreeItem .QueryInterface(Ci.nsIDocShell); if (docShell === observedDocShell) { diff --git a/gfx/thebes/gfxFT2FontBase.cpp b/gfx/thebes/gfxFT2FontBase.cpp index 7314bb99fdea..f78db66abd70 100644 --- a/gfx/thebes/gfxFT2FontBase.cpp +++ b/gfx/thebes/gfxFT2FontBase.cpp @@ -233,7 +233,7 @@ gfxFT2FontBase::InitMetrics() // Resolve variations from entry (descriptor) and style (property) AutoTArray settings; mFontEntry->GetVariationsForStyle(settings, mStyle); - SetupVarCoords(face, settings, &mCoords); + SetupVarCoords(mFontEntry->GetMMVar(), settings, &mCoords); if (!mCoords.IsEmpty()) { #if MOZ_TREE_FREETYPE FT_Set_Var_Design_Coordinates(face, mCoords.Length(), mCoords.Elements()); @@ -638,45 +638,24 @@ gfxFT2FontBase::SetupCairoFont(DrawTarget* aDrawTarget) // axes in mStyle.variationSettings, so we need to search by axis tag). /*static*/ void -gfxFT2FontBase::SetupVarCoords(FT_Face aFace, +gfxFT2FontBase::SetupVarCoords(FT_MM_Var* aMMVar, const nsTArray& aVariations, nsTArray* aCoords) { aCoords->TruncateLength(0); - if (aFace->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS) { - typedef FT_Error (*GetVarFunc)(FT_Face, FT_MM_Var**); - typedef FT_Error (*DoneVarFunc)(FT_Library, FT_MM_Var*); -#if MOZ_TREE_FREETYPE - GetVarFunc getVar = &FT_Get_MM_Var; - DoneVarFunc doneVar = &FT_Done_MM_Var; -#else - static GetVarFunc getVar; - static DoneVarFunc doneVar; - static bool firstTime = true; - if (firstTime) { - firstTime = false; - getVar = (GetVarFunc)dlsym(RTLD_DEFAULT, "FT_Get_MM_Var"); - doneVar = (DoneVarFunc)dlsym(RTLD_DEFAULT, "FT_Done_MM_Var"); - } -#endif - FT_MM_Var* ftVar; - if (getVar && FT_Err_Ok == (*getVar)(aFace, &ftVar)) { - for (unsigned i = 0; i < ftVar->num_axis; ++i) { - aCoords->AppendElement(ftVar->axis[i].def); - for (const auto& v : aVariations) { - if (ftVar->axis[i].tag == v.mTag) { - FT_Fixed val = v.mValue * 0x10000; - val = std::min(val, ftVar->axis[i].maximum); - val = std::max(val, ftVar->axis[i].minimum); - (*aCoords)[i] = val; - break; - } - } - } - if (doneVar) { - (*doneVar)(aFace->glyph->library, ftVar); - } else { - free(ftVar); + if (!aMMVar) { + return; + } + + for (unsigned i = 0; i < aMMVar->num_axis; ++i) { + aCoords->AppendElement(aMMVar->axis[i].def); + for (const auto& v : aVariations) { + if (aMMVar->axis[i].tag == v.mTag) { + FT_Fixed val = v.mValue * 0x10000; + val = std::min(val, aMMVar->axis[i].maximum); + val = std::max(val, aMMVar->axis[i].minimum); + (*aCoords)[i] = val; + break; } } } diff --git a/gfx/thebes/gfxFT2FontBase.h b/gfx/thebes/gfxFT2FontBase.h index 3ce63f5003a0..493227bbc5c9 100644 --- a/gfx/thebes/gfxFT2FontBase.h +++ b/gfx/thebes/gfxFT2FontBase.h @@ -37,7 +37,7 @@ public: virtual FontType GetType() const override { return FONT_TYPE_FT2; } - static void SetupVarCoords(FT_Face aFace, + static void SetupVarCoords(FT_MM_Var* aMMVar, const nsTArray& aVariations, nsTArray* aCoords); diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index dbe9d368e301..a45d4bfc24df 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -206,6 +206,10 @@ FT2FontEntry::CreateScaledFont(const gfxFontStyle *aStyle) FT2FontEntry::~FT2FontEntry() { + if (mMMVar) { + FT_Done_MM_Var(mFTFace->glyph->library, mMMVar); + } + // Do nothing for mFTFace here since FTFontDestroyFunc is called by cairo. mFTFace = nullptr; @@ -473,7 +477,7 @@ FT2FontEntry::CairoFontFace(const gfxFontStyle* aStyle) AutoTArray settings; GetVariationsForStyle(settings, aStyle ? *aStyle : gfxFontStyle()); AutoTArray coords; - gfxFT2FontBase::SetupVarCoords(mFTFace, settings, &coords); + gfxFT2FontBase::SetupVarCoords(GetMMVar(), settings, &coords); // Create a separate FT_Face because we need to apply custom // variation settings to it. FT_Face ftFace; @@ -646,16 +650,11 @@ FT2FontEntry::GetVariationAxes(nsTArray& aAxes) if (!HasVariations()) { return; } - AutoFTFace face(this); - if (!face) { - return; - } - FT_MM_Var* mmVar; - if (FT_Err_Ok != (FT_Get_MM_Var(face, &mmVar))) { + FT_MM_Var* mmVar = GetMMVar(); + if (!mmVar) { return; } gfxFT2Utils::GetVariationAxes(mmVar, aAxes); - FT_Done_MM_Var(FT_Face(face)->glyph->library, mmVar); } void @@ -665,16 +664,28 @@ FT2FontEntry::GetVariationInstances( if (!HasVariations()) { return; } - AutoFTFace face(this); - if (!face) { - return; - } - FT_MM_Var* mmVar; - if (FT_Err_Ok != (FT_Get_MM_Var(face, &mmVar))) { + FT_MM_Var* mmVar = GetMMVar(); + if (!mmVar) { return; } gfxFT2Utils::GetVariationInstances(this, mmVar, aInstances); - FT_Done_MM_Var(FT_Face(face)->glyph->library, mmVar); +} + +FT_MM_Var* +FT2FontEntry::GetMMVar() +{ + if (mMMVarInitialized) { + return mMMVar; + } + mMMVarInitialized = true; + AutoFTFace face(this); + if (!face) { + return nullptr; + } + if (FT_Err_Ok != FT_Get_MM_Var(face, &mMMVar)) { + mMMVar = nullptr; + } + return mMMVar; } void diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index d4ef14751e13..ac1a33ef82d1 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -94,6 +94,8 @@ public: // accordingly so that we avoid using bad font tables void CheckForBrokenFont(gfxFontFamily *aFamily); + FT_MM_Var* GetMMVar() override; + virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, FontListSizes* aSizes) const override; virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, @@ -102,6 +104,8 @@ public: FT_Face mFTFace; cairo_font_face_t *mFontFace; + FT_MM_Var* mMMVar = nullptr; + nsCString mFilename; uint8_t mFTFontIndex; @@ -109,6 +113,7 @@ public: bool mHasVariations = false; bool mHasVariationsInitialized = false; + bool mMMVarInitialized = false; }; class FT2FontFamily : public gfxFontFamily diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index 8d8578d61af3..369e1e1cb3c9 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -784,7 +784,7 @@ gfxFontconfigFontEntry::CreateScaledFont(FcPattern* aRenderPattern, if (ftFace) { AutoTArray settings; GetVariationsForStyle(settings, *aStyle); - gfxFT2FontBase::SetupVarCoords(ftFace, settings, &coords); + gfxFT2FontBase::SetupVarCoords(GetMMVar(), settings, &coords); } } diff --git a/gfx/thebes/gfxFcPlatformFontList.h b/gfx/thebes/gfxFcPlatformFontList.h index 0a50a64e7419..510a4a21b86a 100644 --- a/gfx/thebes/gfxFcPlatformFontList.h +++ b/gfx/thebes/gfxFcPlatformFontList.h @@ -117,7 +117,7 @@ public: FT_Face GetFTFace(); - FT_MM_Var* GetMMVar(); + FT_MM_Var* GetMMVar() override; bool HasVariations() override; void GetVariationAxes(nsTArray& aAxes) override; diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 0a9475de1be6..e85699c8c7d0 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -46,6 +46,10 @@ #include "GreekCasing.h" #include "cairo.h" +#ifdef XP_WIN +#include "cairo-win32.h" +#include "gfxWindowsPlatform.h" +#endif #include "harfbuzz/hb.h" #include "harfbuzz/hb-ot.h" diff --git a/gfx/thebes/gfxFontEntry.h b/gfx/thebes/gfxFontEntry.h index 28283c001a0a..e7ae5a7107d5 100644 --- a/gfx/thebes/gfxFontEntry.h +++ b/gfx/thebes/gfxFontEntry.h @@ -27,6 +27,7 @@ #include typedef struct gr_face gr_face; +typedef struct FT_MM_Var_ FT_MM_Var; #ifdef DEBUG #include @@ -397,6 +398,9 @@ public: // Get the font's list of features (if any) for DevTools support. void GetFeatureInfo(nsTArray& aFeatureInfo); + // This is only called on platforms where we use FreeType. + virtual FT_MM_Var* GetMMVar() { return nullptr; } + nsString mName; nsString mFamilyName; diff --git a/gfx/thebes/gfxFontInfoLoader.cpp b/gfx/thebes/gfxFontInfoLoader.cpp index e762245b1bd1..54369ce9dc06 100644 --- a/gfx/thebes/gfxFontInfoLoader.cpp +++ b/gfx/thebes/gfxFontInfoLoader.cpp @@ -9,6 +9,10 @@ #include "nsThreadUtils.h" // for nsRunnable #include "gfxPlatformFontList.h" +#ifdef XP_WIN +#include +#endif + using namespace mozilla; using services::GetObserverService; diff --git a/gfx/thebes/gfxFontMissingGlyphs.h b/gfx/thebes/gfxFontMissingGlyphs.h index 25e45595b6b7..90a42cbc14bc 100644 --- a/gfx/thebes/gfxFontMissingGlyphs.h +++ b/gfx/thebes/gfxFontMissingGlyphs.h @@ -7,6 +7,7 @@ #define GFX_FONTMISSINGGLYPHS_H #include "mozilla/Attributes.h" +#include "mozilla/gfx/MatrixFwd.h" #include "mozilla/gfx/Rect.h" namespace mozilla { @@ -24,6 +25,7 @@ class gfxFontMissingGlyphs final { typedef mozilla::gfx::DrawTarget DrawTarget; typedef mozilla::gfx::Float Float; + typedef mozilla::gfx::Matrix Matrix; typedef mozilla::gfx::Pattern Pattern; typedef mozilla::gfx::Rect Rect; diff --git a/gfx/thebes/gfxPattern.cpp b/gfx/thebes/gfxPattern.cpp index 429645f402e4..9aad3ffa3fd1 100644 --- a/gfx/thebes/gfxPattern.cpp +++ b/gfx/thebes/gfxPattern.cpp @@ -182,7 +182,7 @@ gfxPattern::IsOpaque() } void -gfxPattern::SetSamplingFilter(gfx::SamplingFilter filter) +gfxPattern::SetSamplingFilter(mozilla::gfx::SamplingFilter filter) { if (mGfxPattern.GetPattern()->GetType() != PatternType::SURFACE) { return; @@ -195,7 +195,7 @@ SamplingFilter gfxPattern::SamplingFilter() const { if (mGfxPattern.GetPattern()->GetType() != PatternType::SURFACE) { - return gfx::SamplingFilter::GOOD; + return mozilla::gfx::SamplingFilter::GOOD; } return static_cast(mGfxPattern.GetPattern())->mSamplingFilter; } diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 0e5190721b03..025a6a6fcbc4 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -293,6 +293,7 @@ private: // The apz prefs are explained in AsyncPanZoomController.cpp DECL_GFX_PREF(Live, "apz.allow_checkerboarding", APZAllowCheckerboarding, bool, true); + DECL_GFX_PREF(Live, "apz.allow_double_tap_zooming", APZAllowDoubleTapZooming, bool, true); DECL_GFX_PREF(Live, "apz.allow_immediate_handoff", APZAllowImmediateHandoff, bool, true); DECL_GFX_PREF(Live, "apz.allow_zooming", APZAllowZooming, bool, false); DECL_GFX_PREF(Live, "apz.android.chrome_fling_physics.enabled", APZUseChromeFlingPhysics, bool, false); diff --git a/gfx/thebes/gfxSVGGlyphs.cpp b/gfx/thebes/gfxSVGGlyphs.cpp index cbb14fd086b7..c41a0e425a20 100644 --- a/gfx/thebes/gfxSVGGlyphs.cpp +++ b/gfx/thebes/gfxSVGGlyphs.cpp @@ -40,7 +40,7 @@ using namespace mozilla; typedef mozilla::dom::Element Element; -/* static */ const Color SimpleTextContextPaint::sZero = Color(); +/* static */ const mozilla::gfx::Color SimpleTextContextPaint::sZero; gfxSVGGlyphs::gfxSVGGlyphs(hb_blob_t *aSVGTable, gfxFontEntry *aFontEntry) : mSVGData(aSVGTable) diff --git a/gfx/thebes/gfxSkipChars.cpp b/gfx/thebes/gfxSkipChars.cpp index d0fad53e2e47..0cd53c87b654 100644 --- a/gfx/thebes/gfxSkipChars.cpp +++ b/gfx/thebes/gfxSkipChars.cpp @@ -5,6 +5,7 @@ #include "gfxSkipChars.h" #include "mozilla/BinarySearch.h" +#include "mozilla/gfx/Logging.h" struct SkippedRangeStartComparator { diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp index a4634fb6f904..b93f19120ba9 100644 --- a/gfx/thebes/gfxTextRun.cpp +++ b/gfx/thebes/gfxTextRun.cpp @@ -6,6 +6,7 @@ #include "gfxTextRun.h" #include "gfxGlyphExtents.h" +#include "gfxHarfBuzzShaper.h" #include "gfxPlatformFontList.h" #include "gfxUserFontSet.h" #include "mozilla/gfx/2D.h" diff --git a/gfx/thebes/moz.build b/gfx/thebes/moz.build index 9f51aab0aac3..e29c26fd7dc6 100644 --- a/gfx/thebes/moz.build +++ b/gfx/thebes/moz.build @@ -176,6 +176,8 @@ SOURCES += [ # we could consider removing soon (affects Ubuntus older than 10.04 LTS) # which currently prevent it from joining UNIFIED_SOURCES. 'gfxDrawable.cpp', + # gfxFontInfoLoader.cpp needs to set no_pgo for clang-cl + 'gfxFontInfoLoader.cpp', # gfxFontUtils.cpp and gfxPlatform.cpp include mac system header conflicting with point/size 'gfxFontUtils.cpp', 'gfxPlatform.cpp', @@ -184,6 +186,10 @@ SOURCES += [ 'PrintTargetThebes.cpp', ] +if CONFIG['CC_TYPE'] == 'clang-cl': + # clang-cl crashes trying to PGO this file (Bug 1479842) + SOURCES['gfxFontInfoLoader.cpp'].no_pgo = True + UNIFIED_SOURCES += [ 'CJKCompatSVS.cpp', 'gfxAlphaRecovery.cpp', @@ -193,7 +199,6 @@ UNIFIED_SOURCES += [ 'gfxFont.cpp', 'gfxFontEntry.cpp', 'gfxFontFeatures.cpp', - 'gfxFontInfoLoader.cpp', 'gfxFontMissingGlyphs.cpp', 'gfxFontSrcPrincipal.cpp', 'gfxFontSrcURI.cpp', diff --git a/ipc/ipdl/sync-messages.ini b/ipc/ipdl/sync-messages.ini index 625882008c30..626e23b76b8b 100644 --- a/ipc/ipdl/sync-messages.ini +++ b/ipc/ipdl/sync-messages.ini @@ -614,8 +614,6 @@ description = description = [PJavaScript::PreventExtensions] description = -[PJavaScript::GetPropertyDescriptor] -description = [PJavaScript::GetOwnPropertyDescriptor] description = [PJavaScript::DefineProperty] diff --git a/js/ipc/JavaScriptBase.h b/js/ipc/JavaScriptBase.h index 52a498ebf1d2..df884274e975 100644 --- a/js/ipc/JavaScriptBase.h +++ b/js/ipc/JavaScriptBase.h @@ -37,15 +37,6 @@ class JavaScriptBase : public WrapperOwner, public WrapperAnswer, public Base } return IPC_OK(); } - mozilla::ipc::IPCResult RecvGetPropertyDescriptor(const uint64_t& objId, const JSIDVariant& id, - ReturnStatus* rs, - PPropertyDescriptor* out) override { - Maybe obj(ObjectId::deserialize(objId)); - if (obj.isNothing() || !Answer::RecvGetPropertyDescriptor(obj.value(), id, rs, out)) { - return IPC_FAIL_NO_REASON(this); - } - return IPC_OK(); - } mozilla::ipc::IPCResult RecvGetOwnPropertyDescriptor(const uint64_t& objId, const JSIDVariant& id, ReturnStatus* rs, @@ -216,11 +207,6 @@ class JavaScriptBase : public WrapperOwner, public WrapperAnswer, public Base bool SendPreventExtensions(const ObjectId& objId, ReturnStatus* rs) override { return Base::SendPreventExtensions(objId.serialize(), rs); } - bool SendGetPropertyDescriptor(const ObjectId& objId, const JSIDVariant& id, - ReturnStatus* rs, - PPropertyDescriptor* out) override { - return Base::SendGetPropertyDescriptor(objId.serialize(), id, rs, out); - } bool SendGetOwnPropertyDescriptor(const ObjectId& objId, const JSIDVariant& id, ReturnStatus* rs, diff --git a/js/ipc/PJavaScript.ipdl b/js/ipc/PJavaScript.ipdl index 41110968f578..e2f9f02db405 100644 --- a/js/ipc/PJavaScript.ipdl +++ b/js/ipc/PJavaScript.ipdl @@ -25,7 +25,6 @@ both: // These roughly map to the ProxyHandler hooks that CPOWs need. nested(inside_sync) sync PreventExtensions(uint64_t objId) returns (ReturnStatus rs); - nested(inside_sync) sync GetPropertyDescriptor(uint64_t objId, JSIDVariant id) returns (ReturnStatus rs, PPropertyDescriptor result); nested(inside_sync) sync GetOwnPropertyDescriptor(uint64_t objId, JSIDVariant id) returns (ReturnStatus rs, PPropertyDescriptor result); nested(inside_sync) sync DefineProperty(uint64_t objId, JSIDVariant id, PPropertyDescriptor descriptor) returns (ReturnStatus rs); nested(inside_sync) sync Delete(uint64_t objId, JSIDVariant id) returns (ReturnStatus rs); diff --git a/js/ipc/WrapperAnswer.cpp b/js/ipc/WrapperAnswer.cpp index 5e7f786a543a..682f045d3cd9 100644 --- a/js/ipc/WrapperAnswer.cpp +++ b/js/ipc/WrapperAnswer.cpp @@ -130,41 +130,6 @@ EmptyDesc(PPropertyDescriptor* desc) desc->setter() = 0; } -bool -WrapperAnswer::RecvGetPropertyDescriptor(const ObjectId& objId, const JSIDVariant& idVar, - ReturnStatus* rs, PPropertyDescriptor* out) -{ - if (!IsInAutomation()) - return false; - - MaybeForceDebugGC(); - - AutoJSAPI jsapi; - if (NS_WARN_IF(!jsapi.Init(scopeForTargetObjects()))) - return false; - JSContext* cx = jsapi.cx(); - EmptyDesc(out); - - RootedObject obj(cx, findObjectById(cx, objId)); - if (!obj) - return deadCPOW(jsapi, rs); - - LOG("%s.getPropertyDescriptor(%s)", ReceiverObj(objId), Identifier(idVar)); - - RootedId id(cx); - if (!fromJSIDVariant(cx, idVar, &id)) - return fail(jsapi, rs); - - Rooted desc(cx); - if (!JS_GetPropertyDescriptorById(cx, obj, id, &desc)) - return fail(jsapi, rs); - - if (!fromDescriptor(cx, desc, out)) - return fail(jsapi, rs); - - return ok(rs); -} - bool WrapperAnswer::RecvGetOwnPropertyDescriptor(const ObjectId& objId, const JSIDVariant& idVar, ReturnStatus* rs, PPropertyDescriptor* out) diff --git a/js/ipc/WrapperAnswer.h b/js/ipc/WrapperAnswer.h index 4df7b08ae5d6..a83408804385 100644 --- a/js/ipc/WrapperAnswer.h +++ b/js/ipc/WrapperAnswer.h @@ -22,9 +22,6 @@ class WrapperAnswer : public virtual JavaScriptShared { public: bool RecvPreventExtensions(const ObjectId& objId, ReturnStatus* rs); - bool RecvGetPropertyDescriptor(const ObjectId& objId, const JSIDVariant& id, - ReturnStatus* rs, - PPropertyDescriptor* out); bool RecvGetOwnPropertyDescriptor(const ObjectId& objId, const JSIDVariant& id, ReturnStatus* rs, diff --git a/js/ipc/WrapperOwner.cpp b/js/ipc/WrapperOwner.cpp index 4d0ebb687b45..2576c4714950 100644 --- a/js/ipc/WrapperOwner.cpp +++ b/js/ipc/WrapperOwner.cpp @@ -118,8 +118,6 @@ class CPOWProxyHandler : public BaseProxyHandler virtual bool call(JSContext* cx, HandleObject proxy, const CallArgs& args) const override; virtual bool construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const override; - virtual bool getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id, - MutableHandle desc) const override; virtual bool hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const override; virtual bool getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject proxy, AutoIdVector& props) const override; @@ -160,36 +158,6 @@ const CPOWProxyHandler CPOWProxyHandler::singleton; return owner->call args; \ } -bool -CPOWProxyHandler::getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id, - MutableHandle desc) const -{ - FORWARD(getPropertyDescriptor, (cx, proxy, id, desc), false); -} - -bool -WrapperOwner::getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id, - MutableHandle desc) -{ - ObjectId objId = idOf(proxy); - - JSIDVariant idVar; - if (!toJSIDVariant(cx, id, &idVar)) - return false; - - ReturnStatus status; - PPropertyDescriptor result; - if (!SendGetPropertyDescriptor(objId, idVar, &status, &result)) - return ipcfail(cx); - - LOG_STACK(); - - if (!ok(cx, status)) - return false; - - return toDescriptor(cx, result, desc); -} - bool CPOWProxyHandler::getOwnPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id, MutableHandle desc) const diff --git a/js/ipc/WrapperOwner.h b/js/ipc/WrapperOwner.h index bb641d1266b5..382c0cb6349c 100644 --- a/js/ipc/WrapperOwner.h +++ b/js/ipc/WrapperOwner.h @@ -47,8 +47,6 @@ class WrapperOwner : public virtual JavaScriptShared bool construct); // SpiderMonkey extensions. - bool getPropertyDescriptor(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, - JS::MutableHandle desc); bool hasOwn(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, bool* bp); bool getOwnEnumerablePropertyKeys(JSContext* cx, JS::HandleObject proxy, JS::AutoIdVector& props); @@ -112,9 +110,6 @@ class WrapperOwner : public virtual JavaScriptShared public: virtual bool SendDropObject(const ObjectId& objId) = 0; virtual bool SendPreventExtensions(const ObjectId& objId, ReturnStatus* rs) = 0; - virtual bool SendGetPropertyDescriptor(const ObjectId& objId, const JSIDVariant& id, - ReturnStatus* rs, - PPropertyDescriptor* out) = 0; virtual bool SendGetOwnPropertyDescriptor(const ObjectId& objId, const JSIDVariant& id, ReturnStatus* rs, diff --git a/js/src/jit-test/tests/cacheir/typedarray-set.js b/js/src/jit-test/tests/cacheir/typedarray-set.js new file mode 100644 index 000000000000..128dd2b0802f --- /dev/null +++ b/js/src/jit-test/tests/cacheir/typedarray-set.js @@ -0,0 +1,29 @@ +// Based on work by André Bargull + +function f() { + var x = [1,2,3]; + x[3] = 0xff; + + // Should have been defined on typed array. + assertEq(x.length, 3); + assertEq(x[3], -1); + + x[3] = 0; +} + +Object.setPrototypeOf(Array.prototype, new Int8Array(4)); +f(); +f(); + +function g() { + var x = [1,2,3,4]; + x[4] = 0xff; + + // OOB [[Set]] should have been ignored + assertEq(x.length, 4); + assertEq(x[4], undefined); +} + +Object.setPrototypeOf(Array.prototype, new Int8Array(4)); +g(); +g(); diff --git a/js/src/jit/CacheIR.cpp b/js/src/jit/CacheIR.cpp index 16350bea6511..a632081a8688 100644 --- a/js/src/jit/CacheIR.cpp +++ b/js/src/jit/CacheIR.cpp @@ -3596,6 +3596,10 @@ CanAttachAddElement(NativeObject* obj, bool isInit) if (!proto->isNative()) return false; + // TypedArrayObjects [[Set]] has special behavior. + if (proto->is()) + return false; + // We have to make sure the proto has no non-writable (frozen) elements // because we're not allowed to shadow them. There are a few cases to // consider: diff --git a/js/src/vm/NativeObject.cpp b/js/src/vm/NativeObject.cpp index 442ca89c5820..db67e09043a8 100644 --- a/js/src/vm/NativeObject.cpp +++ b/js/src/vm/NativeObject.cpp @@ -1920,42 +1920,18 @@ js::NativeDefineDataProperty(JSContext* cx, HandleNativeObject obj, PropertyName return NativeDefineDataProperty(cx, obj, id, value, attrs); } - -// ES2019 draft rev e7dc63fb5d1c26beada9ffc12dc78aa6548f1fb5 -// 9.4.5.9 IntegerIndexedElementSet -static bool -DefineNonexistentTypedArrayElement(JSContext* cx, Handle obj, uint64_t index, - HandleValue v, ObjectOpResult& result) -{ - // This method is only called for non-existent properties, which - // means any absent indexed property must be out of range. - MOZ_ASSERT(index >= obj->length()); - - // Steps 1-2 are enforced by the caller. - - // Step 3. - // We still need to call ToNumber, because of its possible side - // effects. - double d; - if (!ToNumber(cx, v, &d)) - return false; - - // Steps 4-5. - // ToNumber may have detached the array buffer. - if (obj->hasDetachedBuffer()) - return result.failSoft(JSMSG_TYPED_ARRAY_DETACHED); - - // Steps 6-9. - // We (wrongly) ignore out of range defines. - return result.failSoft(JSMSG_BAD_INDEX); -} - static bool DefineNonexistentProperty(JSContext* cx, HandleNativeObject obj, HandleId id, HandleValue v, ObjectOpResult& result) { // Optimized NativeDefineProperty() version for known absent properties. +#ifdef DEBUG + // Indexed properties of typed arrays should have been handled by SetTypedArrayElement. + uint64_t index; + MOZ_ASSERT_IF(obj->is(), !IsTypedArrayIndex(id, &index)); +#endif + // Dispense with custom behavior of exotic native objects first. if (obj->is()) { // Array's length property is non-configurable, so we shouldn't @@ -1968,14 +1944,7 @@ DefineNonexistentProperty(JSContext* cx, HandleNativeObject obj, HandleId id, if (WouldDefinePastNonwritableLength(&obj->as(), index)) return result.fail(JSMSG_CANT_DEFINE_PAST_ARRAY_LENGTH); } - } else if (obj->is()) { - // 9.4.5.5 step 2. Indexed properties of typed arrays are special. - uint64_t index; - if (IsTypedArrayIndex(id, &index)) { - Rooted tobj(cx, &obj->as()); - return DefineNonexistentTypedArrayElement(cx, tobj, index, v, result); - } - } else if (obj->is()) { + } else if (obj->is()) { // If this method is called with either |length| or |@@iterator|, the // property was previously deleted and hence should already be marked // as overridden. @@ -2644,7 +2613,6 @@ SetNonexistentProperty(JSContext* cx, HandleNativeObject obj, HandleId id, Handl #endif // Step 5.e. Define the new data property. - if (DefinePropertyOp op = obj->getOpsDefineProperty()) { // Purge the property cache of now-shadowed id in receiver's environment chain. if (!ReshapeForShadowedProp(cx, obj, id)) @@ -2660,50 +2628,41 @@ SetNonexistentProperty(JSContext* cx, HandleNativeObject obj, HandleId id, Handl return DefineNonexistentProperty(cx, obj, id, v, result); } - if (IsQualified && obj->is()) { - // 9.4.5.5 step 2. Indexed properties of typed arrays are special. - uint64_t index; - if (IsTypedArrayIndex(id, &index)) { - Rooted tobj(cx, &obj->as()); - return DefineNonexistentTypedArrayElement(cx, tobj, index, v, result); - } - } - return SetPropertyByDefining(cx, id, v, receiver, result); } // ES2019 draft rev e7dc63fb5d1c26beada9ffc12dc78aa6548f1fb5 // 9.4.5.9 IntegerIndexedElementSet -// Set an existing own property obj[index] that's a typed array element. static bool -SetTypedArrayElement(JSContext* cx, Handle obj, uint32_t index, HandleValue v, +SetTypedArrayElement(JSContext* cx, Handle obj, uint64_t index, HandleValue v, ObjectOpResult& result) { - // Steps 1-2 are enforced by the caller. + // Steps 1-2. Are enforced by the caller. // Step 3. double d; if (!ToNumber(cx, v, &d)) return false; - // Steps 6-7 don't apply for existing typed array elements. + // Step 5. + if (obj->hasDetachedBuffer()) + return result.failSoft(JSMSG_TYPED_ARRAY_DETACHED); - // Steps 8-16. - // Silently do nothing for out-of-bounds sets, for consistency with - // current behavior. (ES6 currently says to throw for this in - // strict mode code, so we may eventually need to change.) - uint32_t len = obj->as().length(); - if (index < len) { - TypedArrayObject::setElement(obj->as(), index, d); - return result.succeed(); - } + // Step 6. Right now we only allow integer indexes. + // Step 7. - // Steps 4-5. - // A previously existing typed array element can only be out-of-bounds - // if the above ToNumber call detached the typed array's buffer. - MOZ_ASSERT(obj->as().hasDetachedBuffer()); + // Step 8. + uint32_t length = obj->length(); - return result.failSoft(JSMSG_TYPED_ARRAY_DETACHED); + // Step 9. + if (index >= length) + return result.failSoft(JSMSG_BAD_INDEX); + + // Steps 4, 10-15. + TypedArrayObject::setElement(*obj, index, d); + + // Step 16. + return result.succeed(); } // Set an existing own property obj[index] that's a dense element. @@ -2735,11 +2694,7 @@ SetExistingProperty(JSContext* cx, HandleId id, HandleValue v, HandleValue recei { // Step 5 for dense elements. if (prop.isDenseOrTypedArrayElement()) { - // TypedArray [[Set]] ignores the receiver completely. - if (pobj->is()) { - Rooted tobj(cx, &pobj->as()); - return SetTypedArrayElement(cx, tobj, JSID_TO_INT(id), v, result); - } + MOZ_ASSERT(!pobj->is()); // Step 5.a. if (pobj->denseElementsAreFrozen()) @@ -2808,6 +2763,17 @@ js::NativeSetProperty(JSContext* cx, HandleNativeObject obj, HandleId id, Handle if (!LookupOwnPropertyInline(cx, pobj, id, &prop, &done)) return false; + if (pobj->is()) { + uint64_t index; + if (IsTypedArrayIndex(id, &index)) { + Rooted tobj(cx, &pobj->as()); + return SetTypedArrayElement(cx, tobj, index, v, result); + } + + // This case should have been handled. + MOZ_ASSERT(!prop.isDenseOrTypedArrayElement()); + } + if (prop) { // Steps 5-6. return SetExistingProperty(cx, id, v, receiver, pobj, prop, result); diff --git a/layout/base/ZoomConstraintsClient.cpp b/layout/base/ZoomConstraintsClient.cpp index ed1fc94e950a..4ef2358a7efa 100644 --- a/layout/base/ZoomConstraintsClient.cpp +++ b/layout/base/ZoomConstraintsClient.cpp @@ -181,7 +181,7 @@ ComputeZoomConstraintsFromViewportInfo(const nsViewportInfo& aViewportInfo) { mozilla::layers::ZoomConstraints constraints; constraints.mAllowZoom = aViewportInfo.IsZoomAllowed() && gfxPrefs::APZAllowZooming(); - constraints.mAllowDoubleTapZoom = constraints.mAllowZoom; + constraints.mAllowDoubleTapZoom = constraints.mAllowZoom && gfxPrefs::APZAllowDoubleTapZooming(); if (constraints.mAllowZoom) { constraints.mMinZoom.scale = aViewportInfo.GetMinZoom().scale; constraints.mMaxZoom.scale = aViewportInfo.GetMaxZoom().scale; diff --git a/layout/base/tests/chrome/bug1041200_window.html b/layout/base/tests/chrome/bug1041200_window.html index 46acd4242fa3..ae8dcbe8a5a3 100644 --- a/layout/base/tests/chrome/bug1041200_window.html +++ b/layout/base/tests/chrome/bug1041200_window.html @@ -14,12 +14,7 @@ var SimpleTest = window.opener.wrappedJSObject.SimpleTest; var ok = window.opener.wrappedJSObject.ok; var info = window.opener.wrappedJSObject.info; -var viewer = - SpecialPowers.wrap(ourFrame).contentWindow - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell) - .contentViewer; +var viewer = SpecialPowers.wrap(ourFrame).contentWindow.docShell.contentViewer; viewer.fullZoom = 2; SimpleTest.waitForExplicitFinish(); diff --git a/layout/base/tests/chrome/file_bug1018265.xul b/layout/base/tests/chrome/file_bug1018265.xul index 05d365c95eb2..416f3d9381bd 100644 --- a/layout/base/tests/chrome/file_bug1018265.xul +++ b/layout/base/tests/chrome/file_bug1018265.xul @@ -36,8 +36,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1018265 } function getContentViewer(win) { - return win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell).contentViewer; + return win.docShell.contentViewer; } function shouldHaveTwoNonHiddenContentViewers() { diff --git a/layout/base/tests/chrome/test_bug396367-1.html b/layout/base/tests/chrome/test_bug396367-1.html index 225c4e3442ce..6d3f95d2de0e 100644 --- a/layout/base/tests/chrome/test_bug396367-1.html +++ b/layout/base/tests/chrome/test_bug396367-1.html @@ -18,8 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=396367 } function getdocviewer() { - var navigator1 = top.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation); - var docShell = navigator1.QueryInterface(Ci.nsIDocShell); + var docShell = top.docShell; var docviewer = docShell.contentViewer; return docviewer; } diff --git a/layout/base/tests/chrome/test_bug396367-2.html b/layout/base/tests/chrome/test_bug396367-2.html index bd24b5c4d144..862ed435bbd4 100644 --- a/layout/base/tests/chrome/test_bug396367-2.html +++ b/layout/base/tests/chrome/test_bug396367-2.html @@ -19,8 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=396367 } function getdocviewer() { - var navigator1 = top.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation); - var docShell = navigator1.QueryInterface(Ci.nsIDocShell); + var docShell = top.docShell; var docviewer = docShell.contentViewer; return docviewer; } diff --git a/layout/base/tests/chrome/test_bug420499.xul b/layout/base/tests/chrome/test_bug420499.xul index e9a06d7b60f8..5b98cbab83b1 100644 --- a/layout/base/tests/chrome/test_bug420499.xul +++ b/layout/base/tests/chrome/test_bug420499.xul @@ -67,10 +67,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=420499 } function isCaretVisible() { - window.QueryInterface(Ci.nsIInterfaceRequestor); - var docShell = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + var docShell = window.docShell; var selCon = docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsISelectionDisplay) .QueryInterface(Ci.nsISelectionController); diff --git a/layout/base/tests/chrome/test_bug514660.xul b/layout/base/tests/chrome/test_bug514660.xul index ba5431ec60e3..0a74691365d6 100644 --- a/layout/base/tests/chrome/test_bug514660.xul +++ b/layout/base/tests/chrome/test_bug514660.xul @@ -22,11 +22,7 @@ SimpleTest.waitForExplicitFinish(); function doTest() { - var viewer = window - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .contentViewer; + var viewer = window.docShell.contentViewer; viewer.authorStyleDisabled = true; document.documentElement.getBoundingClientRect(); diff --git a/layout/base/tests/chrome/test_bug708062.html b/layout/base/tests/chrome/test_bug708062.html index bc538a238f21..35e0217a773c 100644 --- a/layout/base/tests/chrome/test_bug708062.html +++ b/layout/base/tests/chrome/test_bug708062.html @@ -28,8 +28,7 @@ function isBoundingClientRect(e, r, msg) { function doTest() { var f = document.getElementById('f'); - var navigator1 = f.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation); - var docShell = navigator1.QueryInterface(Ci.nsIDocShell); + var docShell = f.contentWindow.docShell; var docviewer = docShell.contentViewer; var d = f.contentDocument.getElementById('d'); diff --git a/layout/base/tests/test_bug449781.html b/layout/base/tests/test_bug449781.html index ad32793b2a14..759658d6565f 100644 --- a/layout/base/tests/test_bug449781.html +++ b/layout/base/tests/test_bug449781.html @@ -37,11 +37,7 @@ addLoadEvent(function() { "got " + str1 + " but expected " + str2); var viewer = - SpecialPowers.wrap($("ourFrame")).contentWindow - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShell) - .contentViewer; + SpecialPowers.wrap($("ourFrame")).contentWindow.docShell.contentViewer; viewer.fullZoom = 2; s3 = snapshotWindow(window); diff --git a/layout/generic/test/frame_selection_underline-ref.xhtml b/layout/generic/test/frame_selection_underline-ref.xhtml index 6b0d72087744..1dd857bab57a 100644 --- a/layout/generic/test/frame_selection_underline-ref.xhtml +++ b/layout/generic/test/frame_selection_underline-ref.xhtml @@ -13,10 +13,7 @@ function init(aTest) var leftSpacer = document.getElementById("leftspacer"); var rightSpacer = document.getElementById("rightspacer"); - var docShell = - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + var docShell = window.docShell; var controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsISelectionDisplay) diff --git a/layout/generic/test/frame_selection_underline.xhtml b/layout/generic/test/frame_selection_underline.xhtml index 0be8230e9bd6..1e4f6790bb4e 100644 --- a/layout/generic/test/frame_selection_underline.xhtml +++ b/layout/generic/test/frame_selection_underline.xhtml @@ -8,10 +8,7 @@ function init(aTest) { - var docShell = - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + var docShell = window.docShell; var controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsISelectionDisplay) @@ -48,4 +45,4 @@ function init(aTest)
                                                    
- \ No newline at end of file + diff --git a/layout/generic/test/test_bug263683.html b/layout/generic/test/test_bug263683.html index 1fb72c5bcdb7..ae5e5f955800 100644 --- a/layout/generic/test/test_bug263683.html +++ b/layout/generic/test/test_bug263683.html @@ -52,8 +52,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=263683 var noHighlight = snapshotWindow(window); var controller = SpecialPowers.wrap(window). - QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). - getInterface(SpecialPowers.Ci.nsIWebNavigation). + docShell. QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). getInterface(SpecialPowers.Ci.nsISelectionDisplay). QueryInterface(SpecialPowers.Ci.nsISelectionController); diff --git a/layout/generic/test/test_selection_touchevents.html b/layout/generic/test/test_selection_touchevents.html index 5c444758a305..9d5da81b55c6 100644 --- a/layout/generic/test/test_selection_touchevents.html +++ b/layout/generic/test/test_selection_touchevents.html @@ -30,9 +30,7 @@ function test() var cwu = SpecialPowers.getDOMWindowUtils(window); cwu.sendMouseEventToWindow("mousedown", rect.left + rect.width/2, rect.top + rect.height/2, 0, 0, 0, true); cwu.sendMouseEventToWindow("mouseup", rect.left + rect.width/2, rect.top + rect.height/2, 0, 0, 0, true); - var selectionController = SpecialPowers.wrap(window). - QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIWebNavigation). + var selectionController = SpecialPowers.wrap(window).docShell. QueryInterface(Ci.nsIInterfaceRequestor). getInterface(Ci.nsISelectionDisplay). QueryInterface(Ci.nsISelectionController); @@ -54,4 +52,4 @@ SimpleTest.waitForExplicitFinish(); - \ No newline at end of file + diff --git a/layout/mathml/crashtests/400157.xhtml b/layout/mathml/crashtests/400157.xhtml index 78754875da1d..6eebc0ab24f5 100644 --- a/layout/mathml/crashtests/400157.xhtml +++ b/layout/mathml/crashtests/400157.xhtml @@ -5,8 +5,7 @@ - -
- - - -
a - -
- - diff --git a/testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/span-limits.html b/testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/span-limits.html index 0bc986281a41..cdfa61bbcdc0 100644 --- a/testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/span-limits.html +++ b/testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/span-limits.html @@ -23,6 +23,12 @@ + + +
a + +
+ diff --git a/testing/web-platform/tests/webdriver/tests/new_session/conftest.py b/testing/web-platform/tests/webdriver/tests/new_session/conftest.py index 74563f7b8661..bf974ab1c000 100644 --- a/testing/web-platform/tests/webdriver/tests/new_session/conftest.py +++ b/testing/web-platform/tests/webdriver/tests/new_session/conftest.py @@ -1,5 +1,3 @@ -import sys - import pytest from webdriver.transport import HTTPWireProtocol @@ -66,13 +64,3 @@ def fixture_new_session(request, configuration, current_session): if custom_session.get("session") is not None: _delete_session(custom_session["session"]["sessionId"]) custom_session = None - - -@pytest.fixture(scope="session") -def platform_name(): - return { - "linux2": "linux", - "win32": "windows", - "cygwin": "windows", - "darwin": "mac" - }.get(sys.platform) diff --git a/testing/web-platform/tests/webdriver/tests/new_session/merge.py b/testing/web-platform/tests/webdriver/tests/new_session/merge.py index d4b4ee563882..857d289fcaf0 100644 --- a/testing/web-platform/tests/webdriver/tests/new_session/merge.py +++ b/testing/web-platform/tests/webdriver/tests/new_session/merge.py @@ -3,13 +3,13 @@ import pytest from tests.support.asserts import assert_error, assert_success -from conftest import platform_name +from tests.support import platform_name -@pytest.mark.skipif(platform_name() is None, reason="Unsupported platform") +@pytest.mark.skipif(platform_name is None, reason="Unsupported platform {}".format(platform_name)) @pytest.mark.parametrize("body", [lambda key, value: {"alwaysMatch": {key: value}}, lambda key, value: {"firstMatch": [{key: value}]}]) -def test_platform_name(new_session, add_browser_capabilities, platform_name, body): +def test_platform_name(new_session, add_browser_capabilities, body): capabilities = body("platformName", platform_name) if "alwaysMatch" in capabilities: capabilities["alwaysMatch"] = add_browser_capabilities(capabilities["alwaysMatch"]) @@ -40,8 +40,8 @@ def test_merge_invalid(new_session, add_browser_capabilities, key, value): assert_error(response, "invalid argument") -@pytest.mark.skipif(platform_name() is None, reason="Unsupported platform") -def test_merge_platformName(new_session, add_browser_capabilities, platform_name): +@pytest.mark.skipif(platform_name is None, reason="Unsupported platform {}".format(platform_name)) +def test_merge_platformName(new_session, add_browser_capabilities): response, _ = new_session({"capabilities": { "alwaysMatch": add_browser_capabilities({"timeouts": {"script": 10}}), "firstMatch": [{ diff --git a/testing/web-platform/tests/webdriver/tests/new_session/page_load_strategy.py b/testing/web-platform/tests/webdriver/tests/new_session/page_load_strategy.py new file mode 100644 index 000000000000..69288ef43335 --- /dev/null +++ b/testing/web-platform/tests/webdriver/tests/new_session/page_load_strategy.py @@ -0,0 +1,7 @@ +from tests.support.asserts import assert_success + +def test_pageLoadStrategy(new_session, add_browser_capabilities): + response, _ = new_session({"capabilities": { + "alwaysMatch": add_browser_capabilities({"pageLoadStrategy": "eager"})}}) + value = assert_success(response) + assert value["capabilities"]["pageLoadStrategy"] == "eager" diff --git a/testing/web-platform/tests/webdriver/tests/new_session/platform_name.py b/testing/web-platform/tests/webdriver/tests/new_session/platform_name.py new file mode 100644 index 000000000000..0504f04259d8 --- /dev/null +++ b/testing/web-platform/tests/webdriver/tests/new_session/platform_name.py @@ -0,0 +1,11 @@ +import pytest + +from tests.support import platform_name +from tests.support.asserts import assert_success + + +@pytest.mark.skip_if(platform_name is None, reason="Unsupported platform {}".format(platform_name)) +def test_corresponds_to_local_system(new_session, add_browser_capabilities): + response, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilities({})}}) + value = assert_success(response) + assert value["capabilities"]["platformName"] == platform_name diff --git a/testing/web-platform/tests/webdriver/tests/new_session/response.py b/testing/web-platform/tests/webdriver/tests/new_session/response.py index e3b096abb9c0..3e8520718237 100644 --- a/testing/web-platform/tests/webdriver/tests/new_session/response.py +++ b/testing/web-platform/tests/webdriver/tests/new_session/response.py @@ -1,7 +1,7 @@ -# META: timeout=long - import uuid +import pytest + from tests.support.asserts import assert_success @@ -12,63 +12,32 @@ def test_sessionid(new_session, add_browser_capabilities): uuid.UUID(hex=value["sessionId"]) -def test_capabilites(new_session, add_browser_capabilities): - response, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilities({})}}) - value = assert_success(response) - assert isinstance(value["capabilities"], dict) - - all_capabilities = set(value["capabilities"].keys()) - expected_capabilities = { - "browserName", - "browserVersion", - "platformName", - "acceptInsecureCerts", - "setWindowRect", - "timeouts", - "proxy", - "pageLoadStrategy", - } - - assert expected_capabilities.issubset(all_capabilities), ( - "{0} cannot be found in {1}".format( - list(expected_capabilities - all_capabilities), all_capabilities)) +@pytest.mark.parametrize("capability, type", [ + ("browserName", basestring), + ("browserVersion", basestring), + ("platformName", basestring), + ("acceptInsecureCerts", bool), + ("pageLoadStrategy", basestring), + ("proxy", dict), + ("setWindowRect", bool), + ("timeouts", dict), + ("unhandledPromptBehavior", basestring), +]) +def test_capability_type(session, capability, type): + assert isinstance(session.capabilities, dict) + assert capability in session.capabilities + assert isinstance(session.capabilities[capability], type) -def test_data(new_session, add_browser_capabilities, platform_name): - response, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilities({})}}) - value = assert_success(response) - - assert isinstance(value["capabilities"]["browserName"], basestring) - assert isinstance(value["capabilities"]["browserVersion"], basestring) - if platform_name: - assert value["capabilities"]["platformName"] == platform_name - else: - assert "platformName" in value["capabilities"] - assert value["capabilities"]["acceptInsecureCerts"] is False - assert isinstance(value["capabilities"]["setWindowRect"], bool) - assert value["capabilities"]["timeouts"]["implicit"] == 0 - assert value["capabilities"]["timeouts"]["pageLoad"] == 300000 - assert value["capabilities"]["timeouts"]["script"] == 30000 - assert value["capabilities"]["proxy"] == {} - assert value["capabilities"]["pageLoadStrategy"] == "normal" - - -def test_timeouts(new_session, add_browser_capabilities, platform_name): - response, _ = new_session({"capabilities": { - "alwaysMatch": add_browser_capabilities({"timeouts": {"implicit": 1000}}), - }}) - value = assert_success(response) - - assert value["capabilities"]["timeouts"] == { - "implicit": 1000, - "pageLoad": 300000, - "script": 30000 - } - - -def test_pageLoadStrategy(new_session, add_browser_capabilities, platform_name): - response, _ = new_session({"capabilities": { - "alwaysMatch": add_browser_capabilities({"pageLoadStrategy": "eager"})}}) - value = assert_success(response) - - assert value["capabilities"]["pageLoadStrategy"] == "eager" +@pytest.mark.parametrize("capability, default_value", [ + ("acceptInsecureCerts", False), + ("pageLoadStrategy", "normal"), + ("proxy", {}), + ("setWindowRect", True), + ("timeouts", {"implicit": 0, "pageLoad": 300000, "script": 30000}), + ("unhandledPromptBehavior", "dismiss and notify"), +]) +def test_capability_default_value(session, capability, default_value): + assert isinstance(session.capabilities, dict) + assert capability in session.capabilities + assert session.capabilities[capability] == default_value diff --git a/testing/web-platform/tests/webdriver/tests/new_session/timeouts.py b/testing/web-platform/tests/webdriver/tests/new_session/timeouts.py new file mode 100644 index 000000000000..c5adb9396819 --- /dev/null +++ b/testing/web-platform/tests/webdriver/tests/new_session/timeouts.py @@ -0,0 +1,22 @@ +import pytest + +from tests.support.asserts import assert_success + + +def test_default_values(session): + timeouts = session.capabilities["timeouts"] + + assert timeouts["implicit"] == 0 + assert timeouts["pageLoad"] == 300000 + assert timeouts["script"] == 30000 + + +@pytest.mark.parametrize("timeouts", [ + {"implicit": 444, "pageLoad": 300000,"script": 30000}, + {"implicit": 0, "pageLoad": 444,"script": 30000}, + {"implicit": 0, "pageLoad": 300000,"script": 444}, +]) +def test_timeouts(new_session, add_browser_capabilities, timeouts): + response, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilities({"timeouts": timeouts})}}) + value = assert_success(response) + assert value["capabilities"]["timeouts"] == timeouts diff --git a/testing/web-platform/tests/webdriver/tests/support/__init__.py b/testing/web-platform/tests/webdriver/tests/support/__init__.py index d37faf6da048..e5e43c4e6551 100644 --- a/testing/web-platform/tests/webdriver/tests/support/__init__.py +++ b/testing/web-platform/tests/webdriver/tests/support/__init__.py @@ -1 +1,10 @@ +import sys + from merge_dictionaries import merge_dictionaries + +platform_name = { + "linux2": "linux", + "win32": "windows", + "cygwin": "windows", + "darwin": "mac" +}.get(sys.platform) diff --git a/testing/web-platform/tests/webrtc/RTCPeerConnection-transceivers.https.html b/testing/web-platform/tests/webrtc/RTCPeerConnection-transceivers.https.html index 3f4e50800590..49f683911e61 100644 --- a/testing/web-platform/tests/webrtc/RTCPeerConnection-transceivers.https.html +++ b/testing/web-platform/tests/webrtc/RTCPeerConnection-transceivers.https.html @@ -16,13 +16,13 @@ function createPeerConnectionWithCleanup(t) { return pc; } -async function createTrackWithCleanup(t, kind = 'audio') { +async function createTrackAndStreamWithCleanup(t, kind = 'audio') { let constraints = {}; constraints[kind] = true; const stream = await navigator.mediaDevices.getUserMedia(constraints); const [track] = stream.getTracks(); t.add_cleanup(() => track.stop()); - return track; + return [track, stream]; } function findTransceiverForSender(pc, sender) { @@ -64,8 +64,8 @@ async function exchangeAnswerAndListenToOntrack(t, pc1, pc2) { promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const sender = pc.addTrack(track); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const sender = pc.addTrack(track, stream); const transceiver = findTransceiverForSender(pc, sender); assert_true(transceiver instanceof RTCRtpTransceiver); assert_true(transceiver.sender instanceof RTCRtpSender); @@ -74,8 +74,8 @@ promise_test(async t => { promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc, pc.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc, pc.addTrack(track, stream)); assert_array_equals(pc.getTransceivers(), [transceiver], 'pc.getTransceivers() equals [transceiver]'); assert_array_equals(pc.getSenders(), [transceiver.sender], @@ -86,8 +86,8 @@ promise_test(async t => { promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc, pc.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc, pc.addTrack(track, stream)); assert_true(transceiver.sender.track instanceof MediaStreamTrack, 'transceiver.sender.track instanceof MediaStreamTrack'); assert_equals(transceiver.sender.track, track, @@ -96,8 +96,8 @@ promise_test(async t => { promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc, pc.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc, pc.addTrack(track, stream)); assert_true(transceiver.receiver instanceof RTCRtpReceiver, 'transceiver.receiver instanceof RTCRtpReceiver'); assert_true(transceiver.receiver.track instanceof MediaStreamTrack, @@ -108,51 +108,51 @@ promise_test(async t => { promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc, pc.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc, pc.addTrack(track, stream)); assert_true(transceiver.receiver.track.muted); }, 'addTrack: transceiver.receiver\'s track is muted'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc, pc.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc, pc.addTrack(track, stream)); assert_equals(transceiver.mid, null); }, 'addTrack: transceiver is not associated with an m-section'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc, pc.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc, pc.addTrack(track, stream)); assert_false(transceiver.stopped); }, 'addTrack: transceiver is not stopped'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc, pc.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc, pc.addTrack(track, stream)); assert_equals(transceiver.direction, 'sendrecv'); }, 'addTrack: transceiver\'s direction is sendrecv'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc, pc.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc, pc.addTrack(track, stream)); assert_equals(transceiver.currentDirection, null); }, 'addTrack: transceiver\'s currentDirection is null'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc, pc.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc, pc.addTrack(track, stream)); await pc.setLocalDescription(await pc.createOffer()); assert_not_equals(transceiver.mid, null, 'transceiver.mid != null'); }, 'setLocalDescription(offer): transceiver gets associated with an m-section'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc, pc.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc, pc.addTrack(track, stream)); const offer = await pc.createOffer(); await pc.setLocalDescription(offer); let sdp = offer.sdp; @@ -166,7 +166,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); - pc1.addTrack(await createTrackWithCleanup(t)); + pc1.addTrack(... await createTrackAndStreamWithCleanup(t)); const pc2 = createPeerConnectionWithCleanup(t); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_true(trackEvent instanceof RTCTrackEvent, @@ -177,8 +177,8 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - pc1.addTrack(track); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + pc1.addTrack(track, stream); const pc2 = createPeerConnectionWithCleanup(t); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_true(trackEvent.track instanceof MediaStreamTrack, @@ -189,7 +189,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); - pc1.addTrack(await createTrackWithCleanup(t)); + pc1.addTrack(... await createTrackAndStreamWithCleanup(t)); const pc2 = createPeerConnectionWithCleanup(t); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_true(trackEvent.transceiver instanceof RTCRtpTransceiver, @@ -198,8 +198,8 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc1, pc1.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc1, pc1.addTrack(track, stream)); const pc2 = createPeerConnectionWithCleanup(t); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_equals(transceiver.mid, trackEvent.transceiver.mid); @@ -207,7 +207,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); - pc1.addTrack(await createTrackWithCleanup(t)); + pc1.addTrack(... await createTrackAndStreamWithCleanup(t)); const pc2 = createPeerConnectionWithCleanup(t); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); const transceiver = trackEvent.transceiver; @@ -221,7 +221,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); - pc1.addTrack(await createTrackWithCleanup(t)); + pc1.addTrack(... await createTrackAndStreamWithCleanup(t)); const pc2 = createPeerConnectionWithCleanup(t); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_equals(trackEvent.transceiver.direction, 'recvonly'); @@ -229,7 +229,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); - pc1.addTrack(await createTrackWithCleanup(t)); + pc1.addTrack(... await createTrackAndStreamWithCleanup(t)); const pc2 = createPeerConnectionWithCleanup(t); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_equals(trackEvent.transceiver.currentDirection, null); @@ -237,7 +237,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); - pc1.addTrack(await createTrackWithCleanup(t)); + pc1.addTrack(... await createTrackAndStreamWithCleanup(t)); const pc2 = createPeerConnectionWithCleanup(t); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_false(trackEvent.transceiver.stopped); @@ -245,7 +245,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); - pc1.addTrack(await createTrackWithCleanup(t)); + pc1.addTrack(... await createTrackAndStreamWithCleanup(t)); const pc2 = createPeerConnectionWithCleanup(t); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); const transceiver = trackEvent.transceiver; @@ -258,8 +258,8 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const transceiver = findTransceiverForSender(pc1, pc1.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const transceiver = findTransceiverForSender(pc1, pc1.addTrack(track, stream)); const pc2 = createPeerConnectionWithCleanup(t); await exchangeOffer(pc1, pc2); assert_equals(transceiver.currentDirection, null, @@ -271,7 +271,7 @@ promise_test(async t => { promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const transceiver = pc.addTransceiver(track); assert_true(transceiver instanceof RTCRtpTransceiver); assert_true(transceiver.sender instanceof RTCRtpSender); @@ -281,7 +281,7 @@ promise_test(async t => { promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const transceiver = pc.addTransceiver(track); assert_array_equals(pc.getTransceivers(), [transceiver], 'pc.getTransceivers() equals [transceiver]'); @@ -293,7 +293,7 @@ promise_test(async t => { promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const transceiver = pc.addTransceiver(track, {direction:'inactive'}); assert_equals(transceiver.direction, 'inactive'); }, 'addTransceiver(track, init): initialize direction to inactive'); @@ -301,7 +301,7 @@ promise_test(async t => { promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); const otherPc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const transceiver = pc.addTransceiver(track, { sendEncodings: [{active:false}] }); @@ -321,7 +321,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); const pc2 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); pc1.addTransceiver(track, {streams:[]}); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_equals(trackEvent.streams.length, 0, 'trackEvent.streams.length == 0'); @@ -330,8 +330,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); const pc2 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const stream = new MediaStream(); + const [track, stream] = await createTrackAndStreamWithCleanup(t); pc1.addTransceiver(track, {streams:[stream]}); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_equals(trackEvent.streams.length, 1, 'trackEvent.streams.length == 1'); @@ -342,7 +341,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); const pc2 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const stream0 = new MediaStream(); const stream1 = new MediaStream(); pc1.addTransceiver(track, {streams:[stream0, stream1]}); @@ -357,8 +356,8 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); const pc2 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - pc1.addTrack(track); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + pc1.addTrack(track, stream); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_equals(trackEvent.streams.length, 0, 'trackEvent.streams.length == 0'); }, 'addTrack(0 streams): ontrack fires with no stream'); @@ -366,8 +365,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); const pc2 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const stream = new MediaStream(); + const [track, stream] = await createTrackAndStreamWithCleanup(t); pc1.addTrack(track, stream); const trackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); assert_equals(trackEvent.streams.length, 1, 'trackEvent.streams.length == 1'); @@ -378,7 +376,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); const pc2 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const stream0 = new MediaStream(); const stream1 = new MediaStream(); pc1.addTrack(track, stream0, stream1); @@ -392,58 +390,58 @@ promise_test(async t => { promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const transceiver = pc.addTransceiver('audio'); assert_equals(transceiver.direction, 'sendrecv'); }, 'addTransceiver(\'audio\'): creates a transceiver with direction sendrecv'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const transceiver = pc.addTransceiver('audio'); assert_equals(transceiver.receiver.track.kind, 'audio'); }, 'addTransceiver(\'audio\'): transceiver.receiver.track.kind == \'audio\''); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const transceiver = pc.addTransceiver('video'); assert_equals(transceiver.receiver.track.kind, 'video'); }, 'addTransceiver(\'video\'): transceiver.receiver.track.kind == \'video\''); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const transceiver = pc.addTransceiver('audio'); assert_equals(transceiver.sender.track, null); }, 'addTransceiver(\'audio\'): transceiver.sender.track == null'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const transceiver = pc.addTransceiver('audio'); assert_equals(transceiver.currentDirection, null); }, 'addTransceiver(\'audio\'): transceiver.currentDirection is null'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); + const [track, stream] = await createTrackAndStreamWithCleanup(t); const transceiver = pc.addTransceiver('audio'); assert_false(transceiver.stopped); }, 'addTransceiver(\'audio\'): transceiver.stopped is false'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t, 'audio'); + const [track, stream] = await createTrackAndStreamWithCleanup(t, 'audio'); const transceiver = pc.addTransceiver('audio'); - const sender = pc.addTrack(track); + const sender = pc.addTrack(track, stream); assert_equals(sender, transceiver.sender, 'sender == transceiver.sender'); assert_equals(sender.track, track, 'sender.track == track'); }, 'addTrack reuses reusable transceivers'); promise_test(async t => { const pc = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t, 'audio'); + const [track, stream] = await createTrackAndStreamWithCleanup(t, 'audio'); const t1 = pc.addTransceiver('audio'); const t2 = pc.addTransceiver(track); assert_not_equals(t2, t1, 't2 != t1'); @@ -453,13 +451,13 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); const pc2 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t); - const pc1Transceiver = findTransceiverForSender(pc1, pc1.addTrack(track)); + const [track, stream] = await createTrackAndStreamWithCleanup(t); + const pc1Transceiver = findTransceiverForSender(pc1, pc1.addTrack(track, stream)); const pc2TrackEvent = await exchangeOfferAndListenToOntrack(t, pc1, pc2); const pc2Transceiver = pc2TrackEvent.transceiver; assert_equals(pc2Transceiver.direction, 'recvonly', 'pc2Transceiver.direction is recvonly after SRD(offer)'); - const pc2Sender = pc2.addTrack(track); + const pc2Sender = pc2.addTrack(track, stream); assert_equals(pc2Transceiver.sender, pc2Sender, 'pc2Transceiver.sender == sender'); assert_equals(pc2Transceiver.direction, 'sendrecv', @@ -468,7 +466,7 @@ promise_test(async t => { 'pc2Transceiver.currentDirection is null before answer'); const pc1TrackEvent = await exchangeAnswerAndListenToOntrack(t, pc1, pc2); assert_equals(pc2Transceiver.currentDirection, 'sendrecv', - 'pc2Transceiver.currentDirection is sendrecv after SLD(answer)'); + 'pc2Transceiver.currentDirection is sendrecv after SLD(answer)'); assert_equals(pc1TrackEvent.transceiver, pc1Transceiver, 'Answer: pc1.ontrack fires with the existing transceiver.'); assert_equals(pc1Transceiver.currentDirection, 'sendrecv', @@ -482,7 +480,7 @@ promise_test(async t => { promise_test(async t => { const pc1 = createPeerConnectionWithCleanup(t); const pc2 = createPeerConnectionWithCleanup(t); - const track = await createTrackWithCleanup(t, 'audio'); + const [track, stream] = await createTrackAndStreamWithCleanup(t, 'audio'); const transceiver = pc1.addTransceiver(track); await exchangeOffer(pc1, pc2); await exchangeAnswer(pc1, pc2); diff --git a/testing/webdriver/src/capabilities.rs b/testing/webdriver/src/capabilities.rs index 596788fce6b2..fd10ca690034 100644 --- a/testing/webdriver/src/capabilities.rs +++ b/testing/webdriver/src/capabilities.rs @@ -9,11 +9,11 @@ pub type Capabilities = BTreeMap; /// Trait for objects that can be used to inspect browser capabilities /// /// The main methods in this trait are called with a Capabilites object -/// resulting from a full set of potential capabilites for the session. -/// Given those Capabilities they return a property of the browser instance -/// that would be initiated. In many cases this will be independent of the -/// input, but in the case of e.g. browser version, it might depend on a -/// path to the binary provided as a capability. +/// resulting from a full set of potential capabilites for the session. Given +/// those Capabilities they return a property of the browser instance that +/// would be initiated. In many cases this will be independent of the input, +/// but in the case of e.g. browser version, it might depend on a path to the +/// binary provided as a capability. pub trait BrowserCapabilities { /// Set up the Capabilites object /// @@ -22,19 +22,33 @@ pub trait BrowserCapabilities { /// Name of the browser fn browser_name(&mut self, &Capabilities) -> WebDriverResult>; + /// Version number of the browser fn browser_version(&mut self, &Capabilities) -> WebDriverResult>; + /// Compare actual browser version to that provided in a version specifier /// /// Parameters are the actual browser version and the comparison string, - /// respectively. The format of the comparison string is implementation-defined. - fn compare_browser_version(&mut self, version: &str, comparison: &str) -> WebDriverResult; + /// respectively. The format of the comparison string is + /// implementation-defined. + fn compare_browser_version(&mut self, version: &str, comparison: &str) + -> WebDriverResult; + /// Name of the platform/OS fn platform_name(&mut self, &Capabilities) -> WebDriverResult>; + /// Whether insecure certificates are supported fn accept_insecure_certs(&mut self, &Capabilities) -> WebDriverResult; - fn accept_proxy(&mut self, proxy_settings: &BTreeMap, &Capabilities) -> WebDriverResult; + /// Indicates whether driver supports all of the window resizing and + /// repositioning commands. + fn set_window_rect(&mut self, &Capabilities) -> WebDriverResult; + + fn accept_proxy( + &mut self, + proxy_settings: &BTreeMap, + &Capabilities, + ) -> WebDriverResult; /// Type check custom properties /// @@ -42,11 +56,17 @@ pub trait BrowserCapabilities { /// Properties that are unrecognised must be ignored i.e. return without /// error. fn validate_custom(&self, name: &str, value: &Json) -> WebDriverResult<()>; + /// Check if custom properties are accepted capabilites /// /// Check that custom properties containing ":" are compatible with /// the implementation. - fn accept_custom(&mut self, name: &str, value: &Json, merged: &Capabilities) -> WebDriverResult; + fn accept_custom( + &mut self, + name: &str, + value: &Json, + merged: &Capabilities, + ) -> WebDriverResult; } /// Trait to abstract over various version of the new session parameters @@ -70,9 +90,11 @@ pub struct SpecNewSessionParameters { } impl SpecNewSessionParameters { - fn validate(&self, - mut capabilities: Capabilities, - browser_capabilities: &T) -> WebDriverResult { + fn validate( + &self, + mut capabilities: Capabilities, + browser_capabilities: &T, + ) -> WebDriverResult { // Filter out entries with the value `null` let null_entries = capabilities .iter() @@ -85,34 +107,37 @@ impl SpecNewSessionParameters { for (key, value) in capabilities.iter() { match &**key { - "acceptInsecureCerts" => if !value.is_boolean() { - return Err(WebDriverError::new(ErrorStatus::InvalidArgument, - format!("acceptInsecureCerts is not boolean: {}", value))) - }, - x @ "browserName" | - x @ "browserVersion" | - x @ "platformName" => if !value.is_string() { - return Err(WebDriverError::new(ErrorStatus::InvalidArgument, - format!("{} is not a string: {}", x, value))) - }, - "pageLoadStrategy" => { - try!(SpecNewSessionParameters::validate_page_load_strategy(value)) + x @ "acceptInsecureCerts" | x @ "setWindowRect" => if !value.is_boolean() { + return Err(WebDriverError::new( + ErrorStatus::InvalidArgument, + format!("{} is not boolean: {}", x, value), + )); + }, + x @ "browserName" | x @ "browserVersion" | x @ "platformName" => { + if !value.is_string() { + return Err(WebDriverError::new( + ErrorStatus::InvalidArgument, + format!("{} is not a string: {}", x, value), + )); + } } - "proxy" => { - try!(SpecNewSessionParameters::validate_proxy(value)) - }, - "timeouts" => { - try!(SpecNewSessionParameters::validate_timeouts(value)) - }, + "pageLoadStrategy" => SpecNewSessionParameters::validate_page_load_strategy(value)?, + "proxy" => SpecNewSessionParameters::validate_proxy(value)?, + "timeouts" => SpecNewSessionParameters::validate_timeouts(value)?, "unhandledPromptBehavior" => { - try!(SpecNewSessionParameters::validate_unhandled_prompt_behaviour(value)) + SpecNewSessionParameters::validate_unhandled_prompt_behaviour(value)? } x => { if !x.contains(":") { - return Err(WebDriverError::new(ErrorStatus::InvalidArgument, - format!("{} is not the name of a known capability or extension capability", x))) + return Err(WebDriverError::new( + ErrorStatus::InvalidArgument, + format!( + "{} is not the name of a known capability or extension capability", + x + ), + )); } else { - try!(browser_capabilities.validate_custom(x, value)); + browser_capabilities.validate_custom(x, value)? } } } @@ -458,6 +483,15 @@ impl CapabilitiesMatching for SpecNewSessionParameters { return None; } } + "setWindowRect" => { + if value.as_boolean().unwrap_or(false) && + !browser_capabilities + .set_window_rect(merged) + .unwrap_or(false) + { + return None; + } + } "proxy" => { let default = BTreeMap::new(); let proxy = value.as_object().unwrap_or(&default); diff --git a/toolkit/components/normandy/content/AboutPages.jsm b/toolkit/components/normandy/content/AboutPages.jsm index ffbb1b52b939..9ec6a008af50 100644 --- a/toolkit/components/normandy/content/AboutPages.jsm +++ b/toolkit/components/normandy/content/AboutPages.jsm @@ -21,14 +21,7 @@ var EXPORTED_SYMBOLS = ["AboutPages"]; const SHIELD_LEARN_MORE_URL_PREF = "app.normandy.shieldLearnMoreUrl"; -// Due to bug 1051238 frame scripts are cached forever, so we can't update them -// as a restartless add-on. The Math.random() is the work around for this. -const PROCESS_SCRIPT = ( - `resource://normandy-content/shield-content-process.js?${Math.random()}` -); -const FRAME_SCRIPT = ( - `resource://normandy-content/shield-content-frame.js?${Math.random()}` -); +const PROCESS_SCRIPT = "resource://normandy-content/shield-content-process.js"; /** * Class for managing an about: page that Normandy provides. Adapted from @@ -99,7 +92,6 @@ var AboutPages = { async init() { // Load scripts in content processes and tabs Services.ppmm.loadProcessScript(PROCESS_SCRIPT, true); - Services.mm.loadFrameScript(FRAME_SCRIPT, true); // Register about: pages and their listeners this.aboutStudies.register(); @@ -109,7 +101,6 @@ var AboutPages = { // Stop loading processs scripts and notify existing scripts to clean up. Services.ppmm.removeDelayedProcessScript(PROCESS_SCRIPT); Services.ppmm.broadcastAsyncMessage("Shield:ShuttingDown"); - Services.mm.removeDelayedFrameScript(FRAME_SCRIPT); Services.mm.broadcastAsyncMessage("Shield:ShuttingDown"); // Clean up about pages diff --git a/toolkit/components/normandy/content/shield-content-frame.js b/toolkit/components/normandy/content/ShieldFrameListener.jsm similarity index 83% rename from toolkit/components/normandy/content/shield-content-frame.js rename to toolkit/components/normandy/content/ShieldFrameListener.jsm index f23e90088808..f05fac983901 100644 --- a/toolkit/components/normandy/content/shield-content-frame.js +++ b/toolkit/components/normandy/content/ShieldFrameListener.jsm @@ -3,6 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +var EXPORTED_SYMBOLS = ["ShieldFrameListener"]; + /** * Listen for DOM events bubbling up from the about:studies page, and perform * privileged actions in response to them. If we need to do anything that the @@ -13,11 +15,8 @@ * is opened. */ -/* global content addMessageListener removeMessageListener sendAsyncMessage */ - ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); const frameGlobal = {}; ChromeUtils.defineModuleGetter( @@ -38,6 +37,10 @@ XPCOMUtils.defineLazyGetter(this, "gStringBundle", function() { * @implements EventListener */ class ShieldFrameListener { + constructor(mm) { + this.mm = mm; + } + handleEvent(event) { // Abort if the current page isn't about:studies. if (!this.ensureTrustedOrigin()) { @@ -46,23 +49,23 @@ class ShieldFrameListener { // We waited until after we received an event to register message listeners // in order to save resources for tabs that don't ever load about:studies. - addMessageListener("Shield:ShuttingDown", this); - addMessageListener("Shield:ReceiveStudyList", this); - addMessageListener("Shield:ReceiveStudiesEnabled", this); + this.mm.addMessageListener("Shield:ShuttingDown", this); + this.mm.addMessageListener("Shield:ReceiveStudyList", this); + this.mm.addMessageListener("Shield:ReceiveStudiesEnabled", this); switch (event.detail.action) { // Actions that require the parent process case "GetRemoteValue:StudyList": - sendAsyncMessage("Shield:GetStudyList"); + this.mm.sendAsyncMessage("Shield:GetStudyList"); break; case "RemoveStudy": - sendAsyncMessage("Shield:RemoveStudy", event.detail.data); + this.mm.sendAsyncMessage("Shield:RemoveStudy", event.detail.data); break; case "GetRemoteValue:StudiesEnabled": - sendAsyncMessage("Shield:GetStudiesEnabled"); + this.mm.sendAsyncMessage("Shield:GetStudiesEnabled"); break; case "NavigateToDataPreferences": - sendAsyncMessage("Shield:OpenDataPreferences"); + this.mm.sendAsyncMessage("Shield:OpenDataPreferences"); break; // Actions that can be performed in the content process case "GetRemoteValue:ShieldLearnMoreHref": @@ -94,7 +97,7 @@ class ShieldFrameListener { * @return {Boolean} */ ensureTrustedOrigin() { - return content.document.documentURI.startsWith("about:studies"); + return this.mm.content.document.documentURI.startsWith("about:studies"); } /** @@ -127,6 +130,8 @@ class ShieldFrameListener { return; } + let {content} = this.mm; + // Clone details and use the event class from the unprivileged context. const event = new content.document.defaultView.CustomEvent(type, { bubbles: true, @@ -136,10 +141,8 @@ class ShieldFrameListener { } onShutdown() { - removeMessageListener("Shield:SendStudyList", this); - removeMessageListener("Shield:ShuttingDown", this); - removeEventListener("Shield", this); + this.mm.removeMessageListener("Shield:SendStudyList", this); + this.mm.removeMessageListener("Shield:ShuttingDown", this); + this.mm.removeEventListener("Shield", this); } } - -addEventListener("ShieldPageEvent", new ShieldFrameListener(), false, true); diff --git a/toolkit/components/passwordmgr/LoginManagerContent.jsm b/toolkit/components/passwordmgr/LoginManagerContent.jsm index 8602c63e3328..7f7788df4087 100644 --- a/toolkit/components/passwordmgr/LoginManagerContent.jsm +++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm @@ -154,9 +154,7 @@ observer.onPrefChange(); // read initial values function messageManagerFromWindow(win) { - return win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) + return win.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIContentFrameMessageManager); } @@ -362,9 +360,7 @@ var LoginManagerContent = { } try { - let webProgress = window.QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIWebNavigation). - QueryInterface(Ci.nsIDocShell). + let webProgress = window.docShell. QueryInterface(Ci.nsIInterfaceRequestor). getInterface(Ci.nsIWebProgress); webProgress.addProgressListener(observer, diff --git a/toolkit/components/passwordmgr/LoginRecipes.jsm b/toolkit/components/passwordmgr/LoginRecipes.jsm index f9bbe9471963..c3832f34c9cd 100644 --- a/toolkit/components/passwordmgr/LoginRecipes.jsm +++ b/toolkit/components/passwordmgr/LoginRecipes.jsm @@ -234,9 +234,7 @@ var LoginRecipesContent = { } } - let mm = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) + let mm = win.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIContentFrameMessageManager); diff --git a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js index c087caac2b18..2836fdea00f5 100644 --- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js +++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js @@ -1413,10 +1413,7 @@ LoginManagerPrompter.prototype = { _getChromeWindow(aWindow) { // Handle non-e10s toolkit consumers. if (!Cu.isCrossProcessWrapper(aWindow)) { - let chromeWin = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .chromeEventHandler.ownerGlobal; + let chromeWin = aWindow.docShell.chromeEventHandler.ownerGlobal; if (!chromeWin) { return null; } diff --git a/toolkit/components/passwordmgr/test/chrome/notification_common.js b/toolkit/components/passwordmgr/test/chrome/notification_common.js index 84c0d6163459..8f1e28828969 100644 --- a/toolkit/components/passwordmgr/test/chrome/notification_common.js +++ b/toolkit/components/passwordmgr/test/chrome/notification_common.js @@ -22,11 +22,8 @@ function getPopupNotifications(aWindow) { ok(Ci != null, "Access Ci"); ok(Cc != null, "Access Cc"); - var chromeWin = SpecialPowers.wrap(aWindow) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .chromeEventHandler.ownerGlobal; + var chromeWin = + SpecialPowers.wrap(aWindow).docShell.chromeEventHandler.ownerGlobal; var popupNotifications = chromeWin.PopupNotifications; return popupNotifications; @@ -96,11 +93,8 @@ function dumpNotifications() { } // Notification bars - var chromeWin = SpecialPowers.wrap(window.top) - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .chromeEventHandler.ownerGlobal; + var chromeWin = + SpecialPowers.wrap(window.top).docShell.chromeEventHandler.ownerGlobal; var nb = chromeWin.getNotificationBox(window.top); notes = nb.allNotifications; ok(true, "Found " + notes.length + " notification bars."); diff --git a/toolkit/components/passwordmgr/test/test_xhr.html b/toolkit/components/passwordmgr/test/test_xhr.html index 400a2125079f..5724a285818f 100644 --- a/toolkit/components/passwordmgr/test/test_xhr.html +++ b/toolkit/components/passwordmgr/test/test_xhr.html @@ -71,8 +71,7 @@ function handleDialog(doc, testNum) { // be null). var win = doc.defaultView; var Ci = SpecialPowers.Ci; - var treeOwner = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation). - QueryInterface(Ci.nsIDocShellTreeItem).treeOwner; + var treeOwner = win.docShell.treeOwner; treeOwner.QueryInterface(Ci.nsIInterfaceRequestor); var flags = treeOwner.getInterface(Ci.nsIXULWindow).chromeFlags; var wbc = treeOwner.getInterface(Ci.nsIWebBrowserChrome); diff --git a/toolkit/components/passwordmgr/test/test_xml_load.html b/toolkit/components/passwordmgr/test/test_xml_load.html index 5838a0af59c3..14037a8d844a 100644 --- a/toolkit/components/passwordmgr/test/test_xml_load.html +++ b/toolkit/components/passwordmgr/test/test_xml_load.html @@ -63,8 +63,7 @@ function handleDialog(doc, testNum) { // be null). var win = doc.defaultView; var Ci = SpecialPowers.Ci; - var treeOwner = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation). - QueryInterface(Ci.nsIDocShellTreeItem).treeOwner; + var treeOwner = win.docShell.treeOwner; treeOwner.QueryInterface(Ci.nsIInterfaceRequestor); var flags = treeOwner.getInterface(Ci.nsIXULWindow).chromeFlags; var wbc = treeOwner.getInterface(Ci.nsIWebBrowserChrome); diff --git a/toolkit/components/prompts/src/nsPrompter.js b/toolkit/components/prompts/src/nsPrompter.js index c44989bfe189..77c8bb6504d2 100644 --- a/toolkit/components/prompts/src/nsPrompter.js +++ b/toolkit/components/prompts/src/nsPrompter.js @@ -288,10 +288,8 @@ var PromptUtilsTemp = { // Get the chrome window for the content window we're using. // (Unwrap because we need a non-IDL property below.) - var chromeWin = promptWin.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .chromeEventHandler.ownerGlobal.wrappedJSObject; + var chromeWin = + promptWin.docShell.chromeEventHandler.ownerGlobal.wrappedJSObject; if (chromeWin.getTabModalPromptBox) promptBox = chromeWin.getTabModalPromptBox(promptWin); @@ -353,8 +351,7 @@ function openModalWindow(domWin, uri, args) { } function openTabPrompt(domWin, tabPrompt, args) { - let docShell = domWin.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell); + let docShell = domWin.docShell; let inPermitUnload = docShell.contentViewer && docShell.contentViewer.inPermitUnload; let eventDetail = Cu.cloneInto({tabPrompt: true, inPermitUnload}, domWin); PromptUtils.fireDialogEvent(domWin, "DOMWillOpenModalDialog", null, eventDetail); @@ -428,8 +425,7 @@ function openTabPrompt(domWin, tabPrompt, args) { } function openRemotePrompt(domWin, args, tabPrompt) { - let docShell = domWin.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell); + let docShell = domWin.docShell; let messageManager = docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsITabChild) .messageManager; diff --git a/toolkit/components/satchel/nsFormAutoComplete.js b/toolkit/components/satchel/nsFormAutoComplete.js index 16dda05cf483..1d15161572db 100644 --- a/toolkit/components/satchel/nsFormAutoComplete.js +++ b/toolkit/components/satchel/nsFormAutoComplete.js @@ -40,8 +40,7 @@ function isAutocompleteDisabled(aField) { function FormHistoryClient({ formField, inputName }) { if (formField && inputName != this.SEARCHBAR_ID) { let window = formField.ownerGlobal; - let topDocShell = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) + let topDocShell = window.docShell .sameTypeRootTreeItem .QueryInterface(Ci.nsIDocShell); this.mm = topDocShell.QueryInterface(Ci.nsIInterfaceRequestor) diff --git a/toolkit/components/search/nsSearchService.js b/toolkit/components/search/nsSearchService.js index 790030cb3879..29c891965845 100644 --- a/toolkit/components/search/nsSearchService.js +++ b/toolkit/components/search/nsSearchService.js @@ -2449,8 +2449,7 @@ Engine.prototype = { let searchURI = this.getSubmission("dummy").uri; - let callbacks = options.window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + let callbacks = options.window.docShell .QueryInterface(Ci.nsILoadContext); // Using the codebase principal which is constructed by the search URI diff --git a/toolkit/components/search/nsSidebar.js b/toolkit/components/search/nsSidebar.js index 1735dc71eaf9..112619c5a7be 100644 --- a/toolkit/components/search/nsSidebar.js +++ b/toolkit/components/search/nsSidebar.js @@ -12,8 +12,7 @@ nsSidebar.prototype = { init(window) { this.window = window; try { - this.mm = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) + this.mm = window.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIContentFrameMessageManager); } catch (e) { diff --git a/toolkit/components/viewsource/content/viewSource-content.js b/toolkit/components/viewsource/content/viewSource-content.js index 523e82abe643..1b63385ef352 100644 --- a/toolkit/components/viewsource/content/viewSource-content.js +++ b/toolkit/components/viewsource/content/viewSource-content.js @@ -184,12 +184,11 @@ var ViewSourceContent = { if (outerWindowID) { let contentWindow = Services.wm.getOuterWindowWithId(outerWindowID); - let requestor = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor); + let otherDocShell = contentWindow.docShell; try { - let otherWebNav = requestor.getInterface(Ci.nsIWebNavigation); - pageDescriptor = otherWebNav.QueryInterface(Ci.nsIWebPageDescriptor) - .currentDescriptor; + pageDescriptor = otherDocShell.QueryInterface(Ci.nsIWebPageDescriptor) + .currentDescriptor; } catch (e) { // We couldn't get the page descriptor, so we'll probably end up re-retrieving // this document off of the network. diff --git a/toolkit/components/windowwatcher/test/browser_new_content_window_chromeflags.js b/toolkit/components/windowwatcher/test/browser_new_content_window_chromeflags.js index 2ea08da98946..c3d0b5497cf7 100644 --- a/toolkit/components/windowwatcher/test/browser_new_content_window_chromeflags.js +++ b/toolkit/components/windowwatcher/test/browser_new_content_window_chromeflags.js @@ -144,9 +144,7 @@ registerCleanupFunction(() => { * @returns int */ function getParentChromeFlags(win) { - return win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) + return win.docShell .treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIXULWindow) @@ -174,8 +172,7 @@ function getContentChromeFlags(win) { .chromeFlags; } catch (e) { // This must be a non-remote browser... - return docShell.QueryInterface(Ci.nsIDocShellTreeItem) - .treeOwner + return docShell.treeOwner .QueryInterface(Ci.nsIWebBrowserChrome) .chromeFlags; } diff --git a/toolkit/components/windowwatcher/test/browser_new_remote_window_flags.js b/toolkit/components/windowwatcher/test/browser_new_remote_window_flags.js index ae1c8ddf3b89..471929dd0c67 100644 --- a/toolkit/components/windowwatcher/test/browser_new_remote_window_flags.js +++ b/toolkit/components/windowwatcher/test/browser_new_remote_window_flags.js @@ -16,14 +16,12 @@ add_task(async function setup() { }); function assertFlags(win) { - let webNav = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation); - let loadContext = webNav.QueryInterface(Ci.nsILoadContext); - let chromeFlags = webNav.QueryInterface(Ci.nsIDocShellTreeItem) - .treeOwner - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIXULWindow) - .chromeFlags; + let docShell = win.docShell; + let loadContext = docShell.QueryInterface(Ci.nsILoadContext); + let chromeFlags = docShell.treeOwner + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIXULWindow) + .chromeFlags; Assert.ok(loadContext.useRemoteTabs, "Should be using remote tabs on the load context"); Assert.ok(chromeFlags & Ci.nsIWebBrowserChrome.CHROME_REMOTE_WINDOW, diff --git a/toolkit/components/windowwatcher/test/browser_new_sized_window.js b/toolkit/components/windowwatcher/test/browser_new_sized_window.js index 53b101e4e652..7ffea9162a84 100644 --- a/toolkit/components/windowwatcher/test/browser_new_sized_window.js +++ b/toolkit/components/windowwatcher/test/browser_new_sized_window.js @@ -43,10 +43,7 @@ function test_dimensions({ width, height}) { Assert.equal(rect.height, height, "Should have the requested height"); } - let treeOwner = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIDocShellTreeItem) - .treeOwner; + let treeOwner = win.docShell.treeOwner; let persistPosition = {}; let persistSize = {}; let persistSizeMode = {}; diff --git a/toolkit/components/windowwatcher/test/test_blank_named_window.html b/toolkit/components/windowwatcher/test/test_blank_named_window.html index 224a60d9bfd3..5ff48f24b29d 100644 --- a/toolkit/components/windowwatcher/test/test_blank_named_window.html +++ b/toolkit/components/windowwatcher/test/test_blank_named_window.html @@ -26,11 +26,7 @@ name result in new windows being opened. let win1 = window.open("data:text/html,

This is window 1 for test_blank_named_window.html

", "_blank"); - let name = SpecialPowers.wrap(win1) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShellTreeItem) - .name; + let name = SpecialPowers.wrap(win1).docShell.name; is(name, "", "Should have no name"); diff --git a/toolkit/components/windowwatcher/test/test_modal_windows.html b/toolkit/components/windowwatcher/test/test_modal_windows.html index 60e117e979e6..7596a29dd73f 100644 --- a/toolkit/components/windowwatcher/test/test_modal_windows.html +++ b/toolkit/components/windowwatcher/test/test_modal_windows.html @@ -19,10 +19,7 @@ that is opened reports itself as being modal. add_task(async function() { BrowserTestUtils.domWindowOpened().then((win) => { - let treeOwner = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) - .treeOwner; + let treeOwner = win.docShell.treeOwner; let chromeFlags = treeOwner.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIXULWindow) .chromeFlags; diff --git a/toolkit/components/windowwatcher/test/test_named_window.html b/toolkit/components/windowwatcher/test/test_named_window.html index 07626904cbd6..58df085bf576 100644 --- a/toolkit/components/windowwatcher/test/test_named_window.html +++ b/toolkit/components/windowwatcher/test/test_named_window.html @@ -56,11 +56,7 @@ window. let win1 = window.open(TARGET_URL, "my_window"); await promiseEvent(win1, "load"); - let name = SpecialPowers.wrap(win1) - .QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor) - .getInterface(SpecialPowers.Ci.nsIWebNavigation) - .QueryInterface(SpecialPowers.Ci.nsIDocShellTreeItem) - .name; + let name = SpecialPowers.wrap(win1).docShell.name; is(name, NAME, "Should have the expected name"); is(win1.location.href, new URL(TARGET_URL).href, diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index b62a9e7d70a7..9007ee57c8a2 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -925,9 +925,7 @@ function copyRawDataToClipboard(button) { } function getLoadContext() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return window.docShell.QueryInterface(Ci.nsILoadContext); } function copyContentsToClipboard() { diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index d1544c8555d7..87268594a2b2 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -37,6 +37,18 @@ XPCOMUtils.defineLazyProxy(this, "PopupBlocking", () => { return new tmp.PopupBlocking(global); }); +XPCOMUtils.defineLazyProxy(this, "ShieldFrameListener", () => { + let tmp = {}; + ChromeUtils.import("resource://normandy-content/ShieldFrameListener.jsm", tmp); + return new tmp.ShieldFrameListener(global); +}); + +XPCOMUtils.defineLazyProxy(this, "UITourListener", () => { + let tmp = {}; + ChromeUtils.import("resource:///modules/ContentUITour.jsm", tmp); + return new tmp.UITourListener(global); +}); + XPCOMUtils.defineLazyProxy(this, "SelectionSourceContent", "resource://gre/modules/SelectionSourceContent.jsm"); @@ -534,3 +546,7 @@ let ExtFind = { }; ExtFind.init(); + +addEventListener("ShieldPageEvent", ShieldFrameListener, false, true); + +addEventListener("mozUITour", UITourListener, false, true); diff --git a/toolkit/content/contentAreaUtils.js b/toolkit/content/contentAreaUtils.js index 85d9e477e1be..0c34a6d94153 100644 --- a/toolkit/content/contentAreaUtils.js +++ b/toolkit/content/contentAreaUtils.js @@ -212,7 +212,7 @@ function saveDocument(aDocument, aSkipPrompt) { try { let shEntry = - win.getInterface(Ci.nsIWebNavigation) + win.docShell .QueryInterface(Ci.nsIWebPageDescriptor) .currentDescriptor .QueryInterface(Ci.nsISHEntry); @@ -761,8 +761,7 @@ function DownloadURL(aURL, aFileName, aInitiatingDocument) { // For private browsing, try to get document out of the most recent browser // window, or provide our own if there's no browser window. let isPrivate = aInitiatingDocument.defaultView - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + .docShell .QueryInterface(Ci.nsILoadContext) .usePrivateBrowsing; @@ -891,8 +890,7 @@ function getPostData(aDocument) { // returns a session history entry. let sessionHistoryEntry = aDocument.defaultView - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + .docShell .QueryInterface(Ci.nsIWebPageDescriptor) .currentDescriptor .QueryInterface(Ci.nsISHEntry); diff --git a/toolkit/content/process-content.js b/toolkit/content/process-content.js index 1a48d4edf9c7..107871264cbe 100644 --- a/toolkit/content/process-content.js +++ b/toolkit/content/process-content.js @@ -57,8 +57,7 @@ let ProcessObserver = { // Get the frame message manager for this window so we can associate this // page with a browser element - let messageManager = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) + let messageManager = window.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIContentFrameMessageManager); diff --git a/toolkit/content/tests/browser/browser_bug451286.js b/toolkit/content/tests/browser/browser_bug451286.js index 827284635608..94085b48493d 100644 --- a/toolkit/content/tests/browser/browser_bug451286.js +++ b/toolkit/content/tests/browser/browser_bug451286.js @@ -53,9 +53,7 @@ add_task(async function() { let range = iframe.contentDocument.createRange(); range.selectNodeContents(ifBody.childNodes[0]); let ifWindow = iframe.contentWindow; - let ifDocShell = ifWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let ifDocShell = ifWindow.docShell; let ifController = ifDocShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsISelectionDisplay) @@ -67,9 +65,7 @@ add_task(async function() { // Create manual highlights in the main document (the matches that lie // before/after the iframes - let docShell = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docShell = win.docShell; let controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsISelectionDisplay) diff --git a/toolkit/content/tests/chrome/bug263683_window.xul b/toolkit/content/tests/chrome/bug263683_window.xul index 47d8799ce6c1..3c68a4a23e2e 100644 --- a/toolkit/content/tests/chrome/bug263683_window.xul +++ b/toolkit/content/tests/chrome/bug263683_window.xul @@ -163,10 +163,7 @@ // Check the iframe too: let frame = content.document.getElementById("leframe"); // Hoops! Get the docShell first, then the selection. - selection = getSelection(frame.contentWindow - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell)); + selection = getSelection(frame.contentWindow.docShell); Assert.equal(selection.rangeCount, 1, "Correctly added a match to the selection type"); Assert.equal(selection.getRangeAt(0).toString().toLowerCase(), @@ -192,10 +189,7 @@ // Check the iframe too: let frame = content.document.getElementById("leframe"); // Hoops! Get the docShell first, then the selection. - selection = getSelection(frame.contentWindow - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell)); + selection = getSelection(frame.contentWindow.docShell); Assert.equal(selection.rangeCount, 0, "Correctly removed the range"); content.document.documentElement.focus(); diff --git a/toolkit/content/tests/chrome/bug304188_window.xul b/toolkit/content/tests/chrome/bug304188_window.xul index 9df82bf395f0..c8d25193be93 100644 --- a/toolkit/content/tests/chrome/bug304188_window.xul +++ b/toolkit/content/tests/chrome/bug304188_window.xul @@ -59,8 +59,7 @@ find-menu appears in editor element which has had makeEditable() called but desi async function onDocumentLoaded() { await ContentTask.spawn(gBrowser, null, async function() { - var edsession = content.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + var edsession = content.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIEditingSession); edsession.makeWindowEditable(content, "html", false, true, false); diff --git a/toolkit/content/tests/chrome/findbar_window.xul b/toolkit/content/tests/chrome/findbar_window.xul index f0d896ec9e85..7956bf2f39e6 100644 --- a/toolkit/content/tests/chrome/findbar_window.xul +++ b/toolkit/content/tests/chrome/findbar_window.xul @@ -64,9 +64,7 @@ function onLoad() { (async function() { - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) + window.docShell .treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIXULWindow) diff --git a/toolkit/content/tests/chrome/test_arrowpanel.xul b/toolkit/content/tests/chrome/test_arrowpanel.xul index c45dd79e08c1..ab6d276b0f8d 100644 --- a/toolkit/content/tests/chrome/test_arrowpanel.xul +++ b/toolkit/content/tests/chrome/test_arrowpanel.xul @@ -211,10 +211,7 @@ function* nextTest() function setScale(win, scale) { - var wn = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation); - var shell = wn.QueryInterface(Ci.nsIDocShell); - var docViewer = shell.contentViewer; + var docViewer = win.docShell.contentViewer; docViewer.fullZoom = scale; zoomFactor = scale; } diff --git a/toolkit/content/tests/chrome/test_popup_scaled.xul b/toolkit/content/tests/chrome/test_popup_scaled.xul index fb06d45d6771..7581b0ebbcce 100644 --- a/toolkit/content/tests/chrome/test_popup_scaled.xul +++ b/toolkit/content/tests/chrome/test_popup_scaled.xul @@ -40,10 +40,7 @@ function runTests() function setScale(win, scale) { - var wn = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation); - var shell = wn.QueryInterface(Ci.nsIDocShell); - var docViewer = shell.contentViewer; + var docViewer = win.docShell.contentViewer; docViewer.fullZoom = scale; } diff --git a/toolkit/content/tests/widgets/test_popupreflows.xul b/toolkit/content/tests/widgets/test_popupreflows.xul index e9264f772a17..c7f4052fc620 100644 --- a/toolkit/content/tests/widgets/test_popupreflows.xul +++ b/toolkit/content/tests/widgets/test_popupreflows.xul @@ -48,10 +48,7 @@ let observer = { function countReflows(testfn, expected) { return new Promise(resolve => { observer.reflows = []; - let docShell = panel.ownerGlobal - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docShell = panel.ownerGlobal.docShell; docShell.addWeakReflowObserver(observer); testfn().then(() => { docShell.removeWeakReflowObserver(observer); diff --git a/toolkit/content/widgets/findbar.xml b/toolkit/content/widgets/findbar.xml index 035b9508dc9e..fba682557fb2 100644 --- a/toolkit/content/widgets/findbar.xml +++ b/toolkit/content/widgets/findbar.xml @@ -791,9 +791,7 @@ if (!this._xulBrowserWindow) { try { this._xulBrowserWindow = - window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem) + window.docShell .treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIXULWindow) diff --git a/toolkit/modules/BrowserUtils.jsm b/toolkit/modules/BrowserUtils.jsm index d040cfacae2a..42c8be3d4187 100644 --- a/toolkit/modules/BrowserUtils.jsm +++ b/toolkit/modules/BrowserUtils.jsm @@ -559,12 +559,10 @@ var BrowserUtils = { // Iterates through every docshell in the window and calls PermitUnload. canCloseWindow(window) { - let docShell = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation); - let node = docShell.QueryInterface(Ci.nsIDocShellTreeItem); - for (let i = 0; i < node.childCount; ++i) { - let docShell = node.getChildAt(i).QueryInterface(Ci.nsIDocShell); - let contentViewer = docShell.contentViewer; + let docShell = window.docShell; + for (let i = 0; i < docShell.childCount; ++i) { + let childShell = docShell.getChildAt(i).QueryInterface(Ci.nsIDocShell); + let contentViewer = childShell.contentViewer; if (contentViewer && !contentViewer.permitUnload()) { return false; } diff --git a/toolkit/modules/E10SUtils.jsm b/toolkit/modules/E10SUtils.jsm index 043e3e4833da..1863cc0f4588 100644 --- a/toolkit/modules/E10SUtils.jsm +++ b/toolkit/modules/E10SUtils.jsm @@ -258,7 +258,7 @@ var E10SUtils = { shouldLoadURI(aDocShell, aURI, aReferrer, aHasPostData) { // Inner frames should always load in the current process - if (aDocShell.QueryInterface(Ci.nsIDocShellTreeItem).sameTypeParent) + if (aDocShell.sameTypeParent) return true; // If we are in a Large-Allocation process, and it wouldn't be content visible diff --git a/toolkit/modules/Finder.jsm b/toolkit/modules/Finder.jsm index 5680a7b1b102..3944cfab075a 100644 --- a/toolkit/modules/Finder.jsm +++ b/toolkit/modules/Finder.jsm @@ -130,8 +130,7 @@ Finder.prototype = { get clipboardSearchString() { return GetClipboardSearchString(this._getWindow() - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + .docShell .QueryInterface(Ci.nsILoadContext)); }, @@ -571,9 +570,7 @@ Finder.prototype = { } // Yuck. See bug 138068. - let docShell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docShell = aWindow.docShell; let controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsISelectionDisplay) diff --git a/toolkit/modules/FinderIterator.jsm b/toolkit/modules/FinderIterator.jsm index 20ad2d0f7af9..6131250b1e47 100644 --- a/toolkit/modules/FinderIterator.jsm +++ b/toolkit/modules/FinderIterator.jsm @@ -606,9 +606,7 @@ var FinderIterator = { // Ranges may also be passed in, so fetch its window. if (ChromeUtils.getClassName(windowOrRange) === "Range") window = windowOrRange.startContainer.ownerGlobal; - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + return window.docShell; }, /** diff --git a/toolkit/modules/InlineSpellChecker.jsm b/toolkit/modules/InlineSpellChecker.jsm index 7c2ed7b01456..ef9d907e85df 100644 --- a/toolkit/modules/InlineSpellChecker.jsm +++ b/toolkit/modules/InlineSpellChecker.jsm @@ -419,8 +419,7 @@ var SpellCheckHelper = { if (win) { var isSpellcheckable = false; try { - var editingSession = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + var editingSession = win.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIEditingSession); if (editingSession.windowIsEditable(win) && diff --git a/toolkit/modules/InlineSpellCheckerContent.jsm b/toolkit/modules/InlineSpellCheckerContent.jsm index ef7f1cbd1826..66f85eb64f0e 100644 --- a/toolkit/modules/InlineSpellCheckerContent.jsm +++ b/toolkit/modules/InlineSpellCheckerContent.jsm @@ -21,8 +21,7 @@ var InlineSpellCheckerContent = { if (!(editFlags & (SpellCheckHelper.TEXTAREA | SpellCheckHelper.INPUT))) { // Get the editor off the window. let win = event.target.ownerGlobal; - let editingSession = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + let editingSession = win.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIEditingSession); spellChecker = this._spellChecker = diff --git a/toolkit/modules/PageMetadata.jsm b/toolkit/modules/PageMetadata.jsm index 97535499ffec..af582343286f 100644 --- a/toolkit/modules/PageMetadata.jsm +++ b/toolkit/modules/PageMetadata.jsm @@ -54,9 +54,7 @@ var PageMetadata = { // pushState. In that case, we'll only return uri and title. If document is // via XHR or something, there is no view or history. if (document.defaultView) { - let docshell = document.defaultView.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell); + let docshell = document.defaultView.docShell; let shentry = {}; if (docshell.getCurrentSHEntry(shentry) && shentry.value && shentry.value.URIWasModified) { diff --git a/toolkit/modules/PrivateBrowsingUtils.jsm b/toolkit/modules/PrivateBrowsingUtils.jsm index 0b67b820c747..1ab60eb846ad 100644 --- a/toolkit/modules/PrivateBrowsingUtils.jsm +++ b/toolkit/modules/PrivateBrowsingUtils.jsm @@ -53,9 +53,7 @@ var PrivateBrowsingUtils = { }, privacyContextFromWindow: function pbu_privacyContextFromWindow(aWindow) { - return aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return aWindow.docShell.QueryInterface(Ci.nsILoadContext); }, addToTrackingAllowlist(aURI) { diff --git a/toolkit/modules/Troubleshoot.jsm b/toolkit/modules/Troubleshoot.jsm index 23eb146f3a26..49bc0dc9376b 100644 --- a/toolkit/modules/Troubleshoot.jsm +++ b/toolkit/modules/Troubleshoot.jsm @@ -189,9 +189,7 @@ var dataProviders = { let winEnumer = Services.wm.getEnumerator("navigator:browser"); while (winEnumer.hasMoreElements()) { data.numTotalWindows++; - let remote = winEnumer.getNext(). - QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIWebNavigation). + let remote = winEnumer.getNext().docShell. QueryInterface(Ci.nsILoadContext). useRemoteTabs; if (remote) { diff --git a/toolkit/modules/addons/WebRequestContent.js b/toolkit/modules/addons/WebRequestContent.js index 6fbab3495869..bd709bfdcdf0 100644 --- a/toolkit/modules/addons/WebRequestContent.js +++ b/toolkit/modules/addons/WebRequestContent.js @@ -165,9 +165,7 @@ var ContentPolicy = { } } - let ir = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIInterfaceRequestor); + let ir = window.docShell.QueryInterface(Ci.nsIInterfaceRequestor); try { // If e10s is disabled, this throws NS_NOINTERFACE for closed tabs. mm = ir.getInterface(Ci.nsIContentFrameMessageManager); diff --git a/toolkit/mozapps/downloads/DownloadLastDir.jsm b/toolkit/mozapps/downloads/DownloadLastDir.jsm index 7e7083778823..33d254c88b91 100644 --- a/toolkit/mozapps/downloads/DownloadLastDir.jsm +++ b/toolkit/mozapps/downloads/DownloadLastDir.jsm @@ -84,8 +84,7 @@ function isContentPrefEnabled() { var gDownloadLastDirFile = readLastDirPref(); function DownloadLastDir(aWindow) { - let loadContext = aWindow.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + let loadContext = aWindow.docShell .QueryInterface(Ci.nsILoadContext); // Need this in case the real thing has gone away by the time we need it. // We only care about the private browsing state. All the rest of the diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index d50b5c3b8701..a0c0d12c20fa 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -1892,10 +1892,7 @@ var AddonManagerInternal = { // main tab's browser). Check this by seeing if the browser we've been // passed is in a content type docshell and if so get the outer-browser. let topBrowser = aBrowser; - let docShell = aBrowser.ownerGlobal - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIDocShellTreeItem); + let docShell = aBrowser.ownerGlobal.docShell; if (docShell.itemType == Ci.nsIDocShellTreeItem.typeContent) topBrowser = docShell.chromeEventHandler; @@ -2590,10 +2587,7 @@ var AddonManagerInternal = { let parentWindow = null; if (browser) { // Find the outer browser - let docShell = browser.ownerGlobal - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) - .QueryInterface(Ci.nsIDocShellTreeItem); + let docShell = browser.ownerGlobal.docShell; if (docShell.itemType == Ci.nsIDocShellTreeItem.typeContent) browser = docShell.chromeEventHandler; diff --git a/toolkit/mozapps/extensions/amContentHandler.js b/toolkit/mozapps/extensions/amContentHandler.js index 31b5cf26a0e1..2cacd69ea85a 100644 --- a/toolkit/mozapps/extensions/amContentHandler.js +++ b/toolkit/mozapps/extensions/amContentHandler.js @@ -73,8 +73,7 @@ amContentHandler.prototype = { } // Fall back to sending through the message manager - let messageManager = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) + let messageManager = window.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIContentFrameMessageManager); diff --git a/toolkit/mozapps/extensions/amInstallTrigger.js b/toolkit/mozapps/extensions/amInstallTrigger.js index 512ae2ce4347..ef1afd48eb95 100644 --- a/toolkit/mozapps/extensions/amInstallTrigger.js +++ b/toolkit/mozapps/extensions/amInstallTrigger.js @@ -38,7 +38,7 @@ function RemoteMediator(window) { this._windowID = utils.currentInnerWindowID; this.mm = window - .getInterface(Ci.nsIDocShell) + .docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIContentFrameMessageManager); this.mm.addWeakMessageListener(MSG_INSTALL_CALLBACK, this); @@ -92,9 +92,7 @@ RemoteMediator.prototype = { } // Fall back to sending through the message manager - let messageManager = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) + let messageManager = window.docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIContentFrameMessageManager); diff --git a/toolkit/mozapps/extensions/amWebAPI.js b/toolkit/mozapps/extensions/amWebAPI.js index 93e939f78c13..3373e29f5135 100644 --- a/toolkit/mozapps/extensions/amWebAPI.js +++ b/toolkit/mozapps/extensions/amWebAPI.js @@ -204,8 +204,7 @@ class WebAPI extends APIObject { init(window) { let mm = window - .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) + .docShell .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIContentFrameMessageManager); let broker = new APIBroker(mm); diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index e49ca7fdfdd6..ebf43d4286c4 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -280,9 +280,7 @@ function getMainWindow() { } function getBrowserElement() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell) - .chromeEventHandler; + return window.docShell.chromeEventHandler; } /** @@ -291,20 +289,20 @@ function getBrowserElement() { */ var HTML5History = { get index() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + return window.docShell + .QueryInterface(Ci.nsIWebNavigation) .sessionHistory.index; }, get canGoBack() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + return window.docShell + .QueryInterface(Ci.nsIWebNavigation) .canGoBack; }, get canGoForward() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) + return window.docShell + .QueryInterface(Ci.nsIWebNavigation) .canGoForward; }, @@ -407,8 +405,8 @@ var FakeHistory = { // If the window has a session history then use the HTML5 History wrapper // otherwise use our fake history implementation -if (window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) +if (window.docShell + .QueryInterface(Ci.nsIWebNavigation) .sessionHistory) { var gHistory = HTML5History; } else { @@ -1895,9 +1893,7 @@ var gHeader = { }, get shouldShowNavButtons() { - var docshellItem = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShellTreeItem); + var docshellItem = window.docShell; // If there is no outer frame then make the buttons visible if (docshellItem.rootTreeItem == docshellItem) diff --git a/toolkit/mozapps/extensions/content/extensions.xml b/toolkit/mozapps/extensions/content/extensions.xml index ad188400e159..34cfbfd194e0 100644 --- a/toolkit/mozapps/extensions/content/extensions.xml +++ b/toolkit/mozapps/extensions/content/extensions.xml @@ -460,8 +460,7 @@ } let subject = { wrappedJSObject: { - target: window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIDocShell).chromeEventHandler, + target: window.docShell.chromeEventHandler, info: { addon: info.addon, source: "AMO", diff --git a/uriloader/exthandler/tests/mochitest/handlerApps.js b/uriloader/exthandler/tests/mochitest/handlerApps.js index 83785800fd08..de5f787f402d 100644 --- a/uriloader/exthandler/tests/mochitest/handlerApps.js +++ b/uriloader/exthandler/tests/mochitest/handlerApps.js @@ -24,10 +24,7 @@ function test() { // create a window, and launch the handler in it var newWindow = window.open("", "handlerWindow", "height=300,width=300"); - var windowContext = - SpecialPowers.wrap(newWindow).QueryInterface(SpecialPowers.Ci.nsIInterfaceRequestor). - getInterface(SpecialPowers.Ci.nsIWebNavigation). - QueryInterface(SpecialPowers.Ci.nsIDocShell); + var windowContext = SpecialPowers.wrap(newWindow).docShell; webHandler.launchWithURI(uri, windowContext); diff --git a/widget/nsITransferable.idl b/widget/nsITransferable.idl index 5a6178ce1202..b0cf65d49a34 100644 --- a/widget/nsITransferable.idl +++ b/widget/nsITransferable.idl @@ -110,8 +110,7 @@ interface nsITransferable : nsISupports * to the document that the transferable corresponds to, and then get the load * context from the document like this: * - * var loadContext = doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor) - * .getInterface(Ci.nsIWebNavigation) + * var loadContext = doc.defaultView.docShell * .QueryInterface(Ci.nsILoadContext); * * In C++ callers, if you have the corresponding document, you can just call diff --git a/widget/tests/test_bug444800.xul b/widget/tests/test_bug444800.xul index 055935629959..7ab2374b9439 100644 --- a/widget/tests/test_bug444800.xul +++ b/widget/tests/test_bug444800.xul @@ -40,9 +40,7 @@ function copyImageToClipboard() } function getLoadContext() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return window.docShell.QueryInterface(Ci.nsILoadContext); } function runImageClipboardTests(aCBSvc, aImageType) diff --git a/widget/tests/test_bug466599.xul b/widget/tests/test_bug466599.xul index 88edee583b55..a90fa5ebba37 100644 --- a/widget/tests/test_bug466599.xul +++ b/widget/tests/test_bug466599.xul @@ -24,9 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=466599 /** Test for Bug 466599 **/ function getLoadContext() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return window.docShell.QueryInterface(Ci.nsILoadContext); } function copyToClipboard(txt) diff --git a/widget/tests/test_bug565392.html b/widget/tests/test_bug565392.html index d09743c1c72f..b27aa7307514 100644 --- a/widget/tests/test_bug565392.html +++ b/widget/tests/test_bug565392.html @@ -26,9 +26,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=565392 .getService(Ci.nsIClipboard); function getLoadContext() { - return window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsILoadContext); + return window.docShell.QueryInterface(Ci.nsILoadContext); } function getTransferableFile(file) { diff --git a/widget/tests/test_bug673301.xul b/widget/tests/test_bug673301.xul index ac765a8cd0a1..799066071351 100644 --- a/widget/tests/test_bug673301.xul +++ b/widget/tests/test_bug673301.xul @@ -14,9 +14,7 @@