summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/delay-load-event.html
blob: 5ec6433e65b59c026209964002a8db47f3f97a94 (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
<!DOCTYPE html>
<title>Dynamic imports don't delay the load event</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
// Dynamic imports don't #delay-the-load-event.
// Therefore, Window load event would be fired
// just after the dynamic import() below starts.
window.loaded = [];
window.addEventListener('load', () => loaded.push('Window load event'));
promise_test(t => {
  loaded.push('import start');
  // This 'loading' log is added to detect the previous Chromium behavior
  // where the Window load event is delayed until just before script
  // element's load event.
  t.step_timeout(() => loaded.push('loading'), 1000);
  return import("../resources/slow-module.js?pipe=trickle(d2)")
    .then(() => {
        assert_array_equals(
            loaded,
            ['import start', 'Window load event', 'loading', 'slow'],
            "Window load event shouldn't be delayed by dynamic imports");
      });
}, "Dynamic imports don't delay the load event.");
</script>