toolkit/devtools/server/tests/unit/test_pause_exceptions-01.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/server/tests/unit/test_pause_exceptions-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Test that setting pauseOnExceptions to true will cause the debuggee to pause
     1.9 + * when an exceptions is thrown.
    1.10 + */
    1.11 +
    1.12 +var gDebuggee;
    1.13 +var gClient;
    1.14 +var gThreadClient;
    1.15 +
    1.16 +function run_test()
    1.17 +{
    1.18 +  initTestDebuggerServer();
    1.19 +  gDebuggee = addTestGlobal("test-stack");
    1.20 +  gClient = new DebuggerClient(DebuggerServer.connectPipe());
    1.21 +  gClient.connect(function() {
    1.22 +    attachTestTabAndResume(gClient, "test-stack", function(aResponse, aTabClient, aThreadClient) {
    1.23 +      gThreadClient = aThreadClient;
    1.24 +      test_pause_frame();
    1.25 +    });
    1.26 +  });
    1.27 +  do_test_pending();
    1.28 +}
    1.29 +
    1.30 +function test_pause_frame()
    1.31 +{
    1.32 +  gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    1.33 +    gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    1.34 +      do_check_eq(aPacket.why.type, "exception");
    1.35 +      do_check_eq(aPacket.why.exception, 42);
    1.36 +      gThreadClient.resume(function () {
    1.37 +        finishClient(gClient);
    1.38 +      });
    1.39 +    });
    1.40 +    gThreadClient.pauseOnExceptions(true);
    1.41 +    gThreadClient.resume();
    1.42 +  });
    1.43 +
    1.44 +  gDebuggee.eval("(" + function() {
    1.45 +    function stopMe() {
    1.46 +      debugger;
    1.47 +      throw 42;
    1.48 +    };
    1.49 +    try {
    1.50 +      stopMe();
    1.51 +    } catch (e) {}
    1.52 +  } + ")()");
    1.53 +}

mercurial