Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Prevent hidden documents from locking the screen orientation
https://bugs.webkit.org/show_bug.cgi?id=247248 rdar://102019707 Reviewed by Youenn Fablet. * LayoutTests/fast/screen-orientation/hidden-document-check-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resources/testdriver-vendor.js: (window.test_driver_internal.action_sequence): (async if): (window.test_driver_internal.minimize_window): (window.test_driver_internal.set_window_rect): * LayoutTests/imported/w3c/web-platform-tests/screen-orientation/hidden_document-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/screen-orientation/hidden_document.html: Added. * LayoutTests/platform/ios/TestExpectations: * Source/WebCore/page/ScreenOrientation.cpp: (WebCore::ScreenOrientation::lock): Canonical link: https://commits.webkit.org/257019@main
- Loading branch information
1 parent
c8c8117
commit a68ef76884df02cb25c760874bfc38df99c09783
Showing
6 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
This test checks that trying to lock or unlock a hidden document results in a SecurityError. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS document.hidden is true | ||
PASS SecurityError rejected promise with SecurityError: Only visible documents can lock the screen orientation. | ||
PASS screen.orientation.unlock() threw exception SecurityError: Only visible documents can unlock the screen orientation. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS test locking the orientation when document is hidden | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<meta name="timeout" content="long" /> | ||
<title>Prevent hidden documents from locking orientation</title> | ||
<link rel="help" href="https://github.com/w3c/screen-orientation/pull/232" /> | ||
<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 type="module"> | ||
import { getOppositeOrientation } from "./resources/orientation-utils.js"; | ||
let rect; | ||
|
||
promise_setup(async (t) => { | ||
rect = await test_driver.minimize_window(); | ||
assert_true(document.hidden, "document must be hidden"); | ||
}); | ||
|
||
promise_test(async (t) => { | ||
await promise_rejects_dom( | ||
t, | ||
"SecurityError", | ||
screen.orientation.lock("landscape"), | ||
"Locking orientation must reject when the document is hidden" | ||
); | ||
|
||
assert_throws_dom( | ||
"SecurityError", | ||
() => { | ||
screen.orientation.unlock(); | ||
}, | ||
"Unlocking orientation must throw when the document is hidden" | ||
); | ||
|
||
await test_driver.set_window_rect(rect); | ||
assert_false(document.hidden, "document must not be hidden"); | ||
// not longer throws | ||
screen.orientation.unlock(); | ||
}, "test locking the orientation when document is hidden"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters