tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

open-and-add-load-event.js (889B)


      1 function open_and_add_load_event(href) {
      2  return new Promise((resolve) => {
      3    // While not practically possible, opening "blank" first and setting the
      4    // href after allows for the theoretical possibility of registering the event
      5    // after the window is loaded.
      6    let popup_window = window.open("/resources/blank.html");
      7    assert_not_equals(popup_window, null, "Popup windows not allowed?");
      8    popup_window.addEventListener('load', resolve, {once: true});
      9    popup_window.location.href = href;
     10  });
     11 }
     12 
     13 async function open_and_expect_headers(href) {
     14  let e = await new Promise(resolve => {
     15    let popup_window = window.open("/resources/blank.html");
     16    assert_not_equals(popup_window, null, "Popup windows not allowed?");
     17    window.addEventListener('message', resolve, false);
     18    popup_window.location.href = href;
     19  });
     20 
     21  assert_equals(e.data, "PASS");
     22  return e;
     23 }