tor-browser

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

test_pause_exceptions-02.js (1194B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Test that setting pauseOnExceptions to true when the debugger isn't in a
      8 * paused state will not cause the debuggee to pause when an exception is thrown.
      9 */
     10 
     11 add_task(
     12  threadFrontTest(async ({ threadFront, debuggee, commands }) => {
     13    await commands.threadConfigurationCommand.updateConfiguration({
     14      pauseOnExceptions: true,
     15      ignoreCaughtExceptions: false,
     16    });
     17 
     18    const packet = await executeOnNextTickAndWaitForPause(
     19      () => evaluateTestCode(debuggee),
     20      threadFront
     21    );
     22 
     23    Assert.equal(packet.why.type, "exception");
     24    Assert.equal(packet.why.exception, 42);
     25    await threadFront.resume();
     26  })
     27 );
     28 
     29 function evaluateTestCode(debuggee) {
     30  /* eslint-disable no-throw-literal */
     31  // prettier-ignore
     32  debuggee.eval("(" + function () {    // 1
     33    function stopMe() {                // 2
     34      throw 42;                        // 3
     35    }                                  // 4
     36    try {                              // 5
     37      stopMe();                        // 6
     38    } catch (e) {}                     // 7
     39  } + ")()");
     40 }