tor-browser

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

test_pause_exceptions-01.js (1068B)


      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 will cause the debuggee to pause
      8 * when an exception is thrown.
      9 */
     10 
     11 add_task(
     12  threadFrontTest(async ({ threadFront, debuggee, commands }) => {
     13    await executeOnNextTickAndWaitForPause(
     14      () => evaluateTestCode(debuggee),
     15      threadFront
     16    );
     17 
     18    await commands.threadConfigurationCommand.updateConfiguration({
     19      pauseOnExceptions: true,
     20      ignoreCaughtExceptions: false,
     21    });
     22    const packet = await resumeAndWaitForPause(threadFront);
     23    Assert.equal(packet.why.type, "exception");
     24    Assert.equal(packet.why.exception, 42);
     25 
     26    await threadFront.resume();
     27  })
     28 );
     29 
     30 function evaluateTestCode(debuggee) {
     31  /* eslint-disable no-throw-literal */
     32  // prettier-ignore
     33  debuggee.eval("(" + function () {
     34    function stopMe() {
     35      debugger;
     36      throw 42;
     37    }
     38    try {
     39      stopMe();
     40    } catch (e) {}
     41  } + ")()");
     42  /* eslint-enable no-throw-literal */
     43 }