toolkit/devtools/server/tests/unit/test_stepping-06.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Check that stepping out of a function returns the right return value.
michael@0 6 */
michael@0 7
michael@0 8 var gDebuggee;
michael@0 9 var gClient;
michael@0 10 var gThreadClient;
michael@0 11
michael@0 12 function run_test()
michael@0 13 {
michael@0 14 initTestDebuggerServer();
michael@0 15 gDebuggee = addTestGlobal("test-stack");
michael@0 16 gClient = new DebuggerClient(DebuggerServer.connectPipe());
michael@0 17 gClient.connect(function () {
michael@0 18 attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
michael@0 19 gThreadClient = aThreadClient;
michael@0 20 // XXX: We have to do an executeSoon so that the error isn't caught and
michael@0 21 // reported by DebuggerClient.requester (because we are using the local
michael@0 22 // transport and share a stack) which causes the test to fail.
michael@0 23 Services.tm.mainThread.dispatch({
michael@0 24 run: test_simple_stepping
michael@0 25 }, Ci.nsIThread.DISPATCH_NORMAL);
michael@0 26 });
michael@0 27 });
michael@0 28 do_test_pending();
michael@0 29 }
michael@0 30
michael@0 31 function test_simple_stepping()
michael@0 32 {
michael@0 33 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
michael@0 34 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
michael@0 35 // Check that the return value is 10.
michael@0 36 do_check_eq(aPacket.type, "paused");
michael@0 37 do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 4);
michael@0 38 do_check_eq(aPacket.why.type, "resumeLimit");
michael@0 39 do_check_eq(aPacket.why.frameFinished.return, 10);
michael@0 40
michael@0 41 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
michael@0 42 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
michael@0 43 // Check that the return value is undefined.
michael@0 44 do_check_eq(aPacket.type, "paused");
michael@0 45 do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 7);
michael@0 46 do_check_eq(aPacket.why.type, "resumeLimit");
michael@0 47 do_check_eq(aPacket.why.frameFinished.return.type, "undefined");
michael@0 48
michael@0 49 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
michael@0 50 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
michael@0 51 // Check that the exception was thrown.
michael@0 52 do_check_eq(aPacket.type, "paused");
michael@0 53 do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 12);
michael@0 54 do_check_eq(aPacket.why.type, "resumeLimit");
michael@0 55 do_check_eq(aPacket.why.frameFinished.throw, "ah");
michael@0 56
michael@0 57 gThreadClient.resume(function () {
michael@0 58 finishClient(gClient);
michael@0 59 });
michael@0 60 });
michael@0 61 gThreadClient.stepOut();
michael@0 62 });
michael@0 63 gThreadClient.resume();
michael@0 64 });
michael@0 65 gThreadClient.stepOut();
michael@0 66 });
michael@0 67 gThreadClient.resume();
michael@0 68 });
michael@0 69 gThreadClient.stepOut();
michael@0 70
michael@0 71 });
michael@0 72
michael@0 73 gDebuggee.eval("var line0 = Error().lineNumber;\n" +
michael@0 74 "function f() {\n" + // line0 + 1
michael@0 75 " debugger;\n" + // line0 + 2
michael@0 76 " var a = 10;\n" + // line0 + 3
michael@0 77 " return a;\n" + // line0 + 4
michael@0 78 "}\n" + // line0 + 5
michael@0 79 "function g() {\n" + // line0 + 6
michael@0 80 " debugger;\n" + // line0 + 7
michael@0 81 "}\n" + // line0 + 8
michael@0 82 "function h() {\n" + // line0 + 9
michael@0 83 " debugger;\n" + // line0 + 10
michael@0 84 " throw 'ah';\n" + // line0 + 11
michael@0 85 " return 2;\n" + // line0 + 12
michael@0 86 "}\n" + // line0 + 13
michael@0 87 "f();\n" + // line0 + 14
michael@0 88 "g();\n" + // line0 + 15
michael@0 89 "try { h() } catch (ex) { };\n"); // line0 + 16
michael@0 90 }

mercurial