<!DOCTYPE html>
<html>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
var previousOrientation = screen.orientation;
test(function() {
var caught = false;
try {
screen.orientation.unlock();
} catch (e) {
caught = true;
}
assert_false(caught);
}, "Test that screen.orientation.unlock() 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.orientation.lock(orientation).then(function() {
pending = false;
}, function() {
pending = false;
});
assert_true(pending);
});
}, "Test that screen.orientation.lock returns a pending promise.");
test(function() {
assert_equals(screen.orientation, previousOrientation);
}, "Test that screen.orientation.lock() is actually async");
test(function() {
var caught = false;
try {
screen.orientation.unlock();
} catch (e) {
caught = true;
}
assert_false(caught);
}, "Test that screen.unlock() doesn't throw when there is a lock");
</script>
</body>
</html>