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

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: review commenst 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
« no previous file with comments | « no previous file | LayoutTests/screen_orientation/lockOrientation-basic-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9a48a806fc6fbe10c7c1eb63018bde719e2204ec 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;
+ 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>
« no previous file with comments | « no previous file | LayoutTests/screen_orientation/lockOrientation-basic-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698