Index: LayoutTests/screen_orientation/lockOrientation-bad-array-argument.html |
diff --git a/LayoutTests/screen_orientation/lockOrientation-bad-array-argument.html b/LayoutTests/screen_orientation/lockOrientation-bad-array-argument.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0c56955351bd8573e893ea6d48268be7ff778c7e |
--- /dev/null |
+++ b/LayoutTests/screen_orientation/lockOrientation-bad-array-argument.html |
@@ -0,0 +1,38 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<script src="../resources/js-test.js"></script> |
+<script> |
+description("Validates that lockOrientation() returns false on bad orientation value in array argument."); |
+window.jsTestIsAsync = true; |
+ |
+function onOrientationChangeEvent(ev) { |
+ testFailed("Unexpected 'orientationchange' event"); |
+} |
+ |
+function completeTest() { |
+ shouldBeEqualToString("screen.orientation", "portrait-primary"); |
+ screen.unlockOrientation(); |
+ finishJSTest(); |
+} |
+ |
+window.addEventListener("orientationchange", onOrientationChangeEvent); |
+ |
+function typeErrorEnum(argStr) { |
+ return "TypeError: Failed to execute 'lockOrientation' on 'Screen': parameter 1 ('" + argStr + "') is not a valid enum value."; |
+} |
+ |
+shouldBeEqualToString("screen.orientation", "portrait-primary"); |
+// Bad argument to lockOrientation(), we should not get locked. |
+shouldThrow("screen.lockOrientation(['portrait-primary', 'invalid-orientation'])", "typeErrorEnum('portrait-primary,invalid-orientation')"); |
+shouldThrow("screen.lockOrientation(['portrait-primary', null])", "typeErrorEnum('portrait-primary,')"); |
+shouldThrow("screen.lockOrientation(['portrait-primary', undefined])", "typeErrorEnum('portrait-primary,')"); |
+shouldThrow("screen.lockOrientation(['portrait-primary', 123])", "typeErrorEnum('portrait-primary,123')"); |
+shouldThrow("screen.lockOrientation(['portrait-primary', window])", "typeErrorEnum('portrait-primary,[object Window]')"); |
+ |
+// Finish asynchronously to give events a chance to fire. |
+setTimeout(completeTest, 0); |
+</script> |
+</body> |
+</html> |
+ |