From 1c0a1c9f3e2491351a557e989ae4f03f8a28ab51 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Tue, 21 Apr 2020 14:05:35 +0000 Subject: [PATCH] Bug 1631358 - remove traces of CPOWs from browser/, testing/ and toolkit/, r=mconley Differential Revision: https://phabricator.services.mozilla.com/D71510 --- browser/base/content/browser.js | 31 ++------------ browser/base/content/nsContextMenu.js | 4 +- .../content/test/plugins/browser_bug797677.js | 1 - browser/base/content/utilityOverlay.js | 2 - .../mochitest/tests/SimpleTest/SimpleTest.js | 2 +- toolkit/actors/FindBarChild.jsm | 38 +++++++++++++++++- .../components/thumbnails/PageThumbUtils.jsm | 16 ++------ .../browser/browser_aboutCrashesResubmit.js | 3 +- toolkit/modules/BrowserUtils.jsm | 40 ------------------- 9 files changed, 49 insertions(+), 88 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index da2ab207f1ef..71e8d0bae487 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -3142,13 +3142,8 @@ function readFromClipboard() { /** * Open the View Source dialog. * - * @param aArgsOrDocument - * Either an object or a Document. Passing a Document is deprecated, - * and is not supported with e10s. This function will throw if - * aArgsOrDocument is a CPOW. - * - * If aArgsOrDocument is an object, that object can take the - * following properties: + * @param args + * An object with the following properties: * * URL (required): * A string URL for the page we'd like to view the source of. @@ -3163,27 +3158,7 @@ function readFromClipboard() { * lineNumber (optional): * The line number to focus on once the source is loaded. */ -async function BrowserViewSourceOfDocument(aArgsOrDocument) { - let args; - - if (aArgsOrDocument instanceof Document) { - let doc = aArgsOrDocument; - // Deprecated API - callers should pass args object instead. - if (Cu.isCrossProcessWrapper(doc)) { - throw new Error( - "BrowserViewSourceOfDocument cannot accept a CPOW as a document." - ); - } - - let win = doc.defaultView; - let browser = win.docShell.chromeEventHandler; - let outerWindowID = win.windowUtils.outerWindowID; - let URL = browser.currentURI.spec; - args = { browser, outerWindowID, URL }; - } else { - args = aArgsOrDocument; - } - +async function BrowserViewSourceOfDocument(args) { // Check if external view source is enabled. If so, try it. If it fails, // fallback to internal view source. if (Services.prefs.getBoolPref("view_source.editor.external")) { diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index c4118035b129..870e33c6b4b7 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -63,8 +63,8 @@ function openContextMenu(aMessage, aBrowser, aActor) { let popup = browser.ownerDocument.getElementById("contentAreaContextMenu"); let context = nsContextMenu.contentData.context; - // The event is a CPOW that can't be passed into the native openPopupAtScreen - // function. Therefore we synthesize a new MouseEvent to propagate the + // We don't have access to the original event here, as that happened in + // another process. Therefore we synthesize a new MouseEvent to propagate the // inputSource to the subsequently triggered popupshowing event. var newEvent = document.createEvent("MouseEvent"); newEvent.initNSMouseEvent( diff --git a/browser/base/content/test/plugins/browser_bug797677.js b/browser/base/content/test/plugins/browser_bug797677.js index be9e67a54a14..d50a3e989b5e 100644 --- a/browser/base/content/test/plugins/browser_bug797677.js +++ b/browser/base/content/test/plugins/browser_bug797677.js @@ -43,7 +43,6 @@ add_task(async function() { "plugin should not have been found." ); - // simple cpows await SpecialPowers.spawn(gTestBrowser, [], function() { let plugin = content.document.getElementById("plugin"); ok(plugin, "plugin should be in the page"); diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js index c2af6b5a67ec..a7421f819033 100644 --- a/browser/base/content/utilityOverlay.js +++ b/browser/base/content/utilityOverlay.js @@ -389,8 +389,6 @@ function openLinkIn(url, where, params) { } if (where == "save") { - // TODO(1073187): propagate referrerPolicy. - // ContentClick.jsm passes isContentWindowPrivate for saveURL instead of passing a CPOW initiatingDoc if ("isContentWindowPrivate" in params) { saveURL( url, diff --git a/testing/mochitest/tests/SimpleTest/SimpleTest.js b/testing/mochitest/tests/SimpleTest/SimpleTest.js index 3f7124f89036..61f7f73daa18 100644 --- a/testing/mochitest/tests/SimpleTest/SimpleTest.js +++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js @@ -911,7 +911,7 @@ SimpleTest.waitForFocus = function(callback, targetWindow, expectBlankPage) { if (loaded && focused && !finished) { finished = true; if (isChildProcess) { - sendAsyncMessage("WaitForFocus:ChildFocused", {}, null); + sendAsyncMessage("WaitForFocus:ChildFocused", {}); } else { SimpleTest._pendingWaitForFocusCount--; SimpleTest.executeSoon(function() { diff --git a/toolkit/actors/FindBarChild.jsm b/toolkit/actors/FindBarChild.jsm index 5eca8c04cc20..f7fddb3a3644 100644 --- a/toolkit/actors/FindBarChild.jsm +++ b/toolkit/actors/FindBarChild.jsm @@ -97,7 +97,7 @@ class FindBarChild extends JSWindowActorChild { return FindBarContent.onKeypress(event); } - if (event.charCode && BrowserUtils.shouldFastFind(event.target)) { + if (event.charCode && this.shouldFastFind(event.target)) { let key = String.fromCharCode(event.charCode); if ((key == "/" || key == "'") && FindBarChild.manualFAYT) { return FindBarContent.startQuickFind(event); @@ -108,6 +108,42 @@ class FindBarChild extends JSWindowActorChild { } return null; } + + /** + * Return true if we should FAYT for this node: + * + * @param elt + * The element that is focused + */ + shouldFastFind(elt) { + if (elt) { + let win = elt.ownerGlobal; + if (elt instanceof win.HTMLInputElement && elt.mozIsTextField(false)) { + return false; + } + + if (elt.isContentEditable || win.document.designMode == "on") { + return false; + } + + if ( + elt instanceof win.HTMLTextAreaElement || + elt instanceof win.HTMLSelectElement || + elt instanceof win.HTMLObjectElement || + elt instanceof win.HTMLEmbedElement + ) { + return false; + } + + if (elt instanceof win.HTMLIFrameElement && elt.mozbrowser) { + // If we're targeting a mozbrowser iframe, it should be allowed to + // handle FastFind itself. + return false; + } + } + + return true; + } } XPCOMUtils.defineLazyPreferenceGetter( diff --git a/toolkit/components/thumbnails/PageThumbUtils.jsm b/toolkit/components/thumbnails/PageThumbUtils.jsm index 123e99644dc2..5d6a0594e8c7 100644 --- a/toolkit/components/thumbnails/PageThumbUtils.jsm +++ b/toolkit/components/thumbnails/PageThumbUtils.jsm @@ -111,9 +111,8 @@ var PageThumbUtils = { */ getContentSize(aWindow) { let utils = aWindow.windowUtils; - // aWindow may be a cpow, add exposed props security values. - let sbWidth = {}, - sbHeight = {}; + let sbWidth = {}; + let sbHeight = {}; try { utils.getScrollbarSize(false, sbWidth, sbHeight); @@ -201,9 +200,6 @@ var PageThumbUtils = { * @return Canvas with a scaled thumbnail of the window. */ createSnapshotThumbnail(aWindow, aDestCanvas, aArgs) { - if (Cu.isCrossProcessWrapper(aWindow)) { - throw new Error("Do not pass cpows here."); - } let fullScale = aArgs ? aArgs.fullScale : false; let [contentWidth, contentHeight] = this.getContentSize(aWindow); let [thumbnailWidth, thumbnailHeight] = aDestCanvas @@ -300,13 +296,9 @@ var PageThumbUtils = { * @return An array containing width, height and scale. */ determineCropSize(aWindow, aCanvas) { - if (Cu.isCrossProcessWrapper(aWindow)) { - throw new Error("Do not pass cpows here."); - } let utils = aWindow.windowUtils; - // aWindow may be a cpow, add exposed props security values. - let sbWidth = {}, - sbHeight = {}; + let sbWidth = {}; + let sbHeight = {}; try { utils.getScrollbarSize(false, sbWidth, sbHeight); diff --git a/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js b/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js index 3c3d1839ad8d..1ae3a9a40c59 100644 --- a/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js +++ b/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js @@ -102,7 +102,8 @@ function check_submit_pending(tab, crashes) { } } - // NB: Despite appearances, this doesn't use a CPOW. + // The pageshow event fortunately gets propagated to the containing + // browser across process boundaries. BrowserTestUtils.waitForEvent(browser, "pageshow", true).then( csp_pageshow ); diff --git a/toolkit/modules/BrowserUtils.jsm b/toolkit/modules/BrowserUtils.jsm index 610a7e36a716..ae257db456bb 100644 --- a/toolkit/modules/BrowserUtils.jsm +++ b/toolkit/modules/BrowserUtils.jsm @@ -211,10 +211,6 @@ var BrowserUtils = { return Services.io.newFileURI(aFile); }, - makeURIFromCPOW(aCPOWURI) { - return Services.io.newURI(aCPOWURI.spec); - }, - /** * For a given DOM element, returns its position in "screen" * coordinates. In a content process, the coordinates returned will @@ -356,42 +352,6 @@ var BrowserUtils = { ); }, - /** - * Return true if we should FAYT for this node + window (could be CPOW): - * - * @param elt - * The element that is focused - */ - shouldFastFind(elt) { - if (elt) { - let win = elt.ownerGlobal; - if (elt instanceof win.HTMLInputElement && elt.mozIsTextField(false)) { - return false; - } - - if (elt.isContentEditable || win.document.designMode == "on") { - return false; - } - - if ( - elt instanceof win.HTMLTextAreaElement || - elt instanceof win.HTMLSelectElement || - elt instanceof win.HTMLObjectElement || - elt instanceof win.HTMLEmbedElement - ) { - return false; - } - - if (elt instanceof win.HTMLIFrameElement && elt.mozbrowser) { - // If we're targeting a mozbrowser iframe, it should be allowed to - // handle FastFind itself. - return false; - } - } - - return true; - }, - /** * Returns true if we can show a find bar, including FAYT, for the specified * document location. The location must not be in a blacklist of specific