Bug 1155352, e10s, rewrite and reenable browser_middleMouse_noJSPaste.js, r=gijs

This commit is contained in:
Neil Deakin 2015-04-21 20:09:14 -04:00
parent 1dee995d07
commit 4859f0e9ed
3 changed files with 28 additions and 45 deletions

View File

@ -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]

View File

@ -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);
});

View File

@ -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();
});
});
}