Index: LayoutTests/screen_orientation/page-visibility.html |
diff --git a/LayoutTests/screen_orientation/page-visibility.html b/LayoutTests/screen_orientation/page-visibility.html |
index 51d9708da10cead09c11f5fd76383eec679a6b92..73c19e4cf23e52428171d497c9b656c0fa7455a5 100644 |
--- a/LayoutTests/screen_orientation/page-visibility.html |
+++ b/LayoutTests/screen_orientation/page-visibility.html |
@@ -12,11 +12,16 @@ var orientationUnchangeHiddenTest = async_test("Test that screen.orientation kee |
var orientationUpdateVisibleTest = async_test("Test that screen.orientation is updated once the page is visible again."); |
var frameEventsTest = async_test("Test that the iframe got as many events as the main frame."); |
+var orientationChangeContinuation = null; |
var orientationChangeEventListenerCalls = 0; |
var orientationChangeEventListenerCallsForFrame = 0; |
screen.orientation.addEventListener('change', function() { |
orientationChangeEventListenerCalls++; |
+ if (orientationChangeEventContinuation) { |
+ setTimeout(orientationChangeEventContinuation); |
+ orientationChangeEventContinuation = null; |
+ } |
}); |
window.frames[0].screen.orientation.addEventListener('change', function() { |
@@ -31,7 +36,7 @@ function runEventVisibleTest() { |
if (window.testRunner) |
window.testRunner.setMockScreenOrientation("landscape-primary"); |
- setTimeout(function() { |
+ orientationChangeEventContinuation = function() { |
eventVisibleTest.step(function() { |
assert_equals(orientationChangeEventListenerCalls, 1); |
assert_equals(screen.orientation.type, "landscape-primary"); |
@@ -39,7 +44,7 @@ function runEventVisibleTest() { |
eventVisibleTest.done(); |
runNoEventHiddenTest(); |
- }); |
+ }; |
} |
function runNoEventHiddenTest() { |
@@ -53,14 +58,12 @@ function runNoEventHiddenTest() { |
if (window.testRunner) |
window.testRunner.setMockScreenOrientation("portrait-primary"); |
- setTimeout(function() { |
- noEventHiddenTest.step(function() { |
- assert_equals(orientationChangeEventListenerCalls, 1); |
- }); |
- noEventHiddenTest.done(); |
- |
- runOrientationUnchangeHiddenTest(); |
+ noEventHiddenTest.step(function() { |
+ assert_equals(orientationChangeEventListenerCalls, 1); |
}); |
+ noEventHiddenTest.done(); |
+ |
+ runOrientationUnchangeHiddenTest(); |
} |
function runOrientationUnchangeHiddenTest() { |
@@ -76,7 +79,7 @@ function runOrientationUpdateVisibleTest() { |
if (window.testRunner) |
testRunner.setPageVisibility("visible"); |
- setTimeout(function() { |
+ orientationChangeEventContinuation = function() { |
orientationUpdateVisibleTest.step(function() { |
assert_false(document.hidden); |
// A change event should have been fired. |
@@ -88,7 +91,7 @@ function runOrientationUpdateVisibleTest() { |
orientationUpdateVisibleTest.done(); |
runFrameEventsTest(); |
- }); |
+ }; |
} |
function runFrameEventsTest() { |