tor-browser

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

browser_crash_report.js (3389B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 declTest("crash actor", {
      6  allFrames: true,
      7 
      8  async test() {
      9    if (!("@mozilla.org/toolkit/crash-reporter;1" in Cc)) {
     10      ok(true, "Cannot test crash annotations without a crash reporter");
     11      return;
     12    }
     13 
     14    {
     15      info("Creating a new tab.");
     16      let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
     17      let newTabBrowser = newTab.linkedBrowser;
     18 
     19      let parent =
     20        newTabBrowser.browsingContext.currentWindowGlobal.getActor(
     21          "TestWindow"
     22        );
     23      ok(parent, "JSWindowActorParent should have value.");
     24 
     25      await SpecialPowers.spawn(newTabBrowser, [], async function () {
     26        let child = content.windowGlobalChild;
     27        ok(child, "WindowGlobalChild should have value.");
     28        is(
     29          child.isInProcess,
     30          false,
     31          "Actor should be loaded in the content process."
     32        );
     33        // Make sure that the actor is loaded.
     34        let actorChild = child.getActor("TestWindow");
     35        is(
     36          actorChild.show(),
     37          "TestWindowChild",
     38          "actor show should have value."
     39        );
     40        is(
     41          actorChild.manager,
     42          child,
     43          "manager should match WindowGlobalChild."
     44        );
     45      });
     46 
     47      info(
     48        "Crashing from withing an actor. We should have an actor name and a message name."
     49      );
     50      let report = await BrowserTestUtils.crashFrame(
     51        newTabBrowser,
     52        /* shouldShowTabCrashPage = */ false,
     53        /* shouldClearMinidumps =  */ true,
     54        /* browsingContext = */ null,
     55        { asyncCrash: false }
     56      );
     57 
     58      is(report.JSActorName, "BrowserTestUtils");
     59      is(report.JSActorMessage, "BrowserTestUtils:CrashFrame");
     60 
     61      BrowserTestUtils.removeTab(newTab);
     62    }
     63 
     64    {
     65      info("Creating a new tab for async crash");
     66      let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
     67      let newTabBrowser = newTab.linkedBrowser;
     68 
     69      let parent =
     70        newTabBrowser.browsingContext.currentWindowGlobal.getActor(
     71          "TestWindow"
     72        );
     73      ok(parent, "JSWindowActorParent should have value.");
     74 
     75      await SpecialPowers.spawn(newTabBrowser, [], async function () {
     76        let child = content.windowGlobalChild;
     77        ok(child, "WindowGlobalChild should have value.");
     78        is(
     79          child.isInProcess,
     80          false,
     81          "Actor should be loaded in the content process."
     82        );
     83        // Make sure that the actor is loaded.
     84        let actorChild = child.getActor("TestWindow");
     85        is(
     86          actorChild.show(),
     87          "TestWindowChild",
     88          "actor show should have value."
     89        );
     90        is(
     91          actorChild.manager,
     92          child,
     93          "manager should match WindowGlobalChild."
     94        );
     95      });
     96 
     97      info(
     98        "Crashing from without an actor. We should have neither an actor name nor a message name."
     99      );
    100      let report = await BrowserTestUtils.crashFrame(
    101        newTabBrowser,
    102        /* shouldShowTabCrashPage = */ false,
    103        /* shouldClearMinidumps =  */ true,
    104        /* browsingContext = */ null,
    105        { asyncCrash: true }
    106      );
    107 
    108      ok(!report.JSActorName);
    109      ok(!report.JSActorMessage);
    110 
    111      BrowserTestUtils.removeTab(newTab);
    112    }
    113  },
    114 });