summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/server/tests/unit/test_dbgclient_debuggerstatement.js')
-rw-r--r--devtools/server/tests/unit/test_dbgclient_debuggerstatement.js73
1 files changed, 73 insertions, 0 deletions
diff --git a/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js b/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
new file mode 100644
index 000000000..40468cb1d
--- /dev/null
+++ b/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
@@ -0,0 +1,73 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+var gClient;
+var gTabClient;
+var gDebuggee;
+
+function run_test()
+{
+ initTestDebuggerServer();
+ gDebuggee = testGlobal("test-1");
+ DebuggerServer.addTestGlobal(gDebuggee);
+
+ let transport = DebuggerServer.connectPipe();
+ gClient = new DebuggerClient(transport);
+ gClient.connect().then(function ([aType, aTraits]) {
+ attachTestTab(gClient, "test-1", function (aReply, aTabClient) {
+ gTabClient = aTabClient;
+ test_threadAttach(aReply.threadActor);
+ });
+ });
+ do_test_pending();
+}
+
+function test_threadAttach(aThreadActorID)
+{
+ do_print("Trying to attach to thread " + aThreadActorID);
+ gTabClient.attachThread({}, function (aResponse, aThreadClient) {
+ do_check_eq(aThreadClient.state, "paused");
+ do_check_eq(aThreadClient.actor, aThreadActorID);
+ aThreadClient.resume(function () {
+ do_check_eq(aThreadClient.state, "attached");
+ test_debugger_statement(aThreadClient);
+ });
+ });
+}
+
+function test_debugger_statement(aThreadClient)
+{
+ aThreadClient.addListener("paused", function (aEvent, aPacket) {
+ do_check_eq(aThreadClient.state, "paused");
+ // Reach around the protocol to check that the debuggee is in the state
+ // we expect.
+ do_check_true(gDebuggee.a);
+ do_check_false(gDebuggee.b);
+
+ let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
+ do_check_eq(xpcInspector.eventLoopNestLevel, 1);
+
+ aThreadClient.resume(cleanup);
+ });
+
+ Cu.evalInSandbox("var a = true; var b = false; debugger; var b = true;", gDebuggee);
+
+ // Now make sure that we've run the code after the debugger statement...
+ do_check_true(gDebuggee.b);
+}
+
+function cleanup()
+{
+ gClient.addListener("closed", function (aEvent) {
+ do_test_finished();
+ });
+
+ try {
+ let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
+ do_check_eq(xpcInspector.eventLoopNestLevel, 0);
+ } catch (e) {
+ dump(e);
+ }
+
+ gClient.close();
+}