summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/moving-between-documents/ordering/in-order.html
blob: 6a3e2b54a7738164d47630e2e276f9880c9549a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="help" href="https://html.spec.whatwg.org/C/#list-of-scripts-that-will-execute-in-order-as-soon-as-possible">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="helper.js"></script>
<body>
<script>
const t = async_test('Script elements (in-order) still block subsequent in-order scripts in the original Document after moved to another Document');
const start_time = performance.now();
const iframe = document.createElement('iframe');
document.body.appendChild(iframe);

const onScript2Evaluated = t.step_func_done(() => {
  // `script1` should remain the
  // #list-of-scripts-that-will-execute-in-order-as-soon-as-possible of the
  // original Document and thus blocks `script2` evaluation until it is loaded.
  assert_greater_than(performance.now() - start_time, 2000,
      'In-order scripts should block subsequent in-order scripts');
});

const script1 = document.createElement('script');
script1.async = false;
script1.setAttribute('src', '../../resources/throw.js?pipe=trickle(d2)');
document.body.appendChild(script1);

const script2 = document.createElement('script');
script2.async = false;
script2.setAttribute('src', 'data:text/javascript,onScript2Evaluated()');
document.body.appendChild(script2);

t.step_timeout(() => {
  iframe.contentDocument.body.appendChild(script1);
}, 1000);
</script>