Bug 1252110 - Fix and enable browser_bug400731.js for e10s. r=jaws

This commit is contained in:
Dão Gottwald 2016-02-29 22:24:55 +01:00
parent 6a27d6f942
commit cef6e4acef
2 changed files with 35 additions and 55 deletions

View File

@ -3,7 +3,6 @@ support-files = head.js
[browser_forbidden.js]
[browser_bug400731.js]
skip-if = e10s
[browser_bug415846.js]
skip-if = os == "mac" || e10s
# Disabled on Mac because of its bizarre special-and-unique

View File

@ -1,76 +1,57 @@
/* Check for the intended visibility of the "Ignore this warning" text*/
/* Check presence of the "Ignore this warning" button */
function onDOMContentLoaded(callback) {
function complete({ data }) {
mm.removeMessageListener("Test:DOMContentLoaded", complete);
callback(data);
}
let mm = gBrowser.selectedBrowser.messageManager;
mm.addMessageListener("Test:DOMContentLoaded", complete);
function contentScript() {
let listener = function () {
removeEventListener("DOMContentLoaded", listener);
let button = content.document.getElementById("ignoreWarningButton");
sendAsyncMessage("Test:DOMContentLoaded", { buttonPresent: !!button });
};
addEventListener("DOMContentLoaded", listener);
}
mm.loadFrameScript("data:,(" + contentScript.toString() + ")();", true);
}
function test() {
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
// Navigate to malware site. Can't use an onload listener here since
// error pages don't fire onload. Also can't register the DOMContentLoaded
// handler here because registering it too soon would mean that we might
// get it for about:blank, and not about:blocked.
gBrowser.addTabsProgressListener({
onLocationChange: function(aTab, aWebProgress, aRequest, aLocation, aFlags) {
if (aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) {
gBrowser.removeTabsProgressListener(this);
window.addEventListener("DOMContentLoaded", testMalware, true);
}
}
});
content.location = "http://www.itisatrap.org/firefox/its-an-attack.html";
gBrowser.selectedTab = gBrowser.addTab("http://www.itisatrap.org/firefox/its-an-attack.html");
onDOMContentLoaded(testMalware);
}
function testMalware(event) {
if (event.target != gBrowser.selectedBrowser.contentDocument) {
return;
}
window.removeEventListener("DOMContentLoaded", testMalware, true);
// Confirm that "Ignore this warning" is visible - bug 422410
var el = content.document.getElementById("ignoreWarningButton");
ok(el, "Ignore warning button should be present for malware");
var style = content.getComputedStyle(el, null);
is(style.display, "inline-block", "Ignore Warning button should be display:inline-block for malware");
function testMalware(data) {
ok(data.buttonPresent, "Ignore warning button should be present for malware");
Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", false);
// Now launch the unwanted software test
window.addEventListener("DOMContentLoaded", testUnwanted, true);
content.location = "http://www.itisatrap.org/firefox/unwanted.html";
onDOMContentLoaded(testUnwanted);
gBrowser.loadURI("http://www.itisatrap.org/firefox/unwanted.html");
}
function testUnwanted(event) {
if (event.target != gBrowser.selectedBrowser.contentDocument) {
return;
}
window.removeEventListener("DOMContentLoaded", testUnwanted, true);
function testUnwanted(data) {
// Confirm that "Ignore this warning" is visible - bug 422410
var el = content.document.getElementById("ignoreWarningButton");
ok(!el, "Ignore warning button should be missing for unwanted software");
ok(!data.buttonPresent, "Ignore warning button should be missing for unwanted software");
Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", true);
// Now launch the phishing test
window.addEventListener("DOMContentLoaded", testPhishing, true);
content.location = "http://www.itisatrap.org/firefox/its-a-trap.html";
onDOMContentLoaded(testPhishing);
gBrowser.loadURI("http://www.itisatrap.org/firefox/its-a-trap.html");
}
function testPhishing(event) {
if (event.target != gBrowser.selectedBrowser.contentDocument) {
return;
}
window.removeEventListener("DOMContentLoaded", testPhishing, true);
var el = content.document.getElementById("ignoreWarningButton");
ok(el, "Ignore warning button should be present for phishing");
var style = content.getComputedStyle(el, null);
is(style.display, "inline-block", "Ignore Warning button should be display:inline-block for phishing");
function testPhishing(data) {
ok(data.buttonPresent, "Ignore warning button should be present for phishing");
gBrowser.removeCurrentTab();
finish();