Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

  • This test has a WPT meta file that expects 1 subtest issues.
  • This WPT test may be referenced by the following Test IDs:
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=cross-origin&frame=direct&visibility=display - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=cross-origin&frame=direct&visibility=visibility - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=cross-origin&frame=direct&visibility=zero-size - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=cross-origin&frame=nested&visibility=display - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=cross-origin&frame=nested&visibility=visibility - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=cross-origin&frame=nested&visibility=zero-size - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=same-origin&frame=direct&visibility=display - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=same-origin&frame=direct&visibility=visibility - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=same-origin&frame=direct&visibility=zero-size - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=same-origin&frame=nested&visibility=display - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=same-origin&frame=nested&visibility=visibility - WPT Dashboard Interop Dashboard
    • /webaudio/the-audio-api/media-playback-while-not-visible-permission-policy/interrupt-when-created-hidden.tentative.sub.html?origin=same-origin&frame=nested&visibility=zero-size - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>
AudioContext is interrupted when its iframe is created hidden
(media-playback-while-not-visible permission policy)
</title>
<meta name="variant" content="?origin=same-origin&frame=direct&visibility=display">
<meta name="variant" content="?origin=same-origin&frame=direct&visibility=visibility">
<meta name="variant" content="?origin=same-origin&frame=direct&visibility=zero-size">
<meta name="variant" content="?origin=same-origin&frame=nested&visibility=display">
<meta name="variant" content="?origin=same-origin&frame=nested&visibility=visibility">
<meta name="variant" content="?origin=same-origin&frame=nested&visibility=zero-size">
<meta name="variant" content="?origin=cross-origin&frame=direct&visibility=display">
<meta name="variant" content="?origin=cross-origin&frame=direct&visibility=visibility">
<meta name="variant" content="?origin=cross-origin&frame=direct&visibility=zero-size">
<meta name="variant" content="?origin=cross-origin&frame=nested&visibility=display">
<meta name="variant" content="?origin=cross-origin&frame=nested&visibility=visibility">
<meta name="variant" content="?origin=cross-origin&frame=nested&visibility=zero-size">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/media-playback-while-not-visible-utils.js"></script>
<body>
<script>
const SAME_ORIGIN_BASE = new URL('resources/', location.href).href;
const CROSS_ORIGIN_BASE =
'media-playback-while-not-visible-permission-policy/resources/';
const params = new URLSearchParams(location.search);
const origin = params.get('origin');
const visibility = params.get('visibility');
const frame = params.get('frame');
const base = origin === 'cross-origin' ? CROSS_ORIGIN_BASE : SAME_ORIGIN_BASE;
// Scenario: an AudioContext created in an iframe that is hidden before being
// attached to the DOM should be interrupted instead of continuing to run.
promise_test(
async t => {
const iframe = await createIframe(t, frame, base, /*hidden=*/ visibility);
// The AudioContext can initially start running before the hidden state
// reaches nested or cross-origin frames. Repeated resume() calls recheck
// visibility until the context transitions to interrupted.
await t.step_wait(async () => {
if (await queryAudioContextState(iframe) === 'interrupted') {
return true;
}
await sendCommandToAudioContext(iframe, 'resume');
return await queryAudioContextState(iframe) === 'interrupted';
}, 'waiting for AudioContext to be interrupted');
},
`${origin} ${frame}: AudioContext in an iframe created hidden should be ` +
`interrupted (visibility=${visibility})`);
</script>
</body>