11cb0ef41Sopenharmony_ci<!DOCTYPE html>
21cb0ef41Sopenharmony_ci<meta charset="utf-8">
31cb0ef41Sopenharmony_ci<title>Entry settings object for host functions</title>
41cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
51cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
61cb0ef41Sopenharmony_ci<script src="/wasm/jsapi/wasm-module-builder.js"></script>
71cb0ef41Sopenharmony_ci<script src="/wasm/jsapi/functions/helper.js"></script>
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci<!-- This is the entry page, so window.open() should resolve relative to it, even inside host functions. -->
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci<iframe src="resources/entry-incumbent.html"></iframe>
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ci<script>
141cb0ef41Sopenharmony_cisetup({ explicit_done: true });
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciconst relativeURL = "resources/window-to-open.html";
171cb0ef41Sopenharmony_ciconst expectedURL = (new URL(relativeURL, location.href)).href;
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciconst incumbentWindow = frames[0];
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ciwindow.onload = () => {
221cb0ef41Sopenharmony_ci  async_test(t => {
231cb0ef41Sopenharmony_ci    const w = incumbentWindow.runWindowOpenVeryIndirectly(relativeURL);
241cb0ef41Sopenharmony_ci    w.onload = t.step_func_done(() => {
251cb0ef41Sopenharmony_ci      t.add_cleanup(() => w.close());
261cb0ef41Sopenharmony_ci      assert_equals(w.location.href, expectedURL);
271cb0ef41Sopenharmony_ci    });
281cb0ef41Sopenharmony_ci  }, "Sanity check: this all works as expected synchronously");
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci  async_test(t => {
311cb0ef41Sopenharmony_ci    // No t.step_func because that could change the realms
321cb0ef41Sopenharmony_ci    call_later(() => {
331cb0ef41Sopenharmony_ci      const w = incumbentWindow.runWindowOpenVeryIndirectly(relativeURL);
341cb0ef41Sopenharmony_ci      w.onload = t.step_func_done(() => {
351cb0ef41Sopenharmony_ci        t.add_cleanup(() => w.close());
361cb0ef41Sopenharmony_ci        assert_equals(w.location.href, expectedURL);
371cb0ef41Sopenharmony_ci      });
381cb0ef41Sopenharmony_ci    });
391cb0ef41Sopenharmony_ci  }, "Start function");
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ci  done();
421cb0ef41Sopenharmony_ci};
431cb0ef41Sopenharmony_ci</script>
44