tor-browser

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

browser_ignore_updates_crashed_tabs.js (3266B)


      1 // This test checks that browsers are removed from the SessionStore's
      2 // crashed browser set at a correct time, so that it can stop ignoring update
      3 // events coming from those browsers.
      4 
      5 /**
      6 * Open a tab, crash it, navigate it to a remote uri, and check that it
      7 * is removed from a crashed set.
      8 */
      9 add_task(async function test_update_crashed_tab_after_navigate_to_remote() {
     10  let tab = BrowserTestUtils.addTab(gBrowser, "https://example.com/");
     11  let browser = tab.linkedBrowser;
     12  gBrowser.selectedTab = tab;
     13  await promiseBrowserLoaded(browser);
     14  ok(
     15    !SessionStore.isBrowserInCrashedSet(browser),
     16    "browser is not in the crashed set"
     17  );
     18 
     19  await BrowserTestUtils.crashFrame(browser);
     20  ok(
     21    SessionStore.isBrowserInCrashedSet(browser),
     22    "browser is in the crashed set"
     23  );
     24 
     25  BrowserTestUtils.startLoadingURIString(browser, "https://example.org/");
     26  await BrowserTestUtils.browserLoaded(browser, false, "https://example.org/");
     27  ok(
     28    !SessionStore.isBrowserInCrashedSet(browser),
     29    "browser is not in the crashed set"
     30  );
     31  ok(
     32    !tab.hasAttribute("crashed"),
     33    "Tab shouldn't be marked as crashed anymore."
     34  );
     35  gBrowser.removeTab(tab);
     36 });
     37 
     38 /**
     39 * Open a tab, crash it, navigate it to a non-remote uri, and check that it
     40 * is removed from a crashed set.
     41 */
     42 add_task(async function test_update_crashed_tab_after_navigate_to_non_remote() {
     43  let tab = BrowserTestUtils.addTab(gBrowser, "https://example.com/");
     44  let browser = tab.linkedBrowser;
     45  gBrowser.selectedTab = tab;
     46  await promiseBrowserLoaded(browser);
     47  ok(
     48    !SessionStore.isBrowserInCrashedSet(browser),
     49    "browser is not in the crashed set"
     50  );
     51 
     52  await BrowserTestUtils.crashFrame(browser);
     53  ok(
     54    SessionStore.isBrowserInCrashedSet(browser),
     55    "browser is in the crashed set"
     56  );
     57 
     58  BrowserTestUtils.startLoadingURIString(browser, "about:mozilla");
     59  await BrowserTestUtils.browserLoaded(browser, false, "about:mozilla");
     60  ok(
     61    !SessionStore.isBrowserInCrashedSet(browser),
     62    "browser is not in the crashed set"
     63  );
     64  ok(
     65    !gBrowser.selectedTab.hasAttribute("crashed"),
     66    "Tab shouldn't be marked as crashed anymore."
     67  );
     68  gBrowser.removeTab(tab);
     69 });
     70 
     71 /**
     72 * Open a tab, crash it, restore it from history, and check that it
     73 * is removed from a crashed set.
     74 */
     75 add_task(async function test_update_crashed_tab_after_session_restore() {
     76  let tab = BrowserTestUtils.addTab(gBrowser, "https://example.com/");
     77  let browser = tab.linkedBrowser;
     78  gBrowser.selectedTab = tab;
     79  await promiseBrowserLoaded(browser);
     80  ok(
     81    !SessionStore.isBrowserInCrashedSet(browser),
     82    "browser is not in the crashed set"
     83  );
     84 
     85  await BrowserTestUtils.crashFrame(browser);
     86  ok(
     87    SessionStore.isBrowserInCrashedSet(browser),
     88    "browser is in the crashed set"
     89  );
     90 
     91  let tabRestoredPromise = promiseTabRestored(tab);
     92  // Click restoreTab button
     93  await SpecialPowers.spawn(browser, [], () => {
     94    let button = content.document.getElementById("restoreTab");
     95    button.click();
     96  });
     97  await tabRestoredPromise;
     98  ok(
     99    !tab.hasAttribute("crashed"),
    100    "Tab shouldn't be marked as crashed anymore."
    101  );
    102  ok(
    103    !SessionStore.isBrowserInCrashedSet(browser),
    104    "browser is not in the crashed set"
    105  );
    106 
    107  gBrowser.removeTab(tab);
    108 });