From 4859f0e9ed39ccc419280a452eb201afb32fdb86 Mon Sep 17 00:00:00 2001 From: Neil Deakin Date: Tue, 21 Apr 2015 20:09:14 -0400 Subject: [PATCH] Bug 1155352, e10s, rewrite and reenable browser_middleMouse_noJSPaste.js, r=gijs --- browser/base/content/test/general/browser.ini | 1 - .../general/browser_middleMouse_noJSPaste.js | 65 +++++++------------ .../general/browser_wyciwyg_urlbarCopying.js | 7 +- 3 files changed, 28 insertions(+), 45 deletions(-) diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index 835e148669a..07670be6a46 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -334,7 +334,6 @@ skip-if = os == "linux" # Linux: Intermittent failures, bug 917535 [browser_menuButtonFitts.js] skip-if = os != "win" # The Fitts Law menu button is only supported on Windows (bug 969376) [browser_middleMouse_noJSPaste.js] -skip-if = e10s # Bug 921952 - Content:Click event issues [browser_minimize.js] skip-if = e10s # Bug 1100664 - test directly access content docShells (TypeError: gBrowser.docShell is null) [browser_mixedcontent_securityflags.js] diff --git a/browser/base/content/test/general/browser_middleMouse_noJSPaste.js b/browser/base/content/test/general/browser_middleMouse_noJSPaste.js index dc8755d7352..f51095cc3d8 100644 --- a/browser/base/content/test/general/browser_middleMouse_noJSPaste.js +++ b/browser/base/content/test/general/browser_middleMouse_noJSPaste.js @@ -3,51 +3,32 @@ const middleMousePastePref = "middlemouse.contentLoadURL"; const autoScrollPref = "general.autoScroll"; -function test() { - waitForExplicitFinish(); - Services.prefs.setBoolPref(middleMousePastePref, true); - Services.prefs.setBoolPref(autoScrollPref, false); - let tab = gBrowser.selectedTab = gBrowser.addTab(); +add_task(function* () { + yield pushPrefs([middleMousePastePref, true], [autoScrollPref, false]); - registerCleanupFunction(function () { - Services.prefs.clearUserPref(middleMousePastePref); - Services.prefs.clearUserPref(autoScrollPref); - gBrowser.removeTab(tab); - }); + let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser); - addPageShowListener(function () { - let pagePrincipal = gBrowser.contentPrincipal; - - // copy javascript URI to the clipboard - let url = "javascript:http://www.example.com/"; - waitForClipboard(url, - function() { - Components.classes["@mozilla.org/widget/clipboardhelper;1"] - .getService(Components.interfaces.nsIClipboardHelper) - .copyString(url, document); - }, - function () { - // Middle click on the content area - info("Middle clicking"); - EventUtils.sendMouseEvent({type: "click", button: 1}, gBrowser); - }, - function() { - ok(false, "Failed to copy URL to the clipboard"); - finish(); - } - ); - - addPageShowListener(function () { - is(gBrowser.currentURI.spec, url.replace(/^javascript:/, ""), "url loaded by middle click doesn't include JS"); - finish(); + let url = "javascript:http://www.example.com/"; + yield new Promise((resolve, reject) => { + SimpleTest.waitForClipboard(url, () => { + Components.classes["@mozilla.org/widget/clipboardhelper;1"] + .getService(Components.interfaces.nsIClipboardHelper) + .copyString(url, document); + }, resolve, () => { + ok(false, "Clipboard copy failed"); + reject(); }); }); -} -function addPageShowListener(func) { - gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() { - gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false); - func(); - }); -} + let middlePagePromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser); + + // Middle click on the content area + info("Middle clicking"); + yield BrowserTestUtils.synthesizeMouse(null, 10, 10, {button: 1}, gBrowser.selectedBrowser); + yield middlePagePromise; + + is(gBrowser.currentURI.spec, url.replace(/^javascript:/, ""), "url loaded by middle click doesn't include JS"); + + gBrowser.removeTab(tab); +}); diff --git a/browser/base/content/test/general/browser_wyciwyg_urlbarCopying.js b/browser/base/content/test/general/browser_wyciwyg_urlbarCopying.js index 53456ed85c4..0f8a0388f67 100644 --- a/browser/base/content/test/general/browser_wyciwyg_urlbarCopying.js +++ b/browser/base/content/test/general/browser_wyciwyg_urlbarCopying.js @@ -2,14 +2,17 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ function testURLBarCopy(targetValue) { - return new Promise(resolve => { + return new Promise((resolve, reject) => { info("Expecting copy of: " + targetValue); waitForClipboard(targetValue, function () { gURLBar.focus(); gURLBar.select(); goDoCommand("cmd_copy"); - }, resolve); + }, resolve, () => { + ok(false, "Clipboard copy failed"); + reject(); + }); }); }