blob: 129882d64f6d323d93a183d59f4744a8e888d3f1 [file] [log] [blame]
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script>
import { getOppositeOrientation } from "/screen-orientation/resources/orientation-utils.js";
promise_test(async t => {
await test_driver.bless("request full screen", () => {
return document.documentElement.requestFullscreen();
});
const newOrientation = getOppositeOrientation();
// This will reject, because the event will call lock() again.
const pMustReject = screen.orientation.lock(newOrientation);
// This one resolves, because we are re-locking.
const pMustResolve = new Promise(r => {
screen.orientation.onchange = () => {
r(orientation.lock("any"));
};
});
await promise_rejects(t, new TypeError(), pMustReject);
await pMustResolve;
screen.orientation.unlock();
return document.exitFullscreen();
}, "Re-locking orientation during event dispatch must reject existing orientationPendingPromise");
</script>