diff --git a/docshell/test/navigation/NavigationUtils.js b/docshell/test/navigation/NavigationUtils.js index 552f37ebfd31..4c75dd985ec8 100644 --- a/docshell/test/navigation/NavigationUtils.js +++ b/docshell/test/navigation/NavigationUtils.js @@ -209,9 +209,14 @@ function xpcWaitForFinishedFrames(callback, numFrames) { } function poll() { - // This only gives us UniversalXPConnect for the current stack frame - // We're using setInterval, so the main page's privileges are still normal - xpcEnumerateContentWindows(searchForFinishedFrames); + try { + // This only gives us UniversalXPConnect for the current stack frame + // We're using setInterval, so the main page's privileges are still normal + xpcEnumerateContentWindows(searchForFinishedFrames); + } catch(ex) { + // We might be accessing windows before they are fully constructed, + // which can throw. We'll find those frames on our next poll(). + } } var frameWaitInterval = setInterval(poll, 500); diff --git a/docshell/test/navigation/test_bug13871.html b/docshell/test/navigation/test_bug13871.html index 088a5b7ebc62..423b929f2e5f 100644 --- a/docshell/test/navigation/test_bug13871.html +++ b/docshell/test/navigation/test_bug13871.html @@ -15,23 +15,23 @@ window.onload = function () { navigateByOpen("window1_child0"); navigateByForm("window2_child0"); navigateByHyperlink("window3_child0"); + + xpcWaitForFinishedFrames(function() { + isInaccessible(window0.frames[0], "Should not be able to navigate off-domain frame by setting location."); + isInaccessible(window1.frames[0], "Should not be able to navigate off-domain frame by calling window.open."); + isInaccessible(window2.frames[0], "Should not be able to navigate off-domain frame by submitting form."); + isInaccessible(window3.frames[0], "Should not be able to navigate off-domain frame by targeted hyperlink."); + + window0.close(); + window1.close(); + window2.close(); + window3.close(); + + xpcCleanupWindows(); + SimpleTest.finish(); + }, 4); } -xpcWaitForFinishedFrames(function() { - isInaccessible(window0.frames[0], "Should not be able to navigate off-domain frame by setting location."); - isInaccessible(window1.frames[0], "Should not be able to navigate off-domain frame by calling window.open."); - isInaccessible(window2.frames[0], "Should not be able to navigate off-domain frame by submitting form."); - isInaccessible(window3.frames[0], "Should not be able to navigate off-domain frame by targeted hyperlink."); - - window0.close(); - window1.close(); - window2.close(); - window3.close(); - - xpcCleanupWindows(); - SimpleTest.finish(); -}, 4); - var window0 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/parent.html", "window0", "width=10,height=10"); var window1 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/parent.html", "window1", "width=10,height=10"); var window2 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/parent.html", "window2", "width=10,height=10"); diff --git a/docshell/test/navigation/test_bug278916.html b/docshell/test/navigation/test_bug278916.html index 697ba11de862..eebefa195568 100644 --- a/docshell/test/navigation/test_bug278916.html +++ b/docshell/test/navigation/test_bug278916.html @@ -9,21 +9,19 @@
diff --git a/docshell/test/navigation/test_bug279495.html b/docshell/test/navigation/test_bug279495.html index 86cc51eca5cd..cb09c9aeb9b1 100644 --- a/docshell/test/navigation/test_bug279495.html +++ b/docshell/test/navigation/test_bug279495.html @@ -13,6 +13,14 @@ window.onload = function () { sendMouseEvent({type:"click"}, "link0"); sendMouseEvent({type:"click"}, "link1"); + + xpcWaitForFinishedFrames(function() { + countAndClose("window0", 1); + countAndClose("window1", 1); + + xpcCleanupWindows(); + SimpleTest.finish(); + }, 2); } function countAndClose(name, expected_count) { @@ -24,14 +32,6 @@ function countAndClose(name, expected_count) { for (var i=0; i < array_of_frames.length; ++i) array_of_frames[i].close(); } - -xpcWaitForFinishedFrames(function() { - countAndClose("window0", 1); - countAndClose("window1", 1); - - xpcCleanupWindows(); - SimpleTest.finish(); -}, 2); diff --git a/docshell/test/navigation/test_child.html b/docshell/test/navigation/test_child.html index f0a05f0e4a33..2fc1ed20306b 100644 --- a/docshell/test/navigation/test_child.html +++ b/docshell/test/navigation/test_child.html @@ -15,17 +15,17 @@ window.onload = function() { navigateByOpen("child1"); navigateByForm("child2"); navigateByHyperlink("child3"); + + xpcWaitForFinishedFrames(function() { + isNavigated(frames[0], "Should be able to navigate off-domain child by setting location."); + isNavigated(frames[1], "Should be able to navigate off-domain child by calling window.open."); + isNavigated(frames[2], "Should be able to navigate off-domain child by submitting form."); + isNavigated(frames[3], "Should be able to navigate off-domain child by targeted hyperlink."); + + xpcCleanupWindows(); + SimpleTest.finish(); + }, 4); } - -xpcWaitForFinishedFrames(function() { - isNavigated(frames[0], "Should be able to navigate off-domain child by setting location."); - isNavigated(frames[1], "Should be able to navigate off-domain child by calling window.open."); - isNavigated(frames[2], "Should be able to navigate off-domain child by submitting form."); - isNavigated(frames[3], "Should be able to navigate off-domain child by targeted hyperlink."); - - xpcCleanupWindows(); - SimpleTest.finish(); -}, 4); diff --git a/docshell/test/navigation/test_grandchild.html b/docshell/test/navigation/test_grandchild.html index 426fad065570..8a760222c9db 100644 --- a/docshell/test/navigation/test_grandchild.html +++ b/docshell/test/navigation/test_grandchild.html @@ -15,17 +15,17 @@ window.onload = function () { navigateByOpen("child1_child0"); navigateByForm("child2_child0"); navigateByHyperlink("child3_child0"); + + xpcWaitForFinishedFrames(function() { + isNavigated(frames[0].frames[0], "Should be able to navigate off-domain grandchild by setting location."); + isNavigated(frames[1].frames[0], "Should be able to navigate off-domain grandchild by calling window.open."); + isNavigated(frames[2].frames[0], "Should be able to navigate off-domain grandchild by submitting form."); + isNavigated(frames[3].frames[0], "Should be able to navigate off-domain grandchild by targeted hyperlink."); + + xpcCleanupWindows(); + SimpleTest.finish(); + }, 4); } - -xpcWaitForFinishedFrames(function() { - isNavigated(frames[0].frames[0], "Should be able to navigate off-domain grandchild by setting location."); - isNavigated(frames[1].frames[0], "Should be able to navigate off-domain grandchild by calling window.open."); - isNavigated(frames[2].frames[0], "Should be able to navigate off-domain grandchild by submitting form."); - isNavigated(frames[3].frames[0], "Should be able to navigate off-domain grandchild by targeted hyperlink."); - - xpcCleanupWindows(); - SimpleTest.finish(); -}, 4); diff --git a/docshell/test/navigation/test_not-opener.html b/docshell/test/navigation/test_not-opener.html index 072ee8ada14b..ce7106402c6e 100644 --- a/docshell/test/navigation/test_not-opener.html +++ b/docshell/test/navigation/test_not-opener.html @@ -15,22 +15,22 @@ window.onload = function () { navigateByOpen("window1"); navigateByForm("window2"); navigateByHyperlink("window3"); + + xpcWaitForFinishedFrames(function() { + is(xpcGetFramesByName("window1").length, 2, "Should not be able to navigate popup's popup by calling window.open."); + is(xpcGetFramesByName("window2").length, 2, "Should not be able to navigate popup's popup by submitting form."); + is(xpcGetFramesByName("window3").length, 2, "Should not be able to navigate popup's popup by targeted hyperlink."); + + //opener0.close(); + opener1.close(); + opener2.close(); + opener3.close(); + + xpcCleanupWindows(); + SimpleTest.finish(); + }, 3); } -xpcWaitForFinishedFrames(function() { - is(xpcGetFramesByName("window1").length, 2, "Should not be able to navigate popup's popup by calling window.open."); - is(xpcGetFramesByName("window2").length, 2, "Should not be able to navigate popup's popup by submitting form."); - is(xpcGetFramesByName("window3").length, 2, "Should not be able to navigate popup's popup by targeted hyperlink."); - - //opener0.close(); - opener1.close(); - opener2.close(); - opener3.close(); - - xpcCleanupWindows(); - SimpleTest.finish(); -}, 3); - //opener0 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window0", "_blank", "width=10,height=10"); opener1 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window1", "_blank", "width=10,height=10"); opener2 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/open.html#window2", "_blank", "width=10,height=10"); diff --git a/docshell/test/navigation/test_opener.html b/docshell/test/navigation/test_opener.html index c5a88a1bb204..abab8f1b93b2 100644 --- a/docshell/test/navigation/test_opener.html +++ b/docshell/test/navigation/test_opener.html @@ -15,23 +15,23 @@ window.onload = function () { navigateByOpen("window1"); navigateByForm("window2"); navigateByHyperlink("window3"); + + xpcWaitForFinishedFrames(function() { + isNavigated(window0, "Should be able to navigate popup by setting location."); + isNavigated(window1, "Should be able to navigate popup by calling window.open."); + isNavigated(window2, "Should be able to navigate popup by submitting form."); + isNavigated(window3, "Should be able to navigate popup by targeted hyperlink."); + + window0.close(); + window1.close(); + window2.close(); + window3.close(); + + xpcCleanupWindows(); + SimpleTest.finish(); + }, 4); } -xpcWaitForFinishedFrames(function() { - isNavigated(window0, "Should be able to navigate popup by setting location."); - isNavigated(window1, "Should be able to navigate popup by calling window.open."); - isNavigated(window2, "Should be able to navigate popup by submitting form."); - isNavigated(window3, "Should be able to navigate popup by targeted hyperlink."); - - window0.close(); - window1.close(); - window2.close(); - window3.close(); - - xpcCleanupWindows(); - SimpleTest.finish(); -}, 4); - var window0 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/blank.html", "window0", "width=10,height=10"); var window1 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/blank.html", "window1", "width=10,height=10"); var window2 = window.open("http://test1.example.org:80/tests/docshell/test/navigation/blank.html", "window2", "width=10,height=10"); diff --git a/docshell/test/navigation/test_sibling-matching-parent.html b/docshell/test/navigation/test_sibling-matching-parent.html index fe84335b2da1..bc0fa768e52e 100644 --- a/docshell/test/navigation/test_sibling-matching-parent.html +++ b/docshell/test/navigation/test_sibling-matching-parent.html @@ -16,17 +16,17 @@ window.onload = function () { '' + '' + ''; + + xpcWaitForFinishedFrames(function() { + isNavigated(frames[0], "Should be able to navigate sibling with on-domain parent by setting location."); + isNavigated(frames[1], "Should be able to navigate sibling with on-domain parent by calling window.open."); + isNavigated(frames[2], "Should be able to navigate sibling with on-domain parent by submitting form."); + isNavigated(frames[3], "Should be able to navigate sibling with on-domain parent by targeted hyperlink."); + + xpcCleanupWindows(); + SimpleTest.finish(); + }, 4); } - -xpcWaitForFinishedFrames(function() { - isNavigated(frames[0], "Should be able to navigate sibling with on-domain parent by setting location."); - isNavigated(frames[1], "Should be able to navigate sibling with on-domain parent by calling window.open."); - isNavigated(frames[2], "Should be able to navigate sibling with on-domain parent by submitting form."); - isNavigated(frames[3], "Should be able to navigate sibling with on-domain parent by targeted hyperlink."); - - xpcCleanupWindows(); - SimpleTest.finish(); -}, 4); diff --git a/docshell/test/navigation/test_sibling-off-domain.html b/docshell/test/navigation/test_sibling-off-domain.html index 3d34188b1c02..2648cd4ecc8e 100644 --- a/docshell/test/navigation/test_sibling-off-domain.html +++ b/docshell/test/navigation/test_sibling-off-domain.html @@ -16,17 +16,17 @@ window.onload = function () { '' + '' + ''; + + xpcWaitForFinishedFrames(function() { + isBlank(frames[0], "Should not be able to navigate off-domain sibling by setting location."); + isBlank(frames[1], "Should not be able to navigate off-domain sibling by calling window.open."); + isBlank(frames[2], "Should not be able to navigate off-domain sibling by submitting form."); + isBlank(frames[3], "Should not be able to navigate off-domain sibling by targeted hyperlink."); + + xpcCleanupWindows(); + SimpleTest.finish(); + }, 4); } - -xpcWaitForFinishedFrames(function() { - isBlank(frames[0], "Should not be able to navigate off-domain sibling by setting location."); - isBlank(frames[1], "Should not be able to navigate off-domain sibling by calling window.open."); - isBlank(frames[2], "Should not be able to navigate off-domain sibling by submitting form."); - isBlank(frames[3], "Should not be able to navigate off-domain sibling by targeted hyperlink."); - - xpcCleanupWindows(); - SimpleTest.finish(); -}, 4);