gecko/browser/components/safebrowsing/content/test/browser_bug400731.js
Johnathan Nightingale 0ee5089bb6 Bug 425001 - Tests for bugs 400731 and 431826 rely on timers and are therefore fragile. TEST ONLY FIX.
Replace with DOMContentLoaded listeners, since onload doesn't work for error pages.
2009-04-21 16:17:14 -04:00

44 lines
1.6 KiB
JavaScript

/* Check for the intended visibility of the "Ignore this warning" text*/
var newBrowser
function test() {
waitForExplicitFinish();
var newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
newBrowser = gBrowser.getBrowserForTab(newTab);
// Navigate to malware site. Can't use an onload listener here since
// error pages don't fire onload
window.addEventListener("DOMContentLoaded", testMalware, true);
newBrowser.contentWindow.location = 'http://www.mozilla.com/firefox/its-an-attack.html';
}
function testMalware() {
window.removeEventListener("DOMContentLoaded", testMalware, true);
// Confirm that "Ignore this warning" is visible - bug 422410
var el = newBrowser.contentDocument.getElementById("ignoreWarningButton");
ok(el, "Ignore warning button should be present for malware");
var style = newBrowser.contentWindow.getComputedStyle(el, null);
is(style.display, "-moz-box", "Ignore Warning button should be display:-moz-box for malware");
// Now launch the phishing test
window.addEventListener("DOMContentLoaded", testPhishing, true);
newBrowser.contentWindow.location = 'http://www.mozilla.com/firefox/its-a-trap.html';
}
function testPhishing() {
window.removeEventListener("DOMContentLoaded", testPhishing, true);
var el = newBrowser.contentDocument.getElementById("ignoreWarningButton");
ok(el, "Ignore warning button should be present for phishing");
var style = newBrowser.contentWindow.getComputedStyle(el, null);
is(style.display, "-moz-box", "Ignore Warning button should be display:-moz-box for phishing");
gBrowser.removeCurrentTab();
finish();
}