summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/microtasks/basic.any.js
blob: 4876e82b0db83cfce35ccbe552f9dd6f23a30c3a (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
// META: global=window,dedicatedworker,sharedworker
// META: script=ticker.js

promise_test(async t => {
  const getCount = ticker(1000);

  const importP = import("<invalid>");
  await promise_rejects_js(t, TypeError, importP, 'import() should reject');

  assert_less_than(getCount(), 1000);
}, "import() should not drain the microtask queue if it fails during specifier resolution");

promise_test(async t => {
  // Use Date.now() to ensure that the module is not in the module map
  const specifier = "./empty-module.js?" + Date.now();

  await import(specifier);

  const getCount = ticker(1000);
  await import(specifier);
  assert_less_than(getCount(), 1000);
}, "import() should not drain the microtask queue when loading an already loaded module");

promise_test(async t => {
  // Use Date.now() to ensure that the module is not in the module map
  const specifier = "./empty-module.js?" + Date.now();

  const getCount = ticker(1e6);
  await import(specifier);
  assert_equals(getCount(), 1e6);
}, "import() should drain the microtask queue when fetching a new module");