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

Unified Diff: LayoutTests/screen_orientation/lockOrientation-basic.html

Issue 283423005: Use Promises for screen.lockOrientation(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: cdumez comments Created 6 years, 7 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-basic.html
diff --git a/LayoutTests/screen_orientation/lockOrientation-basic.html b/LayoutTests/screen_orientation/lockOrientation-basic.html
index a14ae787e6523faa97a433a2c332e2b0fba20ba4..462b1bb58d08a95142352b3cf88f349ebd82a525 100644
--- a/LayoutTests/screen_orientation/lockOrientation-basic.html
+++ b/LayoutTests/screen_orientation/lockOrientation-basic.html
@@ -1,21 +1,52 @@
<!DOCTYPE html>
<html>
<body>
-<script src="../resources/js-test.js"></script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
<script>
-description("Basic screen.lockOrientation() / screen.unlockOrientation() testing");
-shouldBeEqualToString("screen.orientation", "portrait-primary");
-shouldNotThrow("screen.unlockOrientation()");
+var previousOrientation = screen.orientation;
-[ 'any', 'portrait', 'landscape', 'portrait-primary', 'portrait-secondary',
- 'landscape-primary', 'landscape-secondary' ].forEach(function(orientation) {
- shouldBeTrue("screen.lockOrientation('" + orientation + "')");
-});
+test(function() {
+ var caught = false;
jochen (gone - plz use gerrit) 2014/05/22 08:34:35 4 space indent plz
mlamouri (slow - plz ping) 2014/05/22 08:58:56 Done.
+ try {
+ screen.unlockOrientation();
+ } catch (e) {
+ caught = true;
+ }
+
+ assert_false(caught);
+}, "Test that unlockOrientation() doesn't throw when there is no lock");
+
+test(function() {
+ [ 'any', 'portrait', 'landscape', 'portrait-primary', 'portrait-secondary',
+ 'landscape-primary', 'landscape-secondary' ].forEach(function(orientation) {
+ var pending = true;
+ screen.lockOrientation(orientation).then(function() {
+ pending = false;
+ }, function() {
+ pending = false;
+ });
+
+ assert_true(pending);
+ });
+}, "Test that screen.lockOrientation returns a pending promise.");
+
+test(function() {
+ assert_equals(screen.orientation, previousOrientation);
+}, "Test that screen.lockOrientation() is actually async");
+
+test(function() {
+ var caught = false;
+ try {
+ screen.unlockOrientation();
+ } catch (e) {
+ caught = true;
+ }
+
+ assert_false(caught);
+}, "Test that unlockOrientation doesn't throw when there is a lock");
-// Update is made asynchronously so that shouldn't change.
-shouldBeEqualToString("screen.orientation", "portrait-primary");
-shouldNotThrow("screen.unlockOrientation()");
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698