Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /container-timing/tentative/iframe-isolation-same-origin.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>Container Timing: paints in a same-origin iframe do not leak to the parent observer</title>
<body>
<style>
body {
margin: 0;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function(t) {
assert_implements(window.PerformanceContainerTiming, "PerformanceContainerTiming is not implemented");
// The parent observer must never fire: an iframe's paints belong to the
// iframe's own performance timeline, not the parent's. This guard is active
// for the whole test, so any leaked entry fails immediately.
const parentObserver = new PerformanceObserver(t.step_func(function(entryList) {
assert_unreached('Parent observer must not receive iframe paints. Got: ' +
entryList.getEntries().map(e => e.identifier).join(','));
}));
parentObserver.observe({entryTypes: ['container']});
// Drive completion off the child's own postMessage: it proves the iframe
// actually painted a container entry, so parent silence is meaningful
// rather than vacuous. Once the child reports, wait a short grace period so
// that an (erroneously) leaked parent entry would have a chance to be
// delivered before we declare success.
window.addEventListener('message', t.step_func(function(e) {
if (!e.data || e.data.kind !== 'child-entries') {
return;
}
assert_equals(e.data.count, 1,
'iframe observer should see exactly 1 container entry');
assert_equals(e.data.identifier, 'child_ct',
"iframe entry identifier should be 'child_ct'");
t.step_timeout(t.step_func_done(function() {}), 500);
}));
const iframe = document.createElement('iframe');
iframe.src = 'resources/iframe-isolation-subframe.html';
document.body.appendChild(iframe);
}, 'Container Timing entries from a same-origin iframe do not appear in the parent observer.');
</script>
</body>