Lightpanda: the headless browser designed for AI and automation
test: record shadow lifecycle assertions in the async test scope
Aaron Wongd74cc1b5da07
diff --git a/src/browser/tests/frames/connected_shadow_iframe.html b/src/browser/tests/frames/connected_shadow_iframe.htmlindex 24f1d9688..8d9eeb128 100644--- a/src/browser/tests/frames/connected_shadow_iframe.html+++ b/src/browser/tests/frames/connected_shadow_iframe.html@@ -52,6 +52,8 @@<script id="shadow_iframes_disconnect_and_reconnect">(async () => {const state = await testing.async();+ const checks = [];+ const check = (expected, actual) => checks.push([expected, actual]);for (const mode of ['open', 'closed']) {const host = document.createElement('section');const shadow = host.attachShadow({ mode });@@ -64,20 +66,20 @@const load = () => new Promise(resolve => iframe.addEventListener('load', () => resolve('load'), { once: true }));const firstLoad = load();document.body.appendChild(host);- testing.expectEqual('load', await Promise.race([firstLoad, new Promise(resolve => setTimeout(() => resolve('timeout'), 500))]));+ check('load', await Promise.race([firstLoad, new Promise(resolve => setTimeout(() => resolve('timeout'), 500))]));const original = iframe.contentWindow;host.remove();- testing.expectEqual(null, iframe.contentWindow);- testing.expectEqual(null, iframe.contentDocument);+ check(null, iframe.contentWindow);+ check(null, iframe.contentDocument);const reloaded = load();document.body.appendChild(host);- testing.expectEqual('load', await Promise.race([reloaded, new Promise(resolve => setTimeout(() => resolve('timeout'), 500))]));- testing.expectTrue(iframe.contentWindow !== original);- testing.expectEqual('Reconnected', iframe.contentDocument.getElementById('marker').textContent);+ check('load', await Promise.race([reloaded, new Promise(resolve => setTimeout(() => resolve('timeout'), 500))]));+ check(true, iframe.contentWindow !== original);+ check('Reconnected', iframe.contentDocument.getElementById('marker').textContent);host.remove();}state.resolve();- await state.done();+ await state.done(() => { for (const [expected, actual] of checks) testing.expectEqual(expected, actual); });})();</script>@@ -91,7 +93,7 @@ const scopedStyle = document.createElement('style');scopedStyle.textContent = 'button { display: none; }';styledShadow.appendChild(scopedStyle);document.body.appendChild(styledHost);-testing.expectEqual('inline-block', getComputedStyle(outside).display);+testing.expectTrue(getComputedStyle(outside).display !== 'none');styledHost.remove();outside.remove();</script>