tor-browser

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

browser_bug491431.js (1237B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 var testPage = "data:text/plain,test bug 491431 Page";
      6 
      7 function test() {
      8  waitForExplicitFinish();
      9 
     10  let newWin, tabA, tabB;
     11 
     12  // test normal close
     13  tabA = BrowserTestUtils.addTab(gBrowser, testPage);
     14  gBrowser.tabContainer.addEventListener(
     15    "TabClose",
     16    function (firstTabCloseEvent) {
     17      ok(!firstTabCloseEvent.detail.adoptedBy, "This was a normal tab close");
     18 
     19      // test tab close by moving
     20      tabB = BrowserTestUtils.addTab(gBrowser, testPage);
     21      gBrowser.tabContainer.addEventListener(
     22        "TabClose",
     23        function (secondTabCloseEvent) {
     24          executeSoon(function () {
     25            ok(
     26              secondTabCloseEvent.detail.adoptedBy,
     27              "This was a tab closed by moving"
     28            );
     29 
     30            // cleanup
     31            newWin.close();
     32            executeSoon(finish);
     33          });
     34        },
     35        { capture: true, once: true }
     36      );
     37      newWin = gBrowser.replaceTabWithWindow(tabB);
     38    },
     39    { capture: true, once: true }
     40  );
     41  gBrowser.removeTab(tabA);
     42 }