Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Unified Diff: LayoutTests/screen_orientation/lockOrientation-bad-argument.html

Issue 381753002: Revert of [screen-orientation] Update implementation to match recent spec changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/screen_orientation/lockOrientation-bad-argument.html
diff --git a/LayoutTests/screen_orientation/lockOrientation-bad-argument.html b/LayoutTests/screen_orientation/lockOrientation-bad-argument.html
index 88b2e047d860c4d4dd7753756b780d79be818c66..affd4df2706a98995ca37f3f7dd2fd96a7af27b3 100644
--- a/LayoutTests/screen_orientation/lockOrientation-bad-argument.html
+++ b/LayoutTests/screen_orientation/lockOrientation-bad-argument.html
@@ -1,72 +1,44 @@
<!DOCTYPE html>
<html>
<body>
-<script src="../resources/testharness.js"></script>
-<script src="../resources/testharnessreport.js"></script>
+<script src="../resources/js-test.js"></script>
<script>
-
-var test = async_test("Test that screen.orientation.lock() throws when the input isn't valid.");
+description("Validates that screen.lockOrientation() returns false on bad input");
+window.jsTestIsAsync = true;
function onOrientationChangeEvent(ev) {
- assert_unreached('Unexpected orientation change');
+ testFailed("Unexpected 'orientationchange' event");
}
-window.screen.orientation.addEventListener('change', test.step_func(onOrientationChangeEvent));
+function completeTest() {
+ shouldBeEqualToString("screen.orientation", "portrait-primary");
+ screen.unlockOrientation();
+ finishJSTest();
+}
-test.step(function() {
- assert_equals(screen.orientation.type, 'portrait-primary');
- assert_throws({ name: 'TypeError' }, function() {
- screen.lock('invalid-orientation');
- });
+window.addEventListener("orientationchange", onOrientationChangeEvent);
- assert_equals(screen.orientation.type, 'portrait-primary');
- assert_throws({ name: 'TypeError' }, function() {
- screen.lock(null);
- });
+function typeErrorEnum(argStr) {
+ return "TypeError: Failed to execute 'lockOrientation' on 'Screen': parameter 1 ('" + argStr + "') is not a valid enum value.";
+}
- assert_equals(screen.orientation.type, 'portrait-primary');
- assert_throws({ name: 'TypeError' }, function() {
- screen.lock(undefined);
- });
-
- assert_equals(screen.orientation.type, 'portrait-primary');
- assert_throws({ name: 'TypeError' }, function() {
- screen.lock(undefined);
- });
-
- assert_equals(screen.orientation.type, 'portrait-primary');
- assert_throws({ name: 'TypeError' }, function() {
- screen.lock(123);
- });
-
- assert_equals(screen.orientation.type, 'portrait-primary');
- assert_throws({ name: 'TypeError' }, function() {
- screen.lock(window);
- });
-
- assert_equals(screen.orientation.type, 'portrait-primary');
- assert_throws({ name: 'TypeError' }, function() {
- screen.lock(['portrait-primary']);
- });
-
- assert_equals(screen.orientation.type, 'portrait-primary');
- assert_throws({ name: 'TypeError' }, function() {
- screen.lock(['portrait-primary', 'landscape-primary']);
- });
-
- assert_equals(screen.orientation.type, 'portrait-primary');
- assert_throws({ name: 'TypeError' }, function() {
- screen.lock();
- });
-});
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldThrow("screen.lockOrientation('invalid-orientation')", "typeErrorEnum('invalid-orientation')");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldThrow("screen.lockOrientation(null)", "typeErrorEnum('null')");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldThrow("screen.lockOrientation(undefined)", "typeErrorEnum('undefined')");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldThrow("screen.lockOrientation(123)", "typeErrorEnum('123')");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldThrow("screen.lockOrientation(window)", "typeErrorEnum('[object Window]')");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldThrow("screen.lockOrientation(['portrait-primary', 'landscape-primary'])", "typeErrorEnum('portrait-primary,landscape-primary')");
+shouldBeEqualToString("screen.orientation", "portrait-primary");
+shouldThrow("screen.lockOrientation()", '"TypeError: Failed to execute \'lockOrientation\' on \'Screen\': 1 argument required, but only 0 present."');
// Finish asynchronously to give events a chance to fire.
-setTimeout(test.step_func(function() {
- assert_equals(screen.orientation.type, 'portrait-primary');
- screen.orientation.unlock();
- test.done();
-}));
-
+setTimeout(completeTest, 0);
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698