// This file contains general helpers for navigation/history tests. The goal is // to make tests more imperative and ordered, instead of requiring lots of // nested callbacks and jumping back and forth. However, // html/browsers/browsing-the-web/remote-context-helper/resources/remote-context-helper.js // might be even better at that, so prefer that when you can. // // TODO(domenic): consider unifying with // overlapping-navigations-and-traversals/resources/helpers.mjs. window.openWindow = (url, t) => { const w = window.open(url); t?.add_cleanup(() => w.close()); return new Promise(resolve => { w.addEventListener("load", () => resolve(w), { once: true }); }); }; window.addIframe = (url = "/common/blank.html", doc = document) => { const iframe = doc.createElement("iframe"); iframe.src = url; doc.body.append(iframe); return new Promise(resolve => { iframe.addEventListener("load", () => resolve(iframe), { once: true }); }); }; window.addSrcdocIframe = async () => { const iframe = document.createElement("iframe"); iframe.srcdoc = `