blob: 53199d619c15cf88f081dc12eff94eabdd262dd8 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="utf-8">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/callback-function-detached-frame-common.js"></script>
<body>
<script>
const IFRAME_SRC = "resources/callback-function-detached-frame-queue-microtask-iframe.html";
promise_test(async t => {
window.__qm0Calls__ = 0;
const iframe = await createIframe(t, IFRAME_SRC);
iframe.contentWindow.callQueueMicrotask("__qm0Calls__");
await sleep(10);
assert_equals(window.__qm0Calls__, 1);
}, "Callback function, originated in an <iframe>, is invoked if <iframe> is connected");
promise_test(async t => {
window.__qm1Calls__ = 0;
const iframe = await createIframe(t, IFRAME_SRC);
iframe.contentWindow.callQueueMicrotask("__qm1Calls__", Function);
iframe.remove();
assert_equals(iframe.contentWindow, null);
await sleep(10);
assert_equals(window.__qm1Calls__, 1);
}, "Callback function, originated in an <iframe> via main window's Function constructor, is invoked even if <iframe> is disconnected");
promise_test(async t => {
window.__qm2Calls__ = 0;
const iframe = await createIframe(t, IFRAME_SRC);
iframe.contentWindow.callQueueMicrotask("__qm2Calls__");
iframe.remove();
assert_equals(iframe.contentWindow, null);
await sleep(10);
assert_equals(window.__qm2Calls__, 0);
}, "Callback function, originated in an <iframe>, is not invoked if <iframe> is disconnected");
</script>