tor-browser

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

close-method.window.js (1374B)


      1 function assert_closed_opener(w, closed, opener) {
      2  assert_equals(w.closed, closed);
      3  assert_equals(w.opener, opener);
      4 }
      5 
      6 async_test(t => {
      7  const openee = window.open();
      8  assert_closed_opener(openee, false, self);
      9  openee.onpagehide = t.step_func(() => {
     10    assert_closed_opener(openee, true, self);
     11    t.step_timeout(() => {
     12      assert_closed_opener(openee, true, null);
     13      t.done();
     14    }, 0);
     15  });
     16  openee.close();
     17  assert_closed_opener(openee, true, self);
     18 }, "window.close() queues a task to discard, but window.closed knows immediately");
     19 
     20 async_test(t => {
     21  const openee = window.open("", "greatname");
     22  assert_closed_opener(openee, false, self);
     23  openee.close();
     24  assert_closed_opener(openee, true, self);
     25  const openee2 = window.open("", "greatname");
     26  assert_not_equals(openee, openee2);
     27  assert_closed_opener(openee, true, self); // Ensure second window.open() call was synchronous
     28  openee2.onpagehide = t.step_func(() => {
     29    assert_closed_opener(openee2, true, self);
     30    t.step_timeout(() => {
     31      assert_closed_opener(openee, true, null);
     32      assert_closed_opener(openee2, true, null);
     33      t.done();
     34    }, 0);
     35  });
     36  openee2.close();
     37  assert_closed_opener(openee, true, self); // Ensure second close() call was synchronous
     38  assert_closed_opener(openee2, true, self);
     39 }, "window.close() affects name targeting immediately");