Bug 1161612, e10s, fix and reenable browser_bug734076.js, r=mconley

This commit is contained in:
Neil Deakin 2015-05-11 08:02:49 -04:00
parent 0ba9bcf9aa
commit c12415dfbe
2 changed files with 77 additions and 74 deletions

View File

@ -248,7 +248,6 @@ skip-if = e10s # bug 1102331 - does focus things on the content window which bre
[browser_bug719271.js] [browser_bug719271.js]
[browser_bug724239.js] [browser_bug724239.js]
[browser_bug734076.js] [browser_bug734076.js]
skip-if = e10s # Bug 1093155 - tries to use context menu from browser-chrome and gets in a mess when in e10s mode
[browser_bug735471.js] [browser_bug735471.js]
[browser_bug749738.js] [browser_bug749738.js]
[browser_bug763468_perwindowpb.js] [browser_bug763468_perwindowpb.js]

View File

@ -1,104 +1,108 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */ * http://creativecommons.org/publicdomain/zero/1.0/ */
function test() { add_task(function* ()
waitForExplicitFinish(); {
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, null, false);
let tab = gBrowser.selectedTab = gBrowser.addTab();
registerCleanupFunction(function () {
gBrowser.removeTab(tab);
});
let browser = tab.linkedBrowser; let browser = tab.linkedBrowser;
browser.stop(); // stop the about:blank load browser.stop(); // stop the about:blank load
let writeDomainURL = encodeURI("data:text/html,<script>document.write(document.domain);</script>"); let writeDomainURL = encodeURI("data:text/html,<script>document.write(document.domain);</script>");
let tests = [ let tests = [
{ {
name: "view background image", name: "view background image",
url: "http://mochi.test:8888/", url: "http://mochi.test:8888/",
go: function (cb) { element: "body",
let contentBody = browser.contentDocument.body; go: function () {
contentBody.style.backgroundImage = "url('" + writeDomainURL + "')"; return ContentTask.spawn(gBrowser.selectedBrowser, { writeDomainURL: writeDomainURL }, function* (arg) {
doOnLoad(function () { let contentBody = content.document.body;
let domain = browser.contentDocument.body.textContent; contentBody.style.backgroundImage = "url('" + arg.writeDomainURL + "')";
is(domain, "", "no domain was inherited for view background image");
cb();
});
doContextCommand(contentBody, "context-viewbgimage"); return "context-viewbgimage";
});
},
verify: function () {
return ContentTask.spawn(gBrowser.selectedBrowser, { }, function* (arg) {
return [content.document.body.textContent, "no domain was inherited for view background image"];
});
} }
}, },
{ {
name: "view image", name: "view image",
url: "http://mochi.test:8888/", url: "http://mochi.test:8888/",
go: function (cb) { element: "img",
doOnLoad(function () { go: function () {
let domain = browser.contentDocument.body.textContent; return ContentTask.spawn(gBrowser.selectedBrowser, { writeDomainURL: writeDomainURL }, function* (arg) {
is(domain, "", "no domain was inherited for view image"); let doc = content.document;
cb(); let img = doc.createElement("img");
img.setAttribute("src", arg.writeDomainURL);
doc.body.insertBefore(img, doc.body.firstChild);
return "context-viewimage";
});
},
verify: function () {
return ContentTask.spawn(gBrowser.selectedBrowser, { }, function* (arg) {
return [content.document.body.textContent, "no domain was inherited for view image"];
}); });
let doc = browser.contentDocument;
let img = doc.createElement("img");
img.setAttribute("src", writeDomainURL);
doc.body.appendChild(img);
doContextCommand(img, "context-viewimage");
} }
}, },
{ {
name: "show only this frame", name: "show only this frame",
url: "http://mochi.test:8888/", url: "http://mochi.test:8888/",
go: function (cb) { element: "iframe",
doOnLoad(function () { go: function () {
let domain = browser.contentDocument.body.textContent; return ContentTask.spawn(gBrowser.selectedBrowser, { writeDomainURL: writeDomainURL }, function* (arg) {
is(domain, "", "no domain was inherited for 'show only this frame'"); let doc = content.document;
cb(); let iframe = doc.createElement("iframe");
iframe.setAttribute("src", arg.writeDomainURL);
doc.body.insertBefore(iframe, doc.body.firstChild);
// Wait for the iframe to load.
return new Promise(resolve => {
iframe.addEventListener("load", function onload() {
iframe.removeEventListener("load", onload, true);
resolve("context-showonlythisframe");
}, true);
});
});
},
verify: function () {
return ContentTask.spawn(gBrowser.selectedBrowser, { writeDomainURL: writeDomainURL }, function* (arg) {
return [content.document.body.textContent, "no domain was inherited for 'show only this frame'"];
}); });
let doc = browser.contentDocument;
let iframe = doc.createElement("iframe");
iframe.setAttribute("src", writeDomainURL);
doc.body.appendChild(iframe);
iframe.addEventListener("load", function onload() {
doContextCommand(iframe.contentDocument.body,
"context-showonlythisframe");
}, false);
} }
} }
]; ];
function doOnLoad(cb) { let contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
browser.addEventListener("load", function onLoad(e) {
if (e.target != browser.contentDocument) for (let test of tests) {
return; let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
browser.removeEventListener("load", onLoad, true); gBrowser.loadURI(test.url);
cb(); yield loadedPromise;
}, true);
info("Run subtest " + test.name);
let commandToRun = yield test.go();
let popupShownPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popupshown");
yield BrowserTestUtils.synthesizeMouse(test.element, 3, 3,
{ type: "contextmenu", button: 2 }, gBrowser.selectedBrowser);
yield popupShownPromise;
let loadedAfterCommandPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
document.getElementById(commandToRun).click();
yield loadedAfterCommandPromise;
let result = yield test.verify();
ok(!result[0], result[1]);
let popupHiddenPromise = BrowserTestUtils.waitForEvent(contentAreaContextMenu, "popuphidden");
contentAreaContextMenu.hidePopup();
yield popupHiddenPromise;
} }
function doNext() { gBrowser.removeCurrentTab();
let test = tests.shift(); });
if (test) {
info("Running test: " + test.name);
doOnLoad(function () {
test.go(function () {
executeSoon(doNext);
});
});
browser.contentDocument.location = test.url;
} else {
executeSoon(finish);
}
}
doNext();
}
function doContextCommand(aNode, aCmd) {
EventUtils.sendMouseEvent({ type: "contextmenu" }, aNode);
document.getElementById(aCmd).click();
document.getElementById("contentAreaContextMenu").hidePopup();
}