browser/devtools/debugger/test/browser_dbg_cmd-dbg.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 * Tests that the debugger commands work as they should.
michael@0 6 */
michael@0 7
michael@0 8 const TEST_URI = EXAMPLE_URL + "doc_cmd-dbg.html";
michael@0 9
michael@0 10 function test() {
michael@0 11 return Task.spawn(function() {
michael@0 12 let options = yield helpers.openTab(TEST_URI);
michael@0 13 yield helpers.openToolbar(options);
michael@0 14
michael@0 15 yield helpers.audit(options, [{
michael@0 16 setup: "dbg open",
michael@0 17 exec: { output: "" }
michael@0 18 }]);
michael@0 19
michael@0 20 let [gTab, gDebuggee, gPanel] = yield initDebugger(gBrowser.selectedTab);
michael@0 21 let gDebugger = gPanel.panelWin;
michael@0 22 let gThreadClient = gDebugger.gThreadClient;
michael@0 23
michael@0 24 yield helpers.audit(options, [{
michael@0 25 setup: "dbg list",
michael@0 26 exec: { output: /doc_cmd-dbg.html/ }
michael@0 27 }]);
michael@0 28
michael@0 29 let button = gDebuggee.document.querySelector("input[type=button]");
michael@0 30 let output = gDebuggee.document.querySelector("input[type=text]");
michael@0 31
michael@0 32 let cmd = function(aTyped, aState) {
michael@0 33 return promise.all([
michael@0 34 waitForThreadEvents(gPanel, aState),
michael@0 35 helpers.audit(options, [{ setup: aTyped, exec: { output: "" } }])
michael@0 36 ]);
michael@0 37 };
michael@0 38
michael@0 39 let click = function(aElement, aState) {
michael@0 40 return promise.all([
michael@0 41 waitForThreadEvents(gPanel, aState),
michael@0 42 executeSoon(() => EventUtils.sendMouseEvent({ type: "click" }, aElement, gDebuggee))
michael@0 43 ]);
michael@0 44 }
michael@0 45
michael@0 46 yield cmd("dbg interrupt", "paused");
michael@0 47 is(gThreadClient.state, "paused", "Debugger is paused.");
michael@0 48
michael@0 49 yield cmd("dbg continue", "resumed");
michael@0 50 isnot(gThreadClient.state, "paused", "Debugger has continued.");
michael@0 51
michael@0 52 yield click(button, "paused");
michael@0 53 is(gThreadClient.state, "paused", "Debugger is paused again.");
michael@0 54
michael@0 55 yield cmd("dbg step in", "paused");
michael@0 56 yield cmd("dbg step in", "paused");
michael@0 57 yield cmd("dbg step in", "paused");
michael@0 58 is(output.value, "step in", "Debugger stepped in.");
michael@0 59
michael@0 60 yield cmd("dbg step over", "paused");
michael@0 61 is(output.value, "step over", "Debugger stepped over.");
michael@0 62
michael@0 63 yield cmd("dbg step out", "paused");
michael@0 64 is(output.value, "step out", "Debugger stepped out.");
michael@0 65
michael@0 66 yield cmd("dbg continue", "paused");
michael@0 67 is(output.value, "dbg continue", "Debugger continued.");
michael@0 68
michael@0 69 let closeDebugger = function() {
michael@0 70 let deferred = promise.defer();
michael@0 71
michael@0 72 helpers.audit(options, [{
michael@0 73 setup: "dbg close",
michael@0 74 exec: { output: "" }
michael@0 75 }])
michael@0 76 .then(() => {
michael@0 77 let toolbox = gDevTools.getToolbox(options.target);
michael@0 78 if (!toolbox) {
michael@0 79 ok(true, "Debugger is closed.");
michael@0 80 deferred.resolve();
michael@0 81 } else {
michael@0 82 toolbox.on("destroyed", () => {
michael@0 83 ok(true, "Debugger just closed.");
michael@0 84 deferred.resolve();
michael@0 85 });
michael@0 86 }
michael@0 87 });
michael@0 88
michael@0 89 return deferred.promise;
michael@0 90 };
michael@0 91
michael@0 92 // We close the debugger twice to ensure 'dbg close' doesn't error when
michael@0 93 // toolbox is already closed. See bug 884638 for more info.
michael@0 94 yield closeDebugger();
michael@0 95 yield closeDebugger();
michael@0 96 yield helpers.closeToolbar(options);
michael@0 97 yield helpers.closeTab(options);
michael@0 98
michael@0 99 }).then(finish, helpers.handleError);
michael@0 100 }

mercurial