Index: LayoutTests/screen_orientation/orientationchange-event.html |
diff --git a/LayoutTests/screen_orientation/orientationchange-event.html b/LayoutTests/screen_orientation/orientationchange-event.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..63dfbfd865c1407cf9d05e1817b4d85269296261 |
--- /dev/null |
+++ b/LayoutTests/screen_orientation/orientationchange-event.html |
@@ -0,0 +1,60 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script> |
+ |
+var orientations = [ |
+ 'portrait-primary', |
+ 'portrait-secondary', |
+ 'landscape-primary', |
+ 'landscape-secondary' |
+]; |
+ |
+var currentIndex = orientations.indexOf(window.screen.orientation); |
+var eventHandlers = 0; |
Inactive
2014/04/19 19:14:19
Maybe "eventHandlerCount"? (Something with "Count"
mlamouri (slow - plz ping)
2014/04/19 23:24:20
I changed the variable name and added a comment.
|
+var eventAVL = 0; |
Inactive
2014/04/19 19:14:19
What does AVL stand for? we don't use abbreviation
mlamouri (slow - plz ping)
2014/04/19 23:24:20
ditto
|
+ |
+// TODO: window.onorientationchange is enabled on Android only. We will enable |
+// it with ScreenOrientation later, at which point this test will fail. We will |
+// then have to fix it. |
+function todo_equals(actual, expected) { |
+ assert_not_equals(actual, expected, "TODO: if this fails, it means that something got fixed."); |
+} |
+ |
+function getNextIndex() { |
+ return (currentIndex + 1) % orientations.length; |
+} |
+ |
+window.onorientationchange = function() { |
+ eventHandlers++; |
+}; |
+ |
+window.addEventListener('orientationchange', function() { |
+ eventAVL++; |
+}); |
+ |
+for (var i = 0; i < 4; ++i) { |
+ test(function() { |
+ window.testRunner.setMockScreenOrientation(orientations[getNextIndex()]); |
Inactive
2014/04/19 19:14:19
So this fires the 'orientationchange' event synchr
mlamouri (slow - plz ping)
2014/04/19 23:24:20
Correct.
|
+ |
+ currentIndex = getNextIndex(); |
+ assert_equals(screen.orientation, orientations[currentIndex]); |
+ |
+ todo_equals(eventHandlers, i + 1); |
+ assert_equals(eventAVL, i + 1); |
+ }, "Test that orientationchange event is fired when the orientation changes"); |
+} |
+ |
+test(function() { |
+ window.testRunner.setMockScreenOrientation(orientations[currentIndex]); |
+ assert_equals(screen.orientation, orientations[currentIndex]); |
+ |
+ todo_equals(eventHandlers, 4); |
+ assert_equals(eventAVL, 4); |
+}, "Test that orientationchange event is not fired when the orientation does not change"); |
+ |
+</script> |
+</body> |
+</html> |