From 7edbc38b652e2c05ae0810c1f225dca74b663fb7 Mon Sep 17 00:00:00 2001 From: Mike de Boer Date: Mon, 28 Sep 2015 12:55:46 +0200 Subject: [PATCH] Backed out changeset 77b2f22f48c7 (bug 1140512) due to invalid fix. rs=me,backout. --- .../BrowserTestUtils/BrowserTestUtils.jsm | 26 ------- .../tests/SimpleTest/AsyncUtilsContent.js | 9 --- toolkit/content/tests/browser/browser.ini | 1 + .../content/tests/browser/browser_findbar.js | 77 ++++++------------- toolkit/content/widgets/findbar.xml | 19 ----- 5 files changed, 26 insertions(+), 106 deletions(-) diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm index a0f4c1780f40..c8bed4c9335a 100644 --- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -451,31 +451,5 @@ this.BrowserTestUtils = { tab.ownerDocument.defaultView.gBrowser.removeTab(tab); } }); - }, - - /** - * Version of EventUtils' `sendChar` function; it will synthesize a keypress - * event in a child process and returns a Promise that will result when the - * event was fired. Instead of a Window, a Browser object is required to be - * passed to this function. - * - * @param {String} char - * A character for the keypress event that is sent to the browser. - * @param {Browser} browser - * Browser element, must not be null. - * - * @returns {Promise} - * @resolves True if the keypress event was synthesized. - */ - sendChar(char, browser) { - return new Promise(resolve => { - let mm = browser.messageManager; - mm.addMessageListener("Test:SendCharDone", function charMsg(message) { - mm.removeMessageListener("Test:SendCharDone", charMsg); - resolve(message.data.sendCharResult); - }); - - mm.sendAsyncMessage("Test:SendChar", { char: char }); - }); } }; diff --git a/testing/mochitest/tests/SimpleTest/AsyncUtilsContent.js b/testing/mochitest/tests/SimpleTest/AsyncUtilsContent.js index 5aab894cd14e..ad2f0ac5fff4 100644 --- a/testing/mochitest/tests/SimpleTest/AsyncUtilsContent.js +++ b/testing/mochitest/tests/SimpleTest/AsyncUtilsContent.js @@ -11,10 +11,6 @@ EventUtils.window = {}; EventUtils.parent = EventUtils.window; EventUtils._EU_Ci = Components.interfaces; EventUtils._EU_Cc = Components.classes; -// EventUtils' `sendChar` function relies on the navigator to synthetize events. -EventUtils.navigator = content.document.defaultView.navigator; -EventUtils.KeyboardEvent = content.document.defaultView.KeyboardEvent; - Services.scriptloader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/EventUtils.js", EventUtils); addMessageListener("Test:SynthesizeMouse", (message) => { @@ -43,8 +39,3 @@ addMessageListener("Test:SynthesizeMouse", (message) => { let result = EventUtils.synthesizeMouseAtPoint(left, top, data.event, content); sendAsyncMessage("Test:SynthesizeMouseDone", { defaultPrevented: result }); }); - -addMessageListener("Test:SendChar", message => { - let result = EventUtils.sendChar(message.data.char, content); - sendAsyncMessage("Test:SendCharDone", { sendCharResult: result }); -}); diff --git a/toolkit/content/tests/browser/browser.ini b/toolkit/content/tests/browser/browser.ini index c449ce9f69ad..e94fe67d7f59 100644 --- a/toolkit/content/tests/browser/browser.ini +++ b/toolkit/content/tests/browser/browser.ini @@ -18,6 +18,7 @@ skip-if = e10s # Bug 1064580 [browser_f7_caret_browsing.js] skip-if = e10s [browser_findbar.js] +skip-if = e10s # Disabled for e10s: Bug ?????? - seems to be a timing issue with RemoteFinder.jsm messages coming later than the tests expect. [browser_input_file_tooltips.js] skip-if = e10s # Bug ?????? - test directly manipulates content (TypeError: doc.createElement is not a function) [browser_isSynthetic.js] diff --git a/toolkit/content/tests/browser/browser_findbar.js b/toolkit/content/tests/browser/browser_findbar.js index 9521ebee104b..6dc5a6fe995b 100644 --- a/toolkit/content/tests/browser/browser_findbar.js +++ b/toolkit/content/tests/browser/browser_findbar.js @@ -2,8 +2,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "Promise", "resource://gre/modules/Promise.jsm"); Components.utils.import("resource://gre/modules/Timer.jsm", this); -const TEST_PAGE_URI = "data:text/html;charset=utf-8,The letter s."; - /** * Makes sure that the findbar hotkeys (' and /) event listeners * are added to the system event group and do not get blocked @@ -13,7 +11,7 @@ add_task(function* test_hotkey_event_propagation() { info("Ensure hotkeys are not affected by stopPropagation."); // Opening new tab - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI); + let tab = yield promiseTestPageLoad(); let browser = gBrowser.getBrowserForTab(tab); let findbar = gBrowser.getFindBar(); @@ -25,29 +23,24 @@ add_task(function* test_hotkey_event_propagation() { is(findbar.hidden, true, "Findbar is hidden now."); gBrowser.selectedTab = tab; yield promiseFocus(); - yield BrowserTestUtils.sendChar(key, browser); + EventUtils.sendChar(key, browser.contentWindow); is(findbar.hidden, false, "Findbar should not be hidden."); yield closeFindbarAndWait(findbar); } // Stop propagation for all keyboard events. - let frameScript = () => { - const stopPropagation = e => e.stopImmediatePropagation(); - let window = content.document.defaultView; - window.removeEventListener("keydown", stopPropagation); - window.removeEventListener("keypress", stopPropagation); - window.removeEventListener("keyup", stopPropagation); - }; - - let mm = browser.messageManager; - mm.loadFrameScript("data:,(" + frameScript.toString() + ")();", false); + let window = browser.contentWindow; + let stopPropagation = function(e) { e.stopImmediatePropagation(); }; + window.addEventListener("keydown", stopPropagation, true); + window.addEventListener("keypress", stopPropagation, true); + window.addEventListener("keyup", stopPropagation, true); // Checking if findbar still appears when any hotkey is pressed. for (let key of HOTKEYS) { is(findbar.hidden, true, "Findbar is hidden now."); gBrowser.selectedTab = tab; yield promiseFocus(); - yield BrowserTestUtils.sendChar(key, browser); + EventUtils.sendChar(key, browser.contentWindow); is(findbar.hidden, false, "Findbar should not be hidden."); yield closeFindbarAndWait(findbar); } @@ -58,7 +51,7 @@ add_task(function* test_hotkey_event_propagation() { add_task(function* test_not_found() { info("Check correct 'Phrase not found' on new tab"); - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI); + let tab = yield promiseTestPageLoad(); // Search for the first word. yield promiseFindFinished("--- THIS SHOULD NEVER MATCH ---", false); @@ -70,7 +63,7 @@ add_task(function* test_not_found() { }); add_task(function* test_found() { - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI); + let tab = yield promiseTestPageLoad(); // Search for a string that WILL be found, with 'Highlight All' on yield promiseFindFinished("S", true); @@ -83,10 +76,10 @@ add_task(function* test_found() { // Setting first findbar to case-sensitive mode should not affect // new tab find bar. add_task(function* test_tabwise_case_sensitive() { - let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI); + let tab1 = yield promiseTestPageLoad(); let findbar1 = gBrowser.getFindBar(); - let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI); + let tab2 = yield promiseTestPageLoad(); let findbar2 = gBrowser.getFindBar(); // Toggle case sensitivity for first findbar @@ -109,33 +102,22 @@ add_task(function* test_tabwise_case_sensitive() { gBrowser.removeTab(tab2); }); -/** - * Navigating from a web page (for example mozilla.org) to an internal page - * (like about:addons) might trigger a change of browser's remoteness. - * 'Remoteness change' means that rendering page content moves from child - * process into the parent process or the other way around. - * This test ensures that findbar properly handles such a change. - */ -add_task(function * test_reinitialization_at_remoteness_change() { - info("Ensure findbar re-initialization at remoteness change."); +function promiseTestPageLoad() { + let deferred = Promise.defer(); - // Load a remote page and trigger findbar construction. - let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI); - let browser = gBrowser.getBrowserForTab(tab); - let findbar = gBrowser.getFindBar(); + let tab = gBrowser.selectedTab = gBrowser.addTab("data:text/html;charset=utf-8,The letter s."); + let browser = gBrowser.selectedBrowser; + browser.addEventListener("load", function listener() { + if (browser.currentURI.spec == "about:blank") + return; + info("Page loaded: " + browser.currentURI.spec); + browser.removeEventListener("load", listener, true); - // Findbar should operate normally. - yield promiseFindFinished("s", false); - ok(!findbar._findStatusDesc.textContent, "Findbar status should be empty"); + deferred.resolve(tab); + }, true); - gBrowser.updateBrowserRemoteness(browser, false); - - // Findbar should keep operating normally. - yield promiseFindFinished("s", false); - ok(!findbar._findStatusDesc.textContent, "Findbar status should be empty"); - - yield BrowserTestUtils.removeTab(tab); -}); + return deferred.promise; +} function promiseFindFinished(searchText, highlightOn) { let deferred = Promise.defer(); @@ -149,17 +131,8 @@ function promiseFindFinished(searchText, highlightOn) { findbar._findField.value = searchText; let resultListener; - // When highlighting is on the finder sends a second "FOUND" message after - // the search wraps. This causes timing problems with e10s. waitMore - // forces foundOrTimeout wait for the second "FOUND" message before - // resolving the promise. - let waitMore = highlightOn; let findTimeout = setTimeout(() => foundOrTimedout(null), 2000); let foundOrTimedout = function(aData) { - if (aData !== null && waitMore) { - waitMore = false; - return; - } if (aData === null) info("Result listener not called, timeout reached."); clearTimeout(findTimeout); diff --git a/toolkit/content/widgets/findbar.xml b/toolkit/content/widgets/findbar.xml index 14c49b13472f..b9f996794a34 100644 --- a/toolkit/content/widgets/findbar.xml +++ b/toolkit/content/widgets/findbar.xml @@ -373,28 +373,12 @@ // browser property if (this.getAttribute("browserid")) setTimeout(function(aSelf) { aSelf.browser = aSelf.browser; }, 0, this); - - if (typeof gBrowser !== 'undefined') - gBrowser.tabContainer.addEventListener("TabRemotenessChange", this); ]]> - - - - - @@ -418,9 +402,6 @@ // Clear all timers that might still be running. this._cancelTimers(); - - if (typeof gBrowser !== 'undefined') - gBrowser.tabContainer.removeEventListener("TabRemotenessChange", this); ]]>