-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a tentative WPT for fullscreen request delegation.
Bug: 1293083 Change-Id: I3ac1d58299fc660c1e55834f75c80242e5bba5ab Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3636299 Reviewed-by: Mike Wasserman <msw@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/main@{#1001633}
- Loading branch information
1 parent
70bd315
commit eb3bc42
Showing
3 changed files
with
113 additions
and
0 deletions.
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
83 changes: 83 additions & 0 deletions
83
...rty/blink/web_tests/external/wpt/fullscreen/api/delegate-request.https.sub.tentative.html
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,83 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Tentative due to: | ||
https://github.com/WICG/capability-delegation/issues/10 | ||
--> | ||
<title>Fullscreen request delegation test</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-actions.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
|
||
<div> | ||
Verifies that element.requestFullscreen() call from a cross-origin subframe without user | ||
activation works if and only if the top frame has user activation and it delegates the capability | ||
to the subframe. | ||
</div> | ||
|
||
<iframe allow="fullscreen" width="300px" height="50px" | ||
src="https://{{hosts[alt][www]}}:{{ports[https][0]}}/fullscreen/api/resources/delegate-request-subframe.html"> | ||
</iframe> | ||
|
||
<script> | ||
// Returns a |Promise| that gets resolved with |event.data| when |window| | ||
// receives from |source| a "message" event whose |event.data.type| matches the string | ||
// |message_data_type|. | ||
function getMessageData(message_data_type, source) { | ||
return new Promise(resolve => { | ||
function waitAndRemove(e) { | ||
if (e.source != source || !e.data || e.data.type != message_data_type) | ||
return; | ||
window.removeEventListener("message", waitAndRemove); | ||
resolve(e.data); | ||
} | ||
window.addEventListener("message", waitAndRemove); | ||
}); | ||
} | ||
|
||
promise_setup(async () => { | ||
// Make sure the iframe has loaded. | ||
await getMessageData("subframe-loaded", frames[0]); | ||
}); | ||
|
||
const target_origin = "https://{{hosts[alt][www]}}:{{ports[https][0]}}"; | ||
const request = {"type": "make-fullscreen-request"}; | ||
|
||
promise_test(async () => { | ||
let result_promise = getMessageData("result", frames[0]); | ||
frames[0].postMessage(request, {targetOrigin: target_origin}); | ||
let data = await result_promise; | ||
|
||
assert_equals(data.result, "failure"); | ||
}, "Fullscreen-request from a subframe fails without delegation when the top frame has no user activation"); | ||
|
||
promise_test(async () => { | ||
let result_promise = getMessageData("result", frames[0]); | ||
frames[0].postMessage(request, {targetOrigin: target_origin, | ||
delegate: "fullscreen"}); | ||
let data = await result_promise; | ||
|
||
assert_equals(data.result, "failure"); | ||
}, "Fullscreen-request from a subframe fails with delegation when the top frame has no user activation"); | ||
|
||
promise_test(async () => { | ||
let result_promise = getMessageData("result", frames[0]); | ||
await test_driver.bless(); | ||
frames[0].postMessage(request, {targetOrigin: target_origin}); | ||
let data = await result_promise; | ||
|
||
assert_equals(data.result, "failure"); | ||
}, "Fullscreen-request from a subframe fails without delegation when the top frame has user activation"); | ||
|
||
promise_test(async () => { | ||
let result_promise = getMessageData("result", frames[0]); | ||
await test_driver.bless(); | ||
frames[0].postMessage(request, {targetOrigin: target_origin, | ||
delegate: "fullscreen"}); | ||
let data = await result_promise; | ||
|
||
assert_equals(data.result, "success"); | ||
}, "Fullscreen-request from a subframe succeeds with delegation when the top frame has user activation"); | ||
|
||
</script> |
28 changes: 28 additions & 0 deletions
28
...arty/blink/web_tests/external/wpt/fullscreen/api/resources/delegate-request-subframe.html
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,28 @@ | ||
<!DOCTYPE html> | ||
<title>Fullscreen request delegation test: subframe</title> | ||
<body>Subframe body</body> | ||
|
||
<script> | ||
function reportResult(msg) { | ||
window.top.postMessage({"type": "result", "result": msg}, "*"); | ||
} | ||
|
||
document.addEventListener('fullscreenchange', () => { | ||
if (document.fullscreenElement) { | ||
reportResult("success"); | ||
document.exitFullscreen(); | ||
} | ||
}); | ||
|
||
document.addEventListener('fullscreenerror', () => { | ||
reportResult("failure"); | ||
}); | ||
|
||
window.addEventListener("message", e => { | ||
if (e.data.type == "make-fullscreen-request") { | ||
document.body.requestFullscreen(); | ||
} | ||
}); | ||
|
||
window.top.postMessage({"type": "subframe-loaded"}, "*"); | ||
</script> |