servo/tests/wpt/web-platform-tests/client-hints/resources/open-and-add-load-event.js

9 lines
No EOL
445 B
JavaScript

function open_and_add_load_event(href, func) {
// While not practically possible, opening "blank" first and setting the
// href after allows for the theoretical possibility of registering the event
// after the window is loaded.
let popup_window = window.open("about:blank");
assert_not_equals(popup_window, null, "Popup windows not allowed?");
popup_window.addEventListener('load', func, false);
popup_window.location.href=href;
}