fune/browser/components/safebrowsing/content/test/browser_bug400731.js
Victor Porof 1f830c96da Bug 1561435 - Format browser/components/, a=automatic-formatting
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D36042

--HG--
extra : source : d3afcafdce650a6f36cebbc126ee93b17f13cf52
2019-07-05 09:53:32 +02:00

74 lines
2 KiB
JavaScript

/* Check presence of the "Ignore this warning" button */
/* eslint-env mozilla/frame-script */
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("ignore_warning_link");
sendAsyncMessage("Test:DOMContentLoaded", { buttonPresent: !!button });
};
addEventListener("DOMContentLoaded", listener);
}
mm.loadFrameScript("data:,(" + contentScript.toString() + ")();", true);
}
function test() {
waitForExplicitFinish();
waitForDBInit(() => {
gBrowser.selectedTab = BrowserTestUtils.addTab(
gBrowser,
"http://www.itisatrap.org/firefox/its-an-attack.html"
);
onDOMContentLoaded(testMalware);
});
}
function testMalware(data) {
ok(data.buttonPresent, "Ignore warning link should be present for malware");
Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", false);
// Now launch the unwanted software test
onDOMContentLoaded(testUnwanted);
BrowserTestUtils.loadURI(
gBrowser,
"http://www.itisatrap.org/firefox/unwanted.html"
);
}
function testUnwanted(data) {
// Confirm that "Ignore this warning" is visible - bug 422410
ok(
!data.buttonPresent,
"Ignore warning link should be missing for unwanted software"
);
Services.prefs.setBoolPref("browser.safebrowsing.allowOverride", true);
// Now launch the phishing test
onDOMContentLoaded(testPhishing);
BrowserTestUtils.loadURI(
gBrowser,
"http://www.itisatrap.org/firefox/its-a-trap.html"
);
}
function testPhishing(data) {
ok(data.buttonPresent, "Ignore warning link should be present for phishing");
gBrowser.removeCurrentTab();
finish();
}