1<!DOCTYPE html> 2<meta charset="utf-8"> 3<title>Entry settings object for host functions when the function realm is different from the test realm</title> 4<script src="/resources/testharness.js"></script> 5<script src="/resources/testharnessreport.js"></script> 6<script src="/wasm/jsapi/wasm-module-builder.js"></script> 7<script src="/wasm/jsapi/functions/helper.js"></script> 8 9<!-- This is what would normally be considered the entry page. However, we use functions from the 10 resources/function/function.html realm. So window.open() should resolve relative to that realm 11 inside host functions. --> 12 13<iframe src="resources/entry-incumbent.html"></iframe> 14<iframe src="resources/function/function.html" id="function-frame"></iframe> 15 16<script> 17setup({ explicit_done: true }); 18 19const relativeURL = "resources/window-to-open.html"; 20const expectedURL = (new URL(relativeURL, document.querySelector("#function-frame").src)).href; 21 22const incumbentWindow = frames[0]; 23const functionWindow = frames[1]; 24const FunctionFromAnotherWindow = functionWindow.Function; 25 26window.onload = () => { 27 async_test(t => { 28 t.add_cleanup(() => { delete functionWindow.args; }); 29 functionWindow.args = [incumbentWindow, relativeURL, t, assert_equals, expectedURL]; 30 31 const func = FunctionFromAnotherWindow(` 32 const [incumbentWindow, relativeURL, t, assert_equals, expectedURL] = window.args; 33 34 const w = incumbentWindow.runWindowOpenVeryIndirectly(relativeURL); 35 w.onload = t.step_func_done(() => { 36 t.add_cleanup(() => w.close()); 37 assert_equals(w.location.href, expectedURL); 38 }); 39 `); 40 call_later(func); 41 }, "Start function"); 42 43 done(); 44}; 45</script> 46