11cb0ef41Sopenharmony_ci<!DOCTYPE html> 21cb0ef41Sopenharmony_ci<meta charset="utf-8"> 31cb0ef41Sopenharmony_ci<title>Entry settings object for host functions when the function realm is different from the test realm</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 what would normally be considered the entry page. However, we use functions from the 101cb0ef41Sopenharmony_ci resources/function/function.html realm. So window.open() should resolve relative to that realm 111cb0ef41Sopenharmony_ci inside host functions. --> 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci<iframe src="resources/entry-incumbent.html"></iframe> 141cb0ef41Sopenharmony_ci<iframe src="resources/function/function.html" id="function-frame"></iframe> 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci<script> 171cb0ef41Sopenharmony_cisetup({ explicit_done: true }); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciconst relativeURL = "resources/window-to-open.html"; 201cb0ef41Sopenharmony_ciconst expectedURL = (new URL(relativeURL, document.querySelector("#function-frame").src)).href; 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciconst incumbentWindow = frames[0]; 231cb0ef41Sopenharmony_ciconst functionWindow = frames[1]; 241cb0ef41Sopenharmony_ciconst FunctionFromAnotherWindow = functionWindow.Function; 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciwindow.onload = () => { 271cb0ef41Sopenharmony_ci async_test(t => { 281cb0ef41Sopenharmony_ci t.add_cleanup(() => { delete functionWindow.args; }); 291cb0ef41Sopenharmony_ci functionWindow.args = [incumbentWindow, relativeURL, t, assert_equals, expectedURL]; 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci const func = FunctionFromAnotherWindow(` 321cb0ef41Sopenharmony_ci const [incumbentWindow, relativeURL, t, assert_equals, expectedURL] = window.args; 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci const w = incumbentWindow.runWindowOpenVeryIndirectly(relativeURL); 351cb0ef41Sopenharmony_ci w.onload = t.step_func_done(() => { 361cb0ef41Sopenharmony_ci t.add_cleanup(() => w.close()); 371cb0ef41Sopenharmony_ci assert_equals(w.location.href, expectedURL); 381cb0ef41Sopenharmony_ci }); 391cb0ef41Sopenharmony_ci `); 401cb0ef41Sopenharmony_ci call_later(func); 411cb0ef41Sopenharmony_ci }, "Start function"); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci done(); 441cb0ef41Sopenharmony_ci}; 451cb0ef41Sopenharmony_ci</script> 46