--- a/devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js
@@ -100,17 +100,14 @@ function test() {
});
});
function setBreakpoint(location) {
let item = gSources.getItemByValue(getSourceActor(gSources, location.url));
let source = gThreadClient.source(item.attachment.source);
let deferred = promise.defer();
- source.setBreakpoint(location, ({ error, message }, bpClient) => {
- if (error) {
- deferred.reject(error + ": " + message);
- }
+ source.setBreakpoint(location).then(([response, bpClient]) => {
deferred.resolve(bpClient);
});
return deferred.promise;
}
}
--- a/devtools/client/debugger/test/mochitest/browser_dbg_pretty-print-07.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_pretty-print-07.js
@@ -31,28 +31,28 @@ function findSource() {
sources = sources.filter(s => s.url.includes("code_ugly-2.js"));
is(sources.length, 1);
gSource = sources[0];
prettyPrintSource();
});
}
function prettyPrintSource() {
- gThreadClient.source(gSource).prettyPrint(4, testPrettyPrinted);
+ gThreadClient.source(gSource).prettyPrint(4).then(testPrettyPrinted);
}
function testPrettyPrinted({ error, source }) {
ok(!error, "Should not get an error while pretty-printing");
ok(source.includes("\n "),
"Source should be pretty-printed");
disablePrettyPrint();
}
function disablePrettyPrint() {
- gThreadClient.source(gSource).disablePrettyPrint(testUgly);
+ gThreadClient.source(gSource).disablePrettyPrint().then(testUgly);
}
function testUgly({ error, source }) {
ok(!error, "Should not get an error while disabling pretty-printing");
ok(!source.includes("\n "),
"Source should not be pretty after disabling pretty-printing");
closeDebuggerAndFinish(gPanel);
}
--- a/devtools/client/debugger/test/mochitest/browser_dbg_pretty-print-08.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_pretty-print-08.js
@@ -37,17 +37,17 @@ function findSource() {
[gSource] = sources;
BP_LOCATION.actor = gSource.actor;
prettyPrintSource(sources[0]);
});
}
function prettyPrintSource(source) {
- gThreadClient.source(gSource).prettyPrint(2, runCode);
+ gThreadClient.source(gSource).prettyPrint(2).then(runCode);
}
function runCode({ error }) {
ok(!error);
gClient.addOneTimeListener("paused", testDbgStatement);
callInTab(gTab, "main3");
}
@@ -57,23 +57,21 @@ function testDbgStatement(event, { why,
is(source.actor, BP_LOCATION.actor, "source.actor should be the right actor");
is(line, 3, "the line should be 3");
setBreakpoint();
}
function setBreakpoint() {
gThreadClient.source(gSource).setBreakpoint(
{ line: BP_LOCATION.line,
- column: BP_LOCATION.column },
- ({ error, actualLocation }) => {
- ok(!error, "error should not exist");
+ column: BP_LOCATION.column })
+ .then(([{ actualLocation }]) => {
ok(!actualLocation, "actualLocation should not exist");
testStepping();
- }
- );
+ });
}
function testStepping() {
gClient.addOneTimeListener("paused", (event, { why, frame }) => {
is(why.type, "resumeLimit");
const { source, line } = frame.where;
is(source.actor, BP_LOCATION.actor, "source.actor should be the right actor");
is(line, 4, "the line should be 4");
--- a/devtools/client/debugger/test/mochitest/browser_dbg_pretty-print-09.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_pretty-print-09.js
@@ -42,17 +42,17 @@ function findSource() {
sources = sources.filter(s => s.url === B_URL);
is(sources.length, 1);
gSource = sources[0];
prettyPrint();
});
}
function prettyPrint() {
- gThreadClient.source(gSource).prettyPrint(2, runCode);
+ gThreadClient.source(gSource).prettyPrint(2).then(runCode);
}
function runCode({ error }) {
ok(!error);
gClient.addOneTimeListener("paused", testDbgStatement);
callInTab(gTab, "a");
}
@@ -61,17 +61,17 @@ function testDbgStatement(event, { frame
const { source, line } = frame.where;
is(source.url, B_URL);
is(line, 2);
disablePrettyPrint();
}
function disablePrettyPrint() {
- gThreadClient.source(gSource).disablePrettyPrint(testUgly);
+ gThreadClient.source(gSource).disablePrettyPrint().then(testUgly);
}
function testUgly({ error, source }) {
ok(!error);
ok(!source.includes("\n "));
getFrame();
}
--- a/devtools/client/debugger/test/mochitest/browser_dbg_source-maps-01.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_source-maps-01.js
@@ -61,37 +61,33 @@ function checkInitialSource() {
}
function testSetBreakpoint() {
let deferred = promise.defer();
let sourceForm = getSourceForm(gSources, COFFEE_URL);
gDebugger.gThreadClient.interrupt(aResponse => {
let source = gDebugger.gThreadClient.source(sourceForm);
- source.setBreakpoint({ line: 5 }, aResponse => {
- ok(!aResponse.error,
- "Should be able to set a breakpoint in a coffee source file.");
+ source.setBreakpoint({ line: 5 }).then(([aResponse]) => {
ok(!aResponse.actualLocation,
"Should be able to set a breakpoint on line 5.");
deferred.resolve();
});
});
return deferred.promise;
}
function testSetBreakpointBlankLine() {
let deferred = promise.defer();
let sourceForm = getSourceForm(gSources, COFFEE_URL);
let source = gDebugger.gThreadClient.source(sourceForm);
- source.setBreakpoint({ line: 8 }, aResponse => {
- ok(!aResponse.error,
- "Should be able to set a breakpoint in a coffee source file on a blank line.");
+ source.setBreakpoint({ line: 8 }).then(([aResponse]) => {
ok(!aResponse.isPending,
"Should not be a pending breakpoint.");
ok(!aResponse.actualLocation,
"Should not be a moved breakpoint.");
deferred.resolve();
});
--- a/devtools/client/debugger/test/mochitest/browser_dbg_source-maps-02.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_source-maps-02.js
@@ -64,20 +64,17 @@ function testToggleGeneratedSource() {
return finished;
}
function testSetBreakpoint() {
let deferred = promise.defer();
let sourceForm = getSourceForm(gSources, JS_URL);
let source = gDebugger.gThreadClient.source(sourceForm);
- source.setBreakpoint({ line: 7 }, aResponse => {
- ok(!aResponse.error,
- "Should be able to set a breakpoint in a js file.");
-
+ source.setBreakpoint({ line: 7 }).then(([aResponse]) => {
gDebugger.gClient.addOneTimeListener("resumed", () => {
waitForCaretAndScopes(gPanel, 7).then(() => {
// Make sure that we have JavaScript stack frames.
is(gFrames.itemCount, 1,
"Should have only one frame.");
is(gFrames.getItemAtIndex(0).attachment.url.indexOf(".coffee"), -1,
"First frame should not be a coffee source frame.");
isnot(gFrames.getItemAtIndex(0).attachment.url.indexOf(".js"), -1,
--- a/devtools/client/debugger/test/mochitest/browser_dbg_source-maps-03.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_source-maps-03.js
@@ -45,19 +45,17 @@ function checkInitialSource() {
"not the whitespace stripped minified version.");
}
function testSetBreakpoint() {
let deferred = promise.defer();
let sourceForm = getSourceForm(gSources, JS_URL);
let source = gDebugger.gThreadClient.source(sourceForm);
- source.setBreakpoint({ line: 30 }, aResponse => {
- ok(!aResponse.error,
- "Should be able to set a breakpoint in a js file.");
+ source.setBreakpoint({ line: 30 }).then(([aResponse]) => {
ok(!aResponse.actualLocation,
"Should be able to set a breakpoint on line 30.");
gDebugger.gClient.addOneTimeListener("resumed", () => {
waitForCaretAndScopes(gPanel, 30).then(() => {
// Make sure that we have the right stack frames.
is(gFrames.itemCount, 9,
"Should have nine frames.");
--- a/devtools/client/debugger/test/mochitest/browser_dbg_source-maps-04.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_source-maps-04.js
@@ -88,19 +88,17 @@ function disableIgnoreCaughtExceptions()
return deferred.promise;
}
function testSetBreakpoint() {
let deferred = promise.defer();
let sourceForm = getSourceForm(gSources, JS_URL);
let source = gDebugger.gThreadClient.source(sourceForm);
- source.setBreakpoint({ line: 3, column: 18 }, aResponse => {
- ok(!aResponse.error,
- "Should be able to set a breakpoint in a js file.");
+ source.setBreakpoint({ line: 3, column: 18 }).then(([aResponse]) => {
ok(!aResponse.actualLocation,
"Should be able to set a breakpoint on line 3 and column 18.");
deferred.resolve();
});
return deferred.promise;
}
--- a/devtools/client/debugger/test/mochitest/browser_dbg_worker-source-map.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_worker-source-map.js
@@ -42,17 +42,17 @@ function test() {
is(editor.getText().indexOf("isnt"), 211,
"The debugger's editor should have the coffee source source displayed.");
is(editor.getText().indexOf("function"), -1,
"The debugger's editor should not have the JS source displayed.");
yield threadClient.interrupt();
let sourceForm = getSourceForm(Sources, COFFEE_URL);
let source = threadClient.source(sourceForm);
- let response = yield source.setBreakpoint({ line: 5 });
+ let [response] = yield source.setBreakpoint({ line: 5 });
ok(!response.error,
"Should be able to set a breakpoint in a coffee source file.");
ok(!response.actualLocation,
"Should be able to set a breakpoint on line 5.");
let promise = new Promise((resolve) => {
threadClient.addOneTimeListener("paused", (event, packet) => {
--- a/devtools/server/tests/unit/test_blackboxing-02.js
+++ b/devtools/server/tests/unit/test_blackboxing-02.js
@@ -40,18 +40,17 @@ function test_black_box() {
obj.getDefinitionSite(runWithSource);
});
});
function runWithSource(packet) {
const source = gThreadClient.source(packet.source);
source.setBreakpoint({
line: 2
- }, function(response) {
- Assert.ok(!response.error, "Should be able to set breakpoint.");
+ }).then(function() {
gThreadClient.resume(test_black_box_breakpoint);
});
}
});
/* eslint-disable no-multi-spaces, no-undef */
Cu.evalInSandbox(
"" + function doStuff(k) { // line 1
--- a/devtools/server/tests/unit/test_blackboxing-03.js
+++ b/devtools/server/tests/unit/test_blackboxing-03.js
@@ -30,19 +30,18 @@ function run_test() {
const BLACK_BOXED_URL = "http://example.com/blackboxme.js";
const SOURCE_URL = "http://example.com/source.js";
function test_black_box() {
gClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
source.setBreakpoint({
line: 4
- }, function({error}, bpClient) {
+ }).then(function([response, bpClient]) {
gBpClient = bpClient;
- Assert.ok(!error, "Should not get an error: " + error);
gThreadClient.resume(test_black_box_dbg_statement);
});
});
/* eslint-disable no-multi-spaces, no-undef */
Cu.evalInSandbox(
"" + function doStuff(k) { // line 1
debugger; // line 2 - Break here
--- a/devtools/server/tests/unit/test_blackboxing-04.js
+++ b/devtools/server/tests/unit/test_blackboxing-04.js
@@ -37,20 +37,17 @@ function test_black_box() {
obj.getDefinitionSite(runWithSource);
});
});
function runWithSource(packet) {
const source = gThreadClient.source(packet.source);
source.setBreakpoint({
line: 2
- }, function(response) {
- Assert.ok(!response.error, "Should be able to set breakpoint.");
- test_black_box_paused();
- });
+ }).then(test_black_box_paused);
}
});
/* eslint-disable no-multi-spaces, no-undef */
Cu.evalInSandbox(
"" + function doStuff(k) { // line 1
debugger; // line 2
k(100); // line 3
--- a/devtools/server/tests/unit/test_breakpoint-01.js
+++ b/devtools/server/tests/unit/test_breakpoint-01.js
@@ -35,17 +35,17 @@ function run_test_with_server(server, ca
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = {
line: gDebuggee.line0 + 3
};
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.type, "paused");
Assert.equal(packet.frame.where.source.actor, source.actor);
Assert.equal(packet.frame.where.line, location.line);
Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
--- a/devtools/server/tests/unit/test_breakpoint-02.js
+++ b/devtools/server/tests/unit/test_breakpoint-02.js
@@ -42,17 +42,21 @@ function test_breakpoint_running() {
// Setting the breakpoint later should interrupt the debuggee.
gThreadClient.addOneTimeListener("paused", function(event, packet) {
Assert.equal(packet.type, "paused");
Assert.equal(packet.why.type, "interrupted");
});
const source = gThreadClient.source(packet.frame.where.source);
- source.setBreakpoint(location, function(response) {
+ source.setBreakpoint(location).then(function() {
+ executeSoon(function() {
+ gClient.close().then(gCallback);
+ });
+ }, function(response) {
// Eval scripts don't stick around long enough for the breakpoint to be set,
// so just make sure we got the expected response from the actor.
Assert.notEqual(response.error, "noScript");
executeSoon(function() {
gClient.close().then(gCallback);
});
});
--- a/devtools/server/tests/unit/test_breakpoint-04.js
+++ b/devtools/server/tests/unit/test_breakpoint-04.js
@@ -34,17 +34,17 @@ function run_test_with_server(server, ca
});
}
function test_child_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = { line: gDebuggee.line0 + 3 };
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
// actualLocation is not returned when breakpoints don't skip forward.
Assert.equal(response.actualLocation, undefined);
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.type, "paused");
Assert.equal(packet.frame.where.source.actor, source.actor);
Assert.equal(packet.frame.where.line, location.line);
--- a/devtools/server/tests/unit/test_breakpoint-05.js
+++ b/devtools/server/tests/unit/test_breakpoint-05.js
@@ -35,17 +35,17 @@ function run_test_with_server(server, ca
});
}
function test_child_skip_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = { line: gDebuggee.line0 + 3 };
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
// Check that the breakpoint has properly skipped forward one line.
Assert.equal(response.actualLocation.source.actor, source.actor);
Assert.equal(response.actualLocation.line, location.line + 1);
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.type, "paused");
Assert.equal(packet.frame.where.source.actor, source.actor);
--- a/devtools/server/tests/unit/test_breakpoint-06.js
+++ b/devtools/server/tests/unit/test_breakpoint-06.js
@@ -35,17 +35,17 @@ function run_test_with_server(server, ca
});
}
function test_nested_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = { line: gDebuggee.line0 + 5 };
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
// Check that the breakpoint has properly skipped forward one line.
Assert.equal(response.actualLocation.source.actor, source.actor);
Assert.equal(response.actualLocation.line, location.line + 1);
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.type, "paused");
Assert.equal(packet.frame.where.source.actor, source.actor);
--- a/devtools/server/tests/unit/test_breakpoint-07.js
+++ b/devtools/server/tests/unit/test_breakpoint-07.js
@@ -35,17 +35,17 @@ function run_test_with_server(server, ca
});
}
function test_second_child_skip_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = { line: gDebuggee.line0 + 6 };
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
// Check that the breakpoint has properly skipped forward one line.
Assert.equal(response.actualLocation.source.actor, source.actor);
Assert.equal(response.actualLocation.line, location.line + 1);
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.type, "paused");
Assert.equal(packet.frame.where.source.actor, source.actor);
--- a/devtools/server/tests/unit/test_breakpoint-08.js
+++ b/devtools/server/tests/unit/test_breakpoint-08.js
@@ -43,17 +43,17 @@ function test_child_skip_breakpoint() {
obj.getDefinitionSite(runWithBreakpoint);
});
});
function runWithBreakpoint(packet) {
const source = gThreadClient.source(packet.source);
const location = { line: gDebuggee.line0 + 3 };
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
// Check that the breakpoint has properly skipped forward one line.
Assert.equal(response.actualLocation.source.actor, source.actor);
Assert.equal(response.actualLocation.line, location.line + 1);
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.type, "paused");
Assert.equal(packet.frame.where.source.actor, source.actor);
--- a/devtools/server/tests/unit/test_breakpoint-09.js
+++ b/devtools/server/tests/unit/test_breakpoint-09.js
@@ -35,17 +35,17 @@ function run_test_with_server(server, ca
}
function test_remove_breakpoint() {
let done = false;
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = { line: gDebuggee.line0 + 2 };
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.type, "paused");
Assert.equal(packet.frame.where.source.actor, source.actor);
Assert.equal(packet.frame.where.line, location.line);
Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
--- a/devtools/server/tests/unit/test_breakpoint-10.js
+++ b/devtools/server/tests/unit/test_breakpoint-10.js
@@ -35,17 +35,17 @@ function run_test_with_server(server, ca
});
}
function test_child_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = { line: gDebuggee.line0 + 3 };
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
// actualLocation is not returned when breakpoints don't skip forward.
Assert.equal(response.actualLocation, undefined);
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.type, "paused");
Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor);
--- a/devtools/server/tests/unit/test_breakpoint-11.js
+++ b/devtools/server/tests/unit/test_breakpoint-11.js
@@ -35,17 +35,17 @@ function run_test_with_server(server, ca
});
}
function test_child_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = { line: gDebuggee.line0 + 2 };
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
// actualLocation is not returned when breakpoints don't skip forward.
Assert.equal(response.actualLocation, undefined);
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.type, "paused");
Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor);
--- a/devtools/server/tests/unit/test_breakpoint-12.js
+++ b/devtools/server/tests/unit/test_breakpoint-12.js
@@ -39,17 +39,17 @@ function run_test_with_server(server, ca
});
}
function test_child_skip_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = { line: gDebuggee.line0 + 3};
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
// Check that the breakpoint has properly skipped forward one line.
Assert.equal(response.actualLocation.source.actor, source.actor);
Assert.equal(response.actualLocation.line, location.line + 1);
gBpActor = response.actor;
// Set more breakpoints at the same location.
set_breakpoints(source, location);
});
@@ -66,17 +66,17 @@ function test_child_skip_breakpoint() {
"foo();\n", // line0 + 7
gDebuggee);
/* eslint-enable no-multi-spaces */
}
// Set many breakpoints at the same location.
function set_breakpoints(source, location) {
Assert.notEqual(gCount, NUM_BREAKPOINTS);
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
// Check that the breakpoint has properly skipped forward one line.
Assert.equal(response.actualLocation.source.actor, source.actor);
Assert.equal(response.actualLocation.line, location.line + 1);
// Check that the same breakpoint actor was returned.
Assert.equal(response.actor, gBpActor);
if (++gCount < NUM_BREAKPOINTS) {
set_breakpoints(source, location);
--- a/devtools/server/tests/unit/test_breakpoint-13.js
+++ b/devtools/server/tests/unit/test_breakpoint-13.js
@@ -35,17 +35,17 @@ function run_test_with_server(server, ca
});
}
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = { line: gDebuggee.line0 + 2 };
- source.setBreakpoint(location, async function(response, bpClient) {
+ source.setBreakpoint(location).then(async function([response, bpClient]) {
const testCallbacks = [
function(packet) {
// Check that the stepping worked.
Assert.equal(packet.frame.where.line, gDebuggee.line0 + 5);
Assert.equal(packet.why.type, "resumeLimit");
},
function(packet) {
// Entered the foo function call frame.
--- a/devtools/server/tests/unit/test_breakpoint-14.js
+++ b/devtools/server/tests/unit/test_breakpoint-14.js
@@ -35,17 +35,17 @@ function run_test_with_server(server, ca
});
}
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = { line: gDebuggee.line0 + 2 };
- source.setBreakpoint(location, async function(response, bpClient) {
+ source.setBreakpoint(location).then(async function([response, bpClient]) {
const testCallbacks = [
function(packet) {
// Check that the stepping worked.
Assert.equal(packet.frame.where.line, gDebuggee.line0 + 5);
Assert.equal(packet.why.type, "resumeLimit");
},
function(packet) {
// Reached the breakpoint.
--- a/devtools/server/tests/unit/test_breakpoint-16.js
+++ b/devtools/server/tests/unit/test_breakpoint-16.js
@@ -40,17 +40,17 @@ function test_column_breakpoint() {
gClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
const location = {
line: gDebuggee.line0 + 1,
column: 55
};
let timesBreakpointHit = 0;
- source.setBreakpoint(location, function(response, bpClient) {
+ source.setBreakpoint(location).then(function([response, bpClient]) {
gThreadClient.addListener("paused", function onPaused(event, packet) {
Assert.equal(packet.type, "paused");
Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.why.actors[0], bpClient.actor);
Assert.equal(packet.frame.where.source.actor, source.actor);
Assert.equal(packet.frame.where.line, location.line);
Assert.equal(packet.frame.where.column, location.column);
--- a/devtools/server/tests/unit/test_breakpoint-17.js
+++ b/devtools/server/tests/unit/test_breakpoint-17.js
@@ -57,25 +57,23 @@ function test_breakpoints_columns() {
Cu.evalInSandbox(code, gDebuggee, "1.8", "http://example.com/", 1);
}
function set_breakpoints(event, packet) {
let first, second;
const source = gThreadClient.source(packet.frame.where.source);
- source.setBreakpoint(firstLocation, function({ error, actualLocation },
- breakpointClient) {
- Assert.ok(!error, "Should not get an error setting the breakpoint");
+ source.setBreakpoint(firstLocation).then(function([{ actualLocation },
+ breakpointClient]) {
Assert.ok(!actualLocation, "Should not get an actualLocation");
first = breakpointClient;
- source.setBreakpoint(secondLocation, function({ error, actualLocation },
- breakpointClient) {
- Assert.ok(!error, "Should not get an error setting the breakpoint");
+ source.setBreakpoint(secondLocation).then(function([{ actualLocation },
+ breakpointClient]) {
Assert.ok(!actualLocation, "Should not get an actualLocation");
second = breakpointClient;
test_different_actors(first, second);
});
});
}
--- a/devtools/server/tests/unit/test_breakpoint-18.js
+++ b/devtools/server/tests/unit/test_breakpoint-18.js
@@ -50,18 +50,17 @@ function setUpCode() {
1
);
}
function setBreakpoint(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
gClient.addOneTimeListener("resumed", runCode);
- source.setBreakpoint({ line: 2 }, ({ error }) => {
- Assert.ok(!error);
+ source.setBreakpoint({ line: 2 }).then(() => {
gThreadClient.resume();
});
}
function runCode() {
gClient.addOneTimeListener("paused", testBPHit);
gDebuggee.test();
}
--- a/devtools/server/tests/unit/test_breakpoint-22.js
+++ b/devtools/server/tests/unit/test_breakpoint-22.js
@@ -46,17 +46,17 @@ const test = async function() {
const [res, ] = await setBreakpoint(source, location);
ok(!res.error);
const location2 = {
line: gDebuggee.line0 + 7
};
- await source.setBreakpoint(location2).then(_ => {
+ await source.setBreakpoint(location2).then(() => {
do_throw("no code shall not be found the specified line or below it");
}, reason => {
Assert.equal(reason.error, "noCodeAtLineColumn");
ok(reason.message);
});
await resume(gThreadClient);
finishClient(gClient);
--- a/devtools/server/tests/unit/test_conditional_breakpoint-01.js
+++ b/devtools/server/tests/unit/test_conditional_breakpoint-01.js
@@ -27,17 +27,17 @@ function run_test() {
}
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
source.setBreakpoint({
line: 3,
condition: "a === 1"
- }, function(response, bpClient) {
+ }).then(function([response, bpClient]) {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.why.type, "breakpoint");
Assert.equal(packet.frame.where.line, 3);
// Remove the breakpoint.
bpClient.remove(function(response) {
gThreadClient.resume(function() {
--- a/devtools/server/tests/unit/test_conditional_breakpoint-02.js
+++ b/devtools/server/tests/unit/test_conditional_breakpoint-02.js
@@ -27,17 +27,17 @@ function run_test() {
}
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
source.setBreakpoint({
line: 3,
condition: "a === 2"
- }, function(response, bpClient) {
+ }).then(function([response, bpClient]) {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.why.type, "debuggerStatement");
Assert.equal(packet.frame.where.line, 4);
// Remove the breakpoint.
bpClient.remove(function(response) {
gThreadClient.resume(function() {
--- a/devtools/server/tests/unit/test_conditional_breakpoint-03.js
+++ b/devtools/server/tests/unit/test_conditional_breakpoint-03.js
@@ -27,17 +27,17 @@ function run_test() {
}
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
const source = gThreadClient.source(packet.frame.where.source);
source.setBreakpoint({
line: 3,
condition: "throw new Error()"
- }, function(response, bpClient) {
+ }).then(function([response, bpClient]) {
gThreadClient.addOneTimeListener("paused", function(event, packet) {
// Check the return value.
Assert.equal(packet.why.type, "breakpointConditionThrown");
Assert.equal(packet.frame.where.line, 3);
// Remove the breakpoint.
bpClient.remove(function(response) {
gThreadClient.resume(function() {
--- a/devtools/server/tests/unit/test_source-01.js
+++ b/devtools/server/tests/unit/test_source-01.js
@@ -49,19 +49,18 @@ function test_source() {
const source = response.sources.filter(function(s) {
return s.url === SOURCE_URL;
})[0];
Assert.ok(!!source);
const sourceClient = gThreadClient.source(source);
- sourceClient.source(function(response) {
+ sourceClient.source().then(function(response) {
Assert.ok(!!response);
- Assert.ok(!response.error);
Assert.ok(!!response.contentType);
Assert.ok(response.contentType.includes("javascript"));
Assert.ok(!!response.source);
Assert.equal(SOURCE_CONTENT,
response.source);
gThreadClient.resume(function() {
--- a/devtools/server/tests/unit/test_sourcemaps-06.js
+++ b/devtools/server/tests/unit/test_sourcemaps-06.js
@@ -72,20 +72,17 @@ function testContents(sources, timesCall
callback(timesCalled);
return;
}
const source = sources[0];
const sourceClient = gThreadClient.source(sources[0]);
if (sourceClient.url) {
- sourceClient.source((response) => {
- Assert.ok(!response.error,
- "Should not get an error loading the source from sourcesContent");
-
+ sourceClient.source().then(response => {
const expectedContent = "content for " + source.url.replace(/^.*\//, "");
Assert.equal(response.source, expectedContent,
"Should have the expected source content");
testContents(sources.slice(1), timesCalled + 1, callback);
});
} else {
testContents(sources.slice(1), timesCalled, callback);
--- a/devtools/server/tests/unit/test_sourcemaps-07.js
+++ b/devtools/server/tests/unit/test_sourcemaps-07.js
@@ -42,27 +42,23 @@ function test_cached_original_sources()
code += "//# sourceMappingURL=data:text/json;base64," + btoa(map.toString());
Cu.evalInSandbox(code, gDebuggee, "1.8",
"http://example.com/www/js/abc.js", 1);
}
function onNewSource(event, packet) {
const sourceClient = gThreadClient.source(packet.source);
- sourceClient.source(function(response) {
- Assert.ok(!response.error,
- "Should not be an error grabbing the source");
+ sourceClient.source().then(function(response) {
Assert.equal(response.source, "initial content",
"The correct source content should be sent");
writeFile("temp.js", "new content");
- sourceClient.source(function(response) {
- Assert.ok(!response.error,
- "Should not be an error grabbing the source");
+ sourceClient.source().then(function(response) {
Assert.equal(response.source, "new content",
"The correct source content should not be cached, " +
"so we should get the new content");
do_get_file("temp.js").remove(false);
finishClient(gClient);
});
});
--- a/devtools/server/tests/unit/test_sourcemaps-08.js
+++ b/devtools/server/tests/unit/test_sourcemaps-08.js
@@ -24,18 +24,17 @@ function run_test() {
});
});
do_test_pending();
}
function test_source_maps() {
gThreadClient.addOneTimeListener("newSource", function(event, packet) {
const sourceClient = gThreadClient.source(packet.source);
- sourceClient.source(function({error, source}) {
- Assert.ok(!error, "should be able to grab the source");
+ sourceClient.source().then(function({source}) {
Assert.equal(source, "foo",
"Should load the source from the sourcesContent field");
finishClient(gClient);
});
});
let code = "'nothing here';\n";
code += "//# sourceMappingURL=data:text/json," + JSON.stringify({
--- a/devtools/server/tests/unit/test_sourcemaps-09.js
+++ b/devtools/server/tests/unit/test_sourcemaps-09.js
@@ -41,20 +41,17 @@ function test_minified() {
Assert.equal(event, "paused");
Assert.equal(packet.why.type, "debuggerStatement");
const location = {
line: 5
};
getSource(gThreadClient, "http://example.com/foo.js").then(source => {
- source.setBreakpoint(location, function(response, bpClient) {
- Assert.ok(!response.error);
- testHitBreakpoint();
- });
+ source.setBreakpoint(location).then(() => testHitBreakpoint());
});
});
// This is the original foo.js, which was then minified with uglifyjs version
// 2.2.5 and the "--mangle" option.
//
// (function () {
// debugger;
--- a/devtools/server/tests/unit/test_wasm_source-01.js
+++ b/devtools/server/tests/unit/test_wasm_source-01.js
@@ -55,19 +55,18 @@ function test_source() {
const source = response.sources.filter(function(s) {
return s.introductionType === "wasm";
})[0];
Assert.ok(!!source);
const sourceClient = gThreadClient.source(source);
- sourceClient.source(function(response) {
+ sourceClient.source().then(function(response) {
Assert.ok(!!response);
- Assert.ok(!response.error);
Assert.ok(!!response.contentType);
Assert.ok(response.contentType.includes("wasm"));
const sourceContent = response.source;
Assert.ok(!!sourceContent);
Assert.equal(typeof sourceContent, "object");
Assert.ok("binary" in sourceContent);
Assert.equal(EXPECTED_CONTENT, sourceContent.binary);
--- a/devtools/shared/client/breakpoint-client.js
+++ b/devtools/shared/client/breakpoint-client.js
@@ -101,23 +101,19 @@ BreakpointClient.prototype = {
// Remove the current breakpoint and add a new one with the
// condition.
this.remove(response => {
if (response && response.error) {
deferred.reject(response);
return;
}
- this.source.setBreakpoint(info, (resp, newBreakpoint) => {
- if (resp && resp.error) {
- deferred.reject(resp);
- } else {
- deferred.resolve(newBreakpoint);
- }
- });
+ deferred.resolve(this.source.setBreakpoint(info).then(([, newBreakpoint]) => {
+ return newBreakpoint;
+ }));
});
} else {
// The property shouldn't even exist if the condition is blank
if (condition === "") {
delete this.conditionalExpression;
} else {
this.conditionalExpression = condition;
}
--- a/devtools/shared/client/source-client.js
+++ b/devtools/shared/client/source-client.js
@@ -42,19 +42,16 @@ SourceClient.prototype = {
return this._client.request;
},
get url() {
return this._form.url;
},
/**
* Black box this SourceClient's source.
- *
- * @param callback Function
- * The callback function called when we receive the response from the server.
*/
blackBox: DebuggerClient.requester({
type: "blackbox"
}, {
after: function(response) {
if (!response.error) {
this._isBlackBoxed = true;
if (this._activeThread) {
@@ -62,19 +59,16 @@ SourceClient.prototype = {
}
}
return response;
}
}),
/**
* Un-black box this SourceClient's source.
- *
- * @param callback Function
- * The callback function called when we receive the response from the server.
*/
unblackBox: DebuggerClient.requester({
type: "unblackbox"
}, {
after: function(response) {
if (!response.error) {
this._isBlackBoxed = false;
if (this._activeThread) {
@@ -82,142 +76,123 @@ SourceClient.prototype = {
}
}
return response;
}
}),
/**
* Get Executable Lines from a source
- *
- * @param callback Function
- * The callback function called when we receive the response from the server.
*/
getExecutableLines: function(cb = noop) {
const packet = {
to: this._form.actor,
type: "getExecutableLines"
};
return this._client.request(packet).then(res => {
cb(res.lines);
return res.lines;
});
},
/**
* Get a long string grip for this SourceClient's source.
*/
- source: function(callback = noop) {
+ source: function() {
const packet = {
to: this._form.actor,
type: "source"
};
return this._client.request(packet).then(response => {
- return this._onSourceResponse(response, callback);
+ return this._onSourceResponse(response);
});
},
/**
* Pretty print this source's text.
*/
- prettyPrint: function(indent, callback = noop) {
+ prettyPrint: function(indent) {
const packet = {
to: this._form.actor,
type: "prettyPrint",
indent
};
return this._client.request(packet).then(response => {
- if (!response.error) {
- this._isPrettyPrinted = true;
- this._activeThread._clearFrames();
- this._activeThread.emit("prettyprintchange", this);
- }
- return this._onSourceResponse(response, callback);
+ this._isPrettyPrinted = true;
+ this._activeThread._clearFrames();
+ this._activeThread.emit("prettyprintchange", this);
+ return this._onSourceResponse(response);
});
},
/**
* Stop pretty printing this source's text.
*/
- disablePrettyPrint: function(callback = noop) {
+ disablePrettyPrint: function() {
const packet = {
to: this._form.actor,
type: "disablePrettyPrint"
};
return this._client.request(packet).then(response => {
- if (!response.error) {
- this._isPrettyPrinted = false;
- this._activeThread._clearFrames();
- this._activeThread.emit("prettyprintchange", this);
- }
- return this._onSourceResponse(response, callback);
+ this._isPrettyPrinted = false;
+ this._activeThread._clearFrames();
+ this._activeThread.emit("prettyprintchange", this);
+ return this._onSourceResponse(response);
});
},
- _onSourceResponse: function(response, callback) {
- if (response.error) {
- callback(response);
- return response;
- }
-
+ _onSourceResponse: function(response) {
if (typeof response.source === "string") {
- callback(response);
return response;
}
const { contentType, source } = response;
if (source.type === "arrayBuffer") {
const arrayBuffer = this._activeThread.threadArrayBuffer(source);
return arrayBuffer.slice(0, arrayBuffer.length).then(function(resp) {
if (resp.error) {
- callback(resp);
return resp;
}
// Keeping str as a string, ArrayBuffer/Uint8Array will not survive
// setIn/mergeIn operations.
const str = atob(resp.encoded);
const newResponse = {
source: {
binary: str,
toString: () => "[wasm]",
},
contentType,
};
- callback(newResponse);
return newResponse;
});
}
const longString = this._activeThread.threadLongString(source);
return longString.substring(0, longString.length).then(function(resp) {
if (resp.error) {
- callback(resp);
return resp;
}
const newResponse = {
source: resp.substring,
contentType: contentType
};
- callback(newResponse);
return newResponse;
});
},
/**
* Request to set a breakpoint in the specified location.
*
* @param object location
* The location and condition of the breakpoint in
* the form of { line[, column, condition] }.
- * @param function onResponse
- * Called with the thread's response.
*/
- setBreakpoint: function({ line, column, condition, noSliding }, onResponse = noop) {
+ setBreakpoint: function({ line, column, condition, noSliding }) {
// A helper function that sets the breakpoint.
const doSetBreakpoint = callback => {
const root = this._client.mainRoot;
const location = {
line,
column,
};
@@ -244,33 +219,31 @@ SourceClient.prototype = {
bpClient = new BreakpointClient(
this._client,
this,
response.actor,
location,
root.traits.conditionalBreakpoints ? condition : undefined
);
}
- onResponse(response, bpClient);
if (callback) {
callback();
}
return [response, bpClient];
});
};
// If the debuggee is paused, just set the breakpoint.
if (this._activeThread.paused) {
return doSetBreakpoint();
}
// Otherwise, force a pause in order to set the breakpoint.
return this._activeThread.interrupt().then(response => {
if (response.error) {
// Can't set the breakpoint if pausing failed.
- onResponse(response);
return response;
}
const { type, why } = response;
const cleanUp = type == "paused" && why.type == "interrupted"
? () => this._activeThread.resume()
: noop;