diff --git a/docshell/test/navigation/file_document_write_1.html b/docshell/test/navigation/file_document_write_1.html
index 14b2efcc127b..e0281f7cdbc4 100644
--- a/docshell/test/navigation/file_document_write_1.html
+++ b/docshell/test/navigation/file_document_write_1.html
@@ -6,7 +6,6 @@
document.write("
document.written content
");
document.close();
window.history.go(-1);
- opener.setTimeout("isTestDynamic()", 2500);
}
function start() {
@@ -14,6 +13,15 @@
setTimeout(run, 0);
}
}
+
+ window.addEventListener("pageshow",
+ function() {
+ ++opener.file_document_write_1_loadCount;
+ if (opener.file_document_write_1_loadCount == 2) {
+ opener.setTimeout("isTestDynamic()", 0);
+ }
+ opener.ok(opener.file_document_write_1_loadCount <= 2);
+ });
diff --git a/docshell/test/navigation/test_sessionhistory.html b/docshell/test/navigation/test_sessionhistory.html
index 2344bb30ba22..e4c0d18419ef 100644
--- a/docshell/test/navigation/test_sessionhistory.html
+++ b/docshell/test/navigation/test_sessionhistory.html
@@ -49,6 +49,7 @@ function nextTest_() {
}
// Needed by file_document_write_1.html
+window.file_document_write_1_loadCount = 0;
function isTestDynamic() {
var dyn = testWindow.document.getElementById("dynamic");
is(dyn, null, "Should have gone back to the static page!");