Skip to content

Commit 340ec32

Browse files
steimelchromeSkyBlack1225
authored andcommittedDec 22, 2023
[document pip] Allow resizeTo()/resizeBy() via user gesture
Currently, we don't allow picture-in-picture windows to use the resizeTo() and resizeBy() APIs to prevent abuse. This CL adds a user gesture requirement to those APIs for document picture-in-picture windows to allow them to use those APIs while limiting the potential for abuse. Specification: WICG/document-picture-in-picture#104 Bug: 1354325 Change-Id: I6eabb2e9b8923ec1fc395cb44e3cc00ad674f5da Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4980802 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Fr <beaufort.francois@gmail.com> Reviewed-by: Frank Liberato <liberato@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Commit-Queue: Tommy Steimel <steimel@chromium.org> Cr-Commit-Position: refs/heads/main@{#1230725}
1 parent faddb32 commit 340ec32

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<title>Test that calling resizeTo() or resizeBy() on a document
3+
picture-in-picture window requires user gesture</title>
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<script src="/resources/testdriver.js"></script>
7+
<script src="/resources/testdriver-vendor.js"></script>
8+
<body>
9+
<script>
10+
promise_test(async (t) => {
11+
await test_driver.bless('request PiP window from top window');
12+
const pipWindow = await documentPictureInPicture.requestWindow();
13+
14+
await assert_throws_dom('NotAllowedError', pipWindow.DOMException, () => {
15+
pipWindow.resizeBy(10, 10);
16+
}, 'resizeBy() requires a user gesture for document picture-in-picture');
17+
await assert_throws_dom('NotAllowedError', pipWindow.DOMException, () => {
18+
pipWindow.resizeTo(400, 400);
19+
}, 'resizeTo() requires a user gesture for document picture-in-picture');
20+
});
21+
</script>
22+
</body>

0 commit comments

Comments
 (0)