Automatic update from web-platform-tests [CE] Add `oncancel` event to HTMLUserMediaElement. This change introduces a new `cancel` event for the `<usermedia>` element. This event is dispatched when the user explicitly denies or dismisses the permission prompt associated with the element. Spec: https://w3c.github.io/mediacapture-extensions/#the-usermedia-html-element Bug: 519071684 Change-Id: Ibccf36b78841809b501f144ea46a0cc2c6026c5f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7882422 Auto-Submit: Ravjit Uppal <ravjit@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1645659} -- wpt-commits: e613ef4eb8987976c3614017eda9fb9d6a9ab2c2 wpt-pr: 60566
64 lines
2.2 KiB
HTML
64 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset="utf-8">
|
|
<title>HTMLUserMediaElement Test: iframe integration</title>
|
|
<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 src="resources/pepc-helper.js"></script>
|
|
<body>
|
|
<script>
|
|
promise_test(async (t) => {
|
|
const iframe = document.createElement('iframe');
|
|
// Iframe without allow="camera" or "microphone"
|
|
iframe.srcdoc = `
|
|
<!DOCTYPE html>
|
|
<usermedia id="um"></usermedia>
|
|
<script>
|
|
const um = document.getElementById('um');
|
|
um.setConstraints({video: {}, audio: {}});
|
|
let onstream_fired = false;
|
|
um.onstream = () => { onstream_fired = true; };
|
|
window.addEventListener('message', async (e) => {
|
|
if (e.data === 'check_result') {
|
|
window.parent.postMessage({
|
|
error: um.error ? um.error.name : null,
|
|
stream: um.stream ? true : false,
|
|
onstream_fired
|
|
}, '*');
|
|
}
|
|
});
|
|
<\/script>
|
|
`;
|
|
document.body.appendChild(iframe);
|
|
|
|
await new Promise(resolve => {
|
|
iframe.onload = resolve;
|
|
});
|
|
|
|
// Grant permission in the main frame, but it shouldn't matter because the iframe doesn't have the permissions policy delegated.
|
|
await test_driver.set_permission({name: 'camera'}, 'granted');
|
|
await test_driver.set_permission({name: 'microphone'}, 'granted');
|
|
|
|
const um = iframe.contentDocument.getElementById('um');
|
|
|
|
// Wait until the element is clickable.
|
|
await new Promise(resolve => t.step_timeout(resolve, PEPC_CLICK_DELAY));
|
|
await test_driver.click(um);
|
|
|
|
const responsePromise = new Promise(resolve => {
|
|
window.addEventListener('message', e => {
|
|
resolve(e.data);
|
|
}, {once: true});
|
|
});
|
|
|
|
// Ask the iframe to send the result
|
|
iframe.contentWindow.postMessage('check_result', '*');
|
|
|
|
const result = await responsePromise;
|
|
assert_equals(result.stream, false, "Stream should not be created in iframe without permissions policy delegation");
|
|
assert_equals(result.onstream_fired, false, "onstream event should not be fired");
|
|
}, "A usermedia element in an iframe without permissions policy delegation should be blocked");
|
|
</script>
|
|
</body>
|