summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/wasm/jsapi/functions/entry.html
blob: 15018074491054dcb9e2f95c0d9c9d1691c9161a (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
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<meta charset="utf-8">
<title>Entry settings object for host functions</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/wasm/jsapi/wasm-module-builder.js"></script>
<script src="/wasm/jsapi/functions/helper.js"></script>

<!-- This is the entry page, so window.open() should resolve relative to it, even inside host functions. -->

<iframe src="resources/entry-incumbent.html"></iframe>

<script>
setup({ explicit_done: true });

const relativeURL = "resources/window-to-open.html";
const expectedURL = (new URL(relativeURL, location.href)).href;

const incumbentWindow = frames[0];

window.onload = () => {
  async_test(t => {
    const w = incumbentWindow.runWindowOpenVeryIndirectly(relativeURL);
    w.onload = t.step_func_done(() => {
      t.add_cleanup(() => w.close());
      assert_equals(w.location.href, expectedURL);
    });
  }, "Sanity check: this all works as expected synchronously");

  async_test(t => {
    // No t.step_func because that could change the realms
    call_later(() => {
      const w = incumbentWindow.runWindowOpenVeryIndirectly(relativeURL);
      w.onload = t.step_func_done(() => {
        t.add_cleanup(() => w.close());
        assert_equals(w.location.href, expectedURL);
      });
    });
  }, "Start function");

  done();
};
</script>