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.
This commit is contained in:
Johnathan Nightingale 2009-04-21 16:17:14 -04:00
parent 1c4f1309c3
commit 0ee5089bb6
2 changed files with 10 additions and 6 deletions

View File

@ -8,13 +8,12 @@ function test() {
newBrowser = gBrowser.getBrowserForTab(newTab);
// Navigate to a site with a broken cert
window.addEventListener("DOMContentLoaded", testBrokenCert, true);
newBrowser.contentWindow.location = 'https://nocert.example.com/';
// XXX - This timer and the next should be replaced with an event
// handler when bug 425001 is fixed.
window.setTimeout(testBrokenCert, 2000);
}
function testBrokenCert() {
window.removeEventListener("DOMContentLoaded", testBrokenCert, true);
// Confirm that we are displaying the contributed error page, not the default
ok(/^about:certerror/.test(gBrowser.contentWindow.document.documentURI), "Broken page should go to about:certerror, not about:neterror");
@ -28,12 +27,13 @@ function testBrokenCert() {
Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch)
.setBoolPref("browser.xul.error_pages.expert_bad_cert", true);
window.addEventListener("DOMContentLoaded", testExpertPref, true);
newBrowser.reload();
window.setTimeout(testExpertPref, 2000);
}
function testExpertPref() {
window.removeEventListener("DOMContentLoaded", testExpertPref, true);
var expertDiv = gBrowser.contentWindow.document.getElementById("expertContent");
var technicalDiv = gBrowser.contentWindow.document.getElementById("technicalContent");
ok(!expertDiv.hasAttribute("collapsed"), "Expert content should not be collapsed with the expert mode pref set");

View File

@ -10,11 +10,13 @@ function test() {
// 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';
window.setTimeout(testMalware, 2000);
}
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");
@ -23,11 +25,13 @@ function testMalware() {
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';
window.setTimeout(testPhishing, 2000);
}
function testPhishing() {
window.removeEventListener("DOMContentLoaded", testPhishing, true);
var el = newBrowser.contentDocument.getElementById("ignoreWarningButton");
ok(el, "Ignore warning button should be present for phishing");