Bug 1325989 - Resolve ESLint issues in devtools/server/tests/unit. r=jryans

--HG--
extra : rebase_source : 855f1da9fc88af46e8be78c94762a90df29cb75f
This commit is contained in:
Michael Brennan 2017-03-18 12:26:05 +01:00
Родитель 14a267bf2b
Коммит 8229796378
186 изменённых файлов: 3475 добавлений и 3150 удалений

Просмотреть файл

@ -135,7 +135,7 @@ devtools/server/actors/stylesheets.js
devtools/server/tests/browser/storage-*.html
!devtools/server/tests/browser/storage-unsecured-iframe.html
devtools/server/tests/browser/stylesheets-nested-iframes.html
devtools/server/tests/unit/**
devtools/server/tests/unit/xpcshell_debugging_script.js
devtools/shared/platform/content/test/test_clipboard.html
devtools/shared/qrcode/tests/mochitest/test_decode.html
devtools/shared/tests/mochitest/*.html
@ -178,6 +178,7 @@ devtools/client/debugger/test/mochitest/code_worker-source-map.js
devtools/client/framework/test/code_ugly*
devtools/server/tests/unit/babel_and_browserify_script_with_source_map.js
devtools/server/tests/unit/setBreakpoint*
devtools/server/tests/unit/sourcemapped.js
# dom/ exclusions
dom/animation/**

Просмотреть файл

@ -2,5 +2,8 @@
module.exports = {
// Extend from the common devtools xpcshell eslintrc config.
"extends": "../../../.eslintrc.xpcshell.js"
"extends": "../../../.eslintrc.xpcshell.js",
"rules": {
"no-debugger": 0,
}
};

Просмотреть файл

@ -1,5 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint no-unused-vars: ["error", {"vars": "local"}] */
/* eslint-disable no-shadow */
"use strict";
var Cc = Components.classes;
@ -42,11 +44,11 @@ const { MemoryFront } = require("devtools/shared/fronts/memory");
const { addDebuggerToGlobal } = Cu.import("resource://gre/modules/jsdebugger.jsm", {});
const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal);
const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"]
.createInstance(Ci.nsIPrincipal);
var loadSubScript = Cc[
"@mozilla.org/moz/jssubscript-loader;1"
].getService(Ci.mozIJSSubScriptLoader).loadSubScript;
var { loadSubScript } = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader);
/**
* Initializes any test that needs to work with add-ons.
@ -150,9 +152,8 @@ function makeFullRuntimeMemoryActorTest(testGeneratorFunction) {
}
function createTestGlobal(name) {
let sandbox = Cu.Sandbox(
Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal)
);
let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"]
.createInstance(Ci.nsIPrincipal));
sandbox.__name = name;
return sandbox;
}
@ -236,24 +237,27 @@ function dumpn(msg) {
function testExceptionHook(ex) {
try {
do_report_unexpected_exception(ex);
} catch (ex) {
return {throw: ex};
} catch (e) {
return {throw: e};
}
return undefined;
}
// Convert an nsIScriptError 'aFlags' value into an appropriate string.
function scriptErrorFlagsToKind(aFlags) {
var kind;
if (aFlags & Ci.nsIScriptError.warningFlag)
// Convert an nsIScriptError 'flags' value into an appropriate string.
function scriptErrorFlagsToKind(flags) {
let kind;
if (flags & Ci.nsIScriptError.warningFlag) {
kind = "warning";
if (aFlags & Ci.nsIScriptError.exceptionFlag)
}
if (flags & Ci.nsIScriptError.exceptionFlag) {
kind = "exception";
else
} else {
kind = "error";
}
if (aFlags & Ci.nsIScriptError.strictFlag)
if (flags & Ci.nsIScriptError.strictFlag) {
kind = "strict " + kind;
}
return kind;
}
@ -262,24 +266,25 @@ function scriptErrorFlagsToKind(aFlags) {
// into the ether.
var errorCount = 0;
var listener = {
observe: function (aMessage) {
observe: function (message) {
try {
let string;
errorCount++;
try {
// If we've been given an nsIScriptError, then we can print out
// something nicely formatted, for tools like Emacs to pick up.
var scriptError = aMessage.QueryInterface(Ci.nsIScriptError);
dumpn(aMessage.sourceName + ":" + aMessage.lineNumber + ": " +
scriptErrorFlagsToKind(aMessage.flags) + ": " +
aMessage.errorMessage);
var string = aMessage.errorMessage;
} catch (x) {
message.QueryInterface(Ci.nsIScriptError);
dumpn(message.sourceName + ":" + message.lineNumber + ": " +
scriptErrorFlagsToKind(message.flags) + ": " +
message.errorMessage);
string = message.errorMessage;
} catch (e1) {
// Be a little paranoid with message, as the whole goal here is to lose
// no information.
try {
var string = "" + aMessage.message;
} catch (x) {
var string = "<error converting error message to string>";
string = "" + message.message;
} catch (e2) {
string = "<error converting error message to string>";
}
}
@ -310,8 +315,7 @@ var listener = {
var consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
consoleService.registerListener(listener);
function check_except(func)
{
function check_except(func) {
try {
func();
} catch (e) {
@ -322,70 +326,67 @@ function check_except(func)
do_check_true(false);
}
function testGlobal(aName) {
let systemPrincipal = Cc["@mozilla.org/systemprincipal;1"]
.createInstance(Ci.nsIPrincipal);
let sandbox = Cu.Sandbox(systemPrincipal);
sandbox.__name = aName;
function testGlobal(name) {
let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"]
.createInstance(Ci.nsIPrincipal));
sandbox.__name = name;
return sandbox;
}
function addTestGlobal(aName, aServer = DebuggerServer)
{
let global = testGlobal(aName);
aServer.addTestGlobal(global);
function addTestGlobal(name, server = DebuggerServer) {
let global = testGlobal(name);
server.addTestGlobal(global);
return global;
}
// List the DebuggerClient |aClient|'s tabs, look for one whose title is
// |aTitle|, and apply |aCallback| to the packet's entry for that tab.
function getTestTab(aClient, aTitle, aCallback) {
aClient.listTabs(function (aResponse) {
for (let tab of aResponse.tabs) {
if (tab.title === aTitle) {
aCallback(tab, aResponse);
// List the DebuggerClient |client|'s tabs, look for one whose title is
// |title|, and apply |callback| to the packet's entry for that tab.
function getTestTab(client, title, callback) {
client.listTabs(function (response) {
for (let tab of response.tabs) {
if (tab.title === title) {
callback(tab, response);
return;
}
}
aCallback(null);
callback(null);
});
}
// Attach to |aClient|'s tab whose title is |aTitle|; pass |aCallback| the
// Attach to |client|'s tab whose title is |title|; pass |callback| the
// response packet and a TabClient instance referring to that tab.
function attachTestTab(aClient, aTitle, aCallback) {
getTestTab(aClient, aTitle, function (aTab) {
aClient.attachTab(aTab.actor, aCallback);
function attachTestTab(client, title, callback) {
getTestTab(client, title, function (tab) {
client.attachTab(tab.actor, callback);
});
}
// Attach to |aClient|'s tab whose title is |aTitle|, and then attach to
// that tab's thread. Pass |aCallback| the thread attach response packet, a
// Attach to |client|'s tab whose title is |title|, and then attach to
// that tab's thread. Pass |callback| the thread attach response packet, a
// TabClient referring to the tab, and a ThreadClient referring to the
// thread.
function attachTestThread(aClient, aTitle, aCallback) {
attachTestTab(aClient, aTitle, function (aTabResponse, aTabClient) {
function onAttach(aResponse, aThreadClient) {
aCallback(aResponse, aTabClient, aThreadClient, aTabResponse);
function attachTestThread(client, title, callback) {
attachTestTab(client, title, function (tabResponse, tabClient) {
function onAttach(response, threadClient) {
callback(response, tabClient, threadClient, tabResponse);
}
aTabClient.attachThread({
tabClient.attachThread({
useSourceMaps: true,
autoBlackBox: true
}, onAttach);
});
}
// Attach to |aClient|'s tab whose title is |aTitle|, attach to the tab's
// thread, and then resume it. Pass |aCallback| the thread's response to
// Attach to |client|'s tab whose title is |title|, attach to the tab's
// thread, and then resume it. Pass |callback| the thread's response to
// the 'resume' packet, a TabClient for the tab, and a ThreadClient for the
// thread.
function attachTestTabAndResume(aClient, aTitle, aCallback = () => {}) {
return new Promise((resolve, reject) => {
attachTestThread(aClient, aTitle, function (aResponse, aTabClient, aThreadClient) {
aThreadClient.resume(function (aResponse) {
aCallback(aResponse, aTabClient, aThreadClient);
resolve([aResponse, aTabClient, aThreadClient]);
function attachTestTabAndResume(client, title, callback = () => {}) {
return new Promise((resolve) => {
attachTestThread(client, title, function (response, tabClient, threadClient) {
threadClient.resume(function (response) {
callback(response, tabClient, threadClient);
resolve([response, tabClient, threadClient]);
});
});
});
@ -394,11 +395,12 @@ function attachTestTabAndResume(aClient, aTitle, aCallback = () => {}) {
/**
* Initialize the testing debugger server.
*/
function initTestDebuggerServer(aServer = DebuggerServer)
{
aServer.registerModule("xpcshell-test/testactors");
function initTestDebuggerServer(server = DebuggerServer) {
server.registerModule("xpcshell-test/testactors");
// Allow incoming connections.
aServer.init(function () { return true; });
server.init(function () {
return true;
});
}
/**
@ -415,18 +417,16 @@ function startTestDebuggerServer(title, server = DebuggerServer) {
return connect(client).then(() => client);
}
function finishClient(aClient)
{
aClient.close(function () {
function finishClient(client) {
client.close(function () {
DebuggerServer.destroy();
do_test_finished();
});
}
// Create a server, connect to it and fetch tab actors for the parent process;
// pass |aCallback| the debugger client and tab actor form with all actor IDs.
function get_chrome_actors(callback)
{
// pass |callback| the debugger client and tab actor form with all actor IDs.
function get_chrome_actors(callback) {
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
@ -449,8 +449,8 @@ function getChromeActors(client, server = DebuggerServer) {
/**
* Takes a relative file path and returns the absolute file url for it.
*/
function getFileUrl(aName, aAllowMissing = false) {
let file = do_get_file(aName, aAllowMissing);
function getFileUrl(name, allowMissing = false) {
let file = do_get_file(name, allowMissing);
return Services.io.newFileURI(file).spec;
}
@ -458,9 +458,8 @@ function getFileUrl(aName, aAllowMissing = false) {
* Returns the full path of the file with the specified name in a
* platform-independent and URL-like form.
*/
function getFilePath(aName, aAllowMissing = false, aUsePlatformPathSeparator = false)
{
let file = do_get_file(aName, aAllowMissing);
function getFilePath(name, allowMissing = false, usePlatformPathSeparator = false) {
let file = do_get_file(name, allowMissing);
let path = Services.io.newFileURI(file).spec;
let filePrePath = "file://";
if ("nsILocalFileWin" in Ci &&
@ -470,7 +469,7 @@ function getFilePath(aName, aAllowMissing = false, aUsePlatformPathSeparator = f
path = path.slice(filePrePath.length);
if (aUsePlatformPathSeparator && path.match(/^\w:/)) {
if (usePlatformPathSeparator && path.match(/^\w:/)) {
path = path.replace(/\//g, "\\");
}
@ -480,8 +479,8 @@ function getFilePath(aName, aAllowMissing = false, aUsePlatformPathSeparator = f
/**
* Returns the full text contents of the given file.
*/
function readFile(aFileName) {
let f = do_get_file(aFileName);
function readFile(fileName) {
let f = do_get_file(fileName);
let s = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
s.init(f, -1, -1, false);
@ -492,16 +491,16 @@ function readFile(aFileName) {
}
}
function writeFile(aFileName, aContent) {
let file = do_get_file(aFileName, true);
function writeFile(fileName, content) {
let file = do_get_file(fileName, true);
let stream = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
stream.init(file, -1, -1, 0);
try {
do {
let numWritten = stream.write(aContent, aContent.length);
aContent = aContent.slice(numWritten);
} while (aContent.length > 0);
let numWritten = stream.write(content, content.length);
content = content.slice(numWritten);
} while (content.length > 0);
} finally {
stream.close();
}
@ -585,9 +584,9 @@ StubTransport.prototype.ready = function () {};
StubTransport.prototype.send = function () {};
StubTransport.prototype.close = function () {};
function executeSoon(aFunc) {
function executeSoon(func) {
Services.tm.mainThread.dispatch({
run: DevToolsUtils.makeInfallible(aFunc)
run: DevToolsUtils.makeInfallible(func)
}, Ci.nsIThread.DISPATCH_NORMAL);
}
@ -810,8 +809,7 @@ function getSource(threadClient, url) {
});
if (source.length) {
deferred.resolve(threadClient.source(source[0]));
}
else {
} else {
deferred.reject(new Error("source not found"));
}
});

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint no-unused-vars: ["error", {"vars": "local"}] */
"use strict";
const protocol = require("devtools/shared/protocol");
@ -12,7 +15,5 @@ const helloSpec = protocol.generateActorSpec({
});
var HelloActor = protocol.ActorClassWithSpec(helloSpec, {
hello: function () {
return;
}
hello: function () {}
});

Просмотреть файл

@ -1,11 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function PostInitGlobalActor(aConnection) {}
"use strict";
function PostInitGlobalActor(connection) {}
PostInitGlobalActor.prototype = {
actorPrefix: "postInitGlobal",
onPing: function onPing(aRequest) {
onPing(request) {
return { message: "pong" };
},
};

Просмотреть файл

@ -1,11 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function PostInitTabActor(aConnection) {}
"use strict";
function PostInitTabActor(connection) {}
PostInitTabActor.prototype = {
actorPostfix: "postInitTab",
onPing: function onPing(aRequest) {
onPing(request) {
return { message: "pong" };
},
};

Просмотреть файл

@ -1,11 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function PreInitGlobalActor(aConnection) {}
"use strict";
function PreInitGlobalActor(connection) {}
PreInitGlobalActor.prototype = {
actorPrefix: "preInitGlobal",
onPing: function onPing(aRequest) {
onPing(request) {
return { message: "pong" };
},
};

Просмотреть файл

@ -1,11 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function PreInitTabActor(aConnection) {}
"use strict";
function PreInitTabActor(connection) {}
PreInitTabActor.prototype = {
actorPrefix: "preInitTab",
onPing: function onPing(aRequest) {
onPing(request) {
return { message: "pong" };
},
};

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function Actor() {}
exports.register = function (handle) {

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function Actor() {}
exports.register = function (handle) {

Просмотреть файл

@ -1,7 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
var {method, RetVal, Actor, ActorClassWithSpec, Front, FrontClassWithSpec,
"use strict";
var {RetVal, Actor, ActorClassWithSpec, Front, FrontClassWithSpec,
generateActorSpec} = require("devtools/shared/protocol");
var Services = require("Services");

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check that you can register new actors via the ActorRegistrationActor.
*/
@ -12,8 +14,7 @@ var gOldPref;
const { ActorRegistryFront } = require("devtools/shared/fronts/actor-registry");
function run_test()
{
function run_test() {
gOldPref = Services.prefs.getBoolPref("devtools.debugger.forbid-certified-apps");
Services.prefs.setBoolPref("devtools.debugger.forbid-certified-apps", false);
initTestDebuggerServer();
@ -39,7 +40,7 @@ function registerNewActor() {
gRegistryFront
.registerActor("resource://test/hello-actor.js", options)
.then(actorFront => gActorFront = actorFront)
.then(actorFront => (gActorFront = actorFront))
.then(talkToNewActor)
.then(null, e => {
DevToolsUtils.reportException("registerNewActor", e);

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gClient;
var gActors;
@ -11,8 +13,7 @@ var gActors;
* in order to add actors after initialization but rather can add actors anytime
* regardless of the object's state.
*/
function run_test()
{
function run_test() {
DebuggerServer.addActors("resource://test/pre_init_global_actors.js");
DebuggerServer.addActors("resource://test/pre_init_tab_actors.js");
@ -32,52 +33,47 @@ function run_test()
run_next_test();
}
function init()
{
function init() {
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect()
.then(() => gClient.listTabs())
.then(aResponse => {
gActors = aResponse;
.then(response => {
gActors = response;
run_next_test();
});
}
function test_pre_init_global_actor()
{
function test_pre_init_global_actor() {
gClient.request({ to: gActors.preInitGlobalActor, type: "ping" },
function onResponse(aResponse) {
do_check_eq(aResponse.message, "pong");
function onResponse(response) {
do_check_eq(response.message, "pong");
run_next_test();
}
);
}
function test_pre_init_tab_actor()
{
function test_pre_init_tab_actor() {
gClient.request({ to: gActors.preInitTabActor, type: "ping" },
function onResponse(aResponse) {
do_check_eq(aResponse.message, "pong");
function onResponse(response) {
do_check_eq(response.message, "pong");
run_next_test();
}
);
}
function test_post_init_global_actor()
{
function test_post_init_global_actor() {
gClient.request({ to: gActors.postInitGlobalActor, type: "ping" },
function onResponse(aResponse) {
do_check_eq(aResponse.message, "pong");
function onResponse(response) {
do_check_eq(response.message, "pong");
run_next_test();
}
);
}
function test_post_init_tab_actor()
{
function test_post_init_tab_actor() {
gClient.request({ to: gActors.postInitTabActor, type: "ping" },
function onResponse(aResponse) {
do_check_eq(aResponse.message, "pong");
function onResponse(response) {
do_check_eq(response.message, "pong");
run_next_test();
}
);
@ -88,16 +84,17 @@ function getActorInstance(connID, actorID) {
return DebuggerServer._connections[connID].getActor(actorID);
}
function test_stable_global_actor_instances()
{
function test_stable_global_actor_instances() {
// Consider that there is only one connection,
// and the first one is ours
let connID = Object.keys(DebuggerServer._connections)[0];
let postInitGlobalActor = getActorInstance(connID, gActors.postInitGlobalActor);
let preInitGlobalActor = getActorInstance(connID, gActors.preInitGlobalActor);
gClient.listTabs(function onListTabs(aResponse) {
do_check_eq(postInitGlobalActor, getActorInstance(connID, aResponse.postInitGlobalActor));
do_check_eq(preInitGlobalActor, getActorInstance(connID, aResponse.preInitGlobalActor));
gClient.listTabs(function onListTabs(response) {
do_check_eq(postInitGlobalActor,
getActorInstance(connID, response.postInitGlobalActor));
do_check_eq(preInitGlobalActor,
getActorInstance(connID, response.preInitGlobalActor));
run_next_test();
});
}

Просмотреть файл

@ -1,7 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
const protocol = require("devtools/shared/protocol");
const {AddonManager} = require("resource://gre/modules/AddonManager.jsm");
startupAddonsManager();
@ -80,7 +82,7 @@ add_task(function* testReloadExitedAddon() {
// Uninstall the decoy add-on, which should cause its actor to exit.
const onUninstalled = promiseAddonEvent("onUninstalled");
installedAddon2.uninstall();
const [uninstalledAddon] = yield onUninstalled;
yield onUninstalled;
// Try to re-list all add-ons after a reload.
// This was throwing an exception because of the exited actor.

Просмотреть файл

@ -1,8 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
const protocol = require("devtools/shared/protocol");
const {AddonsActor} = require("devtools/server/actors/addons");
const {AddonsFront} = require("devtools/shared/fronts/addons");
startupAddonsManager();

Просмотреть файл

@ -1,36 +1,35 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gClient;
var gDebuggee;
function run_test()
{
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) {
test_attach(aTabClient);
gClient.connect().then(function ([type, traits]) {
attachTestTab(gClient, "test-1", function (reply, tabClient) {
test_attach(tabClient);
});
});
do_test_pending();
}
function test_attach(aTabClient)
{
aTabClient.attachThread({}, function (aResponse, aThreadClient) {
do_check_eq(aThreadClient.state, "paused");
aThreadClient.resume(cleanup);
function test_attach(tabClient) {
tabClient.attachThread({}, function (response, threadClient) {
do_check_eq(threadClient.state, "paused");
threadClient.resume(cleanup);
});
}
function cleanup()
{
gClient.addListener("closed", function (aEvent) {
function cleanup() {
gClient.addListener("closed", function (event) {
do_test_finished();
});
gClient.close();

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Test basic black boxing.
*/
@ -9,14 +11,14 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-black-box");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-black-box",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
testBlackBox();
});
});
@ -43,27 +45,27 @@ const testBlackBox = Task.async(function* () {
// Test that we can step into `doStuff` when we are not black boxed.
yield runTest(
function onSteppedLocation(aLocation) {
do_check_eq(aLocation.source.url, BLACK_BOXED_URL);
do_check_eq(aLocation.line, 2);
function onSteppedLocation(location) {
do_check_eq(location.source.url, BLACK_BOXED_URL);
do_check_eq(location.line, 2);
},
function onDebuggerStatementFrames(aFrames) {
do_check_true(!aFrames.some(f => f.where.source.isBlackBoxed));
function onDebuggerStatementFrames(frames) {
do_check_true(!frames.some(f => f.where.source.isBlackBoxed));
}
);
let blackBoxResponse = yield blackBox(sourceClient);
yield blackBox(sourceClient);
do_check_true(sourceClient.isBlackBoxed);
// Test that we step through `doStuff` when we are black boxed and its frame
// doesn't show up.
yield runTest(
function onSteppedLocation(aLocation) {
do_check_eq(aLocation.source.url, SOURCE_URL);
do_check_eq(aLocation.line, 4);
function onSteppedLocation(location) {
do_check_eq(location.source.url, SOURCE_URL);
do_check_eq(location.line, 4);
},
function onDebuggerStatementFrames(aFrames) {
for (let f of aFrames) {
function onDebuggerStatementFrames(frames) {
for (let f of frames) {
if (f.where.source.url == BLACK_BOXED_URL) {
do_check_true(f.where.source.isBlackBoxed);
} else {
@ -73,17 +75,17 @@ const testBlackBox = Task.async(function* () {
}
);
let unBlackBoxResponse = yield unBlackBox(sourceClient);
yield unBlackBox(sourceClient);
do_check_true(!sourceClient.isBlackBoxed);
// Test that we can step into `doStuff` again.
yield runTest(
function onSteppedLocation(aLocation) {
do_check_eq(aLocation.source.url, BLACK_BOXED_URL);
do_check_eq(aLocation.line, 2);
function onSteppedLocation(location) {
do_check_eq(location.source.url, BLACK_BOXED_URL);
do_check_eq(location.line, 2);
},
function onDebuggerStatementFrames(aFrames) {
do_check_true(!aFrames.some(f => f.where.source.isBlackBoxed));
function onDebuggerStatementFrames(frames) {
do_check_true(!frames.some(f => f.where.source.isBlackBoxed));
}
);
@ -91,6 +93,7 @@ const testBlackBox = Task.async(function* () {
});
function evalCode() {
/* eslint-disable */
Components.utils.evalInSandbox(
"" + function doStuff(k) { // line 1
let arg = 15; // line 2 - Step in here
@ -116,6 +119,7 @@ function evalCode() {
SOURCE_URL,
1
);
/* eslint-enable */
}
const runTest = Task.async(function* (onSteppedLocation, onDebuggerStatementFrames) {

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Test that we don't hit breakpoints in black boxed sources, and that when we
@ -11,14 +14,14 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-black-box");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-black-box",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_black_box();
});
});
@ -28,27 +31,27 @@ 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 (aEvent, aPacket) {
gThreadClient.eval(aPacket.frame.actor, "doStuff", function (aResponse) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let obj = gThreadClient.pauseGrip(aPacket.why.frameFinished.return);
function test_black_box() {
gClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.eval(packet.frame.actor, "doStuff", function (response) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let obj = gThreadClient.pauseGrip(packet.why.frameFinished.return);
obj.getDefinitionSite(runWithSource);
});
});
function runWithSource(aPacket) {
let source = gThreadClient.source(aPacket.source);
function runWithSource(packet) {
let source = gThreadClient.source(packet.source);
source.setBreakpoint({
line: 2
}, function (aResponse) {
do_check_true(!aResponse.error, "Should be able to set breakpoint.");
}, function (response) {
do_check_true(!response.error, "Should be able to set breakpoint.");
gThreadClient.resume(test_black_box_breakpoint);
});
}
});
/* eslint-disable */
Components.utils.evalInSandbox(
"" + function doStuff(k) { // line 1
let arg = 15; // line 2 - Break here
@ -74,17 +77,21 @@ function test_black_box()
SOURCE_URL,
1
);
/* eslint-enable */
}
function test_black_box_breakpoint() {
gThreadClient.getSources(function ({error, sources}) {
do_check_true(!error, "Should not get an error: " + error);
let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]);
let sourceClient = gThreadClient.source(
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
sourceClient.blackBox(function ({error}) {
do_check_true(!error, "Should not get an error: " + error);
gClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_eq(aPacket.why.type, "debuggerStatement",
gClient.addOneTimeListener("paused", function (event, packet) {
do_check_eq(
packet.why.type, "debuggerStatement",
"We should pass over the breakpoint since the source is black boxed.");
gThreadClient.resume(test_unblack_box_breakpoint.bind(null, sourceClient));
});
@ -93,14 +100,15 @@ function test_black_box_breakpoint() {
});
}
function test_unblack_box_breakpoint(aSourceClient) {
aSourceClient.unblackBox(function ({error}) {
function test_unblack_box_breakpoint(sourceClient) {
sourceClient.unblackBox(function ({error}) {
do_check_true(!error, "Should not get an error: " + error);
gClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_eq(aPacket.why.type, "breakpoint",
gClient.addOneTimeListener("paused", function (event, packet) {
do_check_eq(packet.why.type, "breakpoint",
"We should hit the breakpoint again");
// We will hit the debugger statement on resume, so do this nastiness to skip over it.
// We will hit the debugger statement on resume, so do this
// nastiness to skip over it.
gClient.addOneTimeListener(
"paused",
gThreadClient.resume.bind(

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Test that we don't stop at debugger statements inside black boxed sources.
@ -10,14 +13,14 @@ var gClient;
var gThreadClient;
var gBpClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-black-box");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-black-box",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_black_box();
});
});
@ -27,10 +30,9 @@ 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 (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_black_box() {
gClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
source.setBreakpoint({
line: 4
}, function ({error}, bpClient) {
@ -40,6 +42,7 @@ function test_black_box()
});
});
/* eslint-disable */
Components.utils.evalInSandbox(
"" + function doStuff(k) { // line 1
debugger; // line 2 - Break here
@ -65,18 +68,21 @@ function test_black_box()
SOURCE_URL,
1
);
/* eslint-enable */
}
function test_black_box_dbg_statement() {
gThreadClient.getSources(function ({error, sources}) {
do_check_true(!error, "Should not get an error: " + error);
let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]);
let sourceClient = gThreadClient.source(
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
sourceClient.blackBox(function ({error}) {
do_check_true(!error, "Should not get an error: " + error);
gClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_eq(aPacket.why.type, "breakpoint",
gClient.addOneTimeListener("paused", function (event, packet) {
do_check_eq(packet.why.type, "breakpoint",
"We should pass over the debugger statement.");
gBpClient.remove(function ({error}) {
do_check_true(!error, "Should not get an error: " + error);
@ -88,12 +94,12 @@ function test_black_box_dbg_statement() {
});
}
function test_unblack_box_dbg_statement(aSourceClient) {
aSourceClient.unblackBox(function ({error}) {
function test_unblack_box_dbg_statement(sourceClient) {
sourceClient.unblackBox(function ({error}) {
do_check_true(!error, "Should not get an error: " + error);
gClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_eq(aPacket.why.type, "debuggerStatement",
gClient.addOneTimeListener("paused", function (event, packet) {
do_check_eq(packet.why.type, "debuggerStatement",
"We should stop at the debugger statement again");
finishClient(gClient);
});

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Test behavior of blackboxing sources we are currently paused in.
@ -9,14 +12,14 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-black-box");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-black-box",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_black_box();
});
});
@ -26,27 +29,27 @@ 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 (aEvent, aPacket) {
gThreadClient.eval(aPacket.frame.actor, "doStuff", function (aResponse) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let obj = gThreadClient.pauseGrip(aPacket.why.frameFinished.return);
function test_black_box() {
gClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.eval(packet.frame.actor, "doStuff", function (response) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let obj = gThreadClient.pauseGrip(packet.why.frameFinished.return);
obj.getDefinitionSite(runWithSource);
});
});
function runWithSource(aPacket) {
let source = gThreadClient.source(aPacket.source);
function runWithSource(packet) {
let source = gThreadClient.source(packet.source);
source.setBreakpoint({
line: 2
}, function (aResponse) {
do_check_true(!aResponse.error, "Should be able to set breakpoint.");
}, function (response) {
do_check_true(!response.error, "Should be able to set breakpoint.");
test_black_box_paused();
});
}
});
/* eslint-disable */
Components.utils.evalInSandbox(
"" + function doStuff(k) { // line 1
debugger; // line 2
@ -72,16 +75,20 @@ function test_black_box()
SOURCE_URL,
1
);
/* eslint-enable */
}
function test_black_box_paused() {
gThreadClient.getSources(function ({error, sources}) {
do_check_true(!error, "Should not get an error: " + error);
let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]);
let sourceClient = gThreadClient.source(
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
sourceClient.blackBox(function ({error, pausedInSource}) {
do_check_true(!error, "Should not get an error: " + error);
do_check_true(pausedInSource, "We should be notified that we are currently paused in this source");
do_check_true(pausedInSource,
"We should be notified that we are currently paused in this source");
finishClient(gClient);
});
});

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Test exceptions inside black boxed sources.
@ -9,14 +12,15 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-black-box");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(
gClient, "test-black-box",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
// XXX: We have to do an executeSoon so that the error isn't caught and
// reported by DebuggerClient.requester (because we are using the local
// transport and share a stack) which causes the test to fail.
@ -31,10 +35,10 @@ function run_test()
const BLACK_BOXED_URL = "http://example.com/blackboxme.js";
const SOURCE_URL = "http://example.com/source.js";
function test_black_box()
{
function test_black_box() {
gClient.addOneTimeListener("paused", test_black_box_exception);
/* eslint-disable */
Components.utils.evalInSandbox(
"" + function doStuff(k) { // line 1
throw new Error("wu tang clan ain't nuthin' ta fuck wit"); // line 2
@ -61,19 +65,22 @@ function test_black_box()
SOURCE_URL,
1
);
/* eslint-enable */
}
function test_black_box_exception() {
gThreadClient.getSources(function ({error, sources}) {
do_check_true(!error, "Should not get an error: " + error);
let sourceClient = gThreadClient.source(sources.filter(s => s.url == BLACK_BOXED_URL)[0]);
let sourceClient = gThreadClient.source(
sources.filter(s => s.url == BLACK_BOXED_URL)[0]
);
sourceClient.blackBox(function ({error}) {
do_check_true(!error, "Should not get an error: " + error);
gThreadClient.pauseOnExceptions(true);
gClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_eq(aPacket.frame.where.source.url, SOURCE_URL,
gClient.addOneTimeListener("paused", function (event, packet) {
do_check_eq(packet.frame.where.source.url, SOURCE_URL,
"We shouldn't pause while in the black boxed source.");
finishClient(gClient);
});

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Test that we can black box source mapped sources.
@ -11,14 +14,15 @@ var gThreadClient;
const {SourceNode} = require("source-map");
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-black-box");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(
gClient, "test-black-box",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
promise.resolve(setup_code())
.then(black_box_code)
@ -36,6 +40,7 @@ function run_test()
}
function setup_code() {
/* eslint-disable */
let { code, map } = (new SourceNode(null, null, null, [
new SourceNode(1, 0, "a.js", "" + function a() {
return b();
@ -54,6 +59,7 @@ function setup_code() {
file: "abc.js",
sourceRoot: "http://example.com/"
});
/* eslint-enable */
code += "//# sourceMappingURL=data:text/json," + map.toString();
@ -85,8 +91,8 @@ function black_box_code() {
function run_code() {
const d = promise.defer();
gClient.addOneTimeListener("paused", function (aEvent, aPacket) {
d.resolve(aPacket);
gClient.addOneTimeListener("paused", function (event, packet) {
d.resolve(packet);
gThreadClient.resume();
});
gDebuggee.a();
@ -94,9 +100,10 @@ function run_code() {
return d.promise;
}
function test_correct_location(aPacket) {
do_check_eq(aPacket.why.type, "debuggerStatement",
function test_correct_location(packet) {
do_check_eq(packet.why.type, "debuggerStatement",
"Should hit a debugger statement.");
do_check_eq(aPacket.frame.where.source.url, "http://example.com/c.js",
"Should have skipped over the debugger statement in the black boxed source");
do_check_eq(packet.frame.where.source.url, "http://example.com/c.js",
"Should have skipped over the debugger statement in the" +
" black boxed source");
}

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Test that sources whose URL ends with ".min.js" automatically get black
* boxed.
@ -10,14 +12,14 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-black-box");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-black-box", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-black-box",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
testBlackBox();
});
});

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check basic breakpoint functionality.
@ -9,55 +12,52 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_simple_breakpoint();
});
});
}
function test_simple_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = {
line: gDebuggee.line0 + 3
};
source.setBreakpoint(location, function (aResponse, bpClient) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
source.setBreakpoint(location, function (response, bpClient) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.frame.where.source.actor, source.actor);
do_check_eq(aPacket.frame.where.line, location.line);
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line);
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a, 1);
do_check_eq(gDebuggee.b, undefined);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
gClient.close().then(gCallback);
});
});
});
// Continue until the breakpoint is hit.
@ -65,6 +65,7 @@ function test_simple_breakpoint()
});
});
/* eslint-disable */
Cu.evalInSandbox(
"var line0 = Error().lineNumber;\n" +
"debugger;\n" + // line0 + 1
@ -72,4 +73,5 @@ function test_simple_breakpoint()
"var b = 2;\n", // line0 + 3
gDebuggee
);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Check that setting breakpoints when the debuggee is running works.
@ -10,46 +13,44 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_breakpoint_running();
});
});
}
function test_breakpoint_running()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
function test_breakpoint_running() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let location = { line: gDebuggee.line0 + 3 };
gThreadClient.resume();
// Setting the breakpoint later should interrupt the debuggee.
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.type, "interrupted");
gThreadClient.addOneTimeListener("paused", function (event, packet) {
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "interrupted");
});
let source = gThreadClient.source(aPacket.frame.where.source);
source.setBreakpoint(location, function (aResponse) {
let source = gThreadClient.source(packet.frame.where.source);
source.setBreakpoint(location, 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.
do_check_neq(aResponse.error, "noScript");
do_check_neq(response.error, "noScript");
do_execute_soon(function () {
gClient.close().then(gCallback);
@ -57,6 +58,7 @@ function test_breakpoint_running()
});
});
/* eslint-disable */
Cu.evalInSandbox(
"var line0 = Error().lineNumber;\n" +
"debugger;\n" +
@ -64,4 +66,5 @@ function test_breakpoint_running()
"var b = 2;\n", // line0 + 3
gDebuggee
);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that setting a breakpoint on a line without code will skip
@ -12,68 +15,66 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient,
"test-stack",
function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_skip_breakpoint();
});
});
}
var test_no_skip_breakpoint = Task.async(function* (source, location) {
let [aResponse, bpClient] = yield source.setBreakpoint(
let [response, bpClient] = yield source.setBreakpoint(
Object.assign({}, location, { noSliding: true })
);
do_check_true(!aResponse.actualLocation);
do_check_true(!response.actualLocation);
do_check_eq(bpClient.location.line, gDebuggee.line0 + 3);
yield bpClient.remove();
});
var test_skip_breakpoint = function () {
gThreadClient.addOneTimeListener("paused", Task.async(function *(aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", Task.async(function* (event, packet) {
let location = { line: gDebuggee.line0 + 3 };
let source = gThreadClient.source(aPacket.frame.where.source);
let source = gThreadClient.source(packet.frame.where.source);
// First, make sure that we can disable sliding with the
// `noSliding` option.
yield test_no_skip_breakpoint(source, location);
// Now make sure that the breakpoint properly slides forward one line.
const [aResponse, bpClient] = yield source.setBreakpoint(location);
do_check_true(!!aResponse.actualLocation);
do_check_eq(aResponse.actualLocation.source.actor, source.actor);
do_check_eq(aResponse.actualLocation.line, location.line + 1);
const [response, bpClient] = yield source.setBreakpoint(location);
do_check_true(!!response.actualLocation);
do_check_eq(response.actualLocation.source.actor, source.actor);
do_check_eq(response.actualLocation.line, location.line + 1);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.frame.where.source.actor, source.actor);
do_check_eq(aPacket.frame.where.line, location.line + 1);
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line + 1);
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a, 1);
do_check_eq(gDebuggee.b, undefined);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
gClient.close().then(gCallback);
});
@ -85,6 +86,7 @@ var test_skip_breakpoint = function() {
// Use `evalInSandbox` to make the debugger treat it as normal
// globally-scoped code, where breakpoint sliding rules apply.
/* eslint-disable */
Cu.evalInSandbox(
"var line0 = Error().lineNumber;\n" +
"debugger;\n" + // line0 + 1
@ -93,4 +95,5 @@ var test_skip_breakpoint = function() {
"var b = 2;", // line0 + 4
gDebuggee
);
}
/* eslint-enable */
};

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that setting a breakpoint in a line in a child script works.
@ -10,51 +13,49 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_child_breakpoint();
});
});
}
function test_child_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_child_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = { line: gDebuggee.line0 + 3 };
source.setBreakpoint(location, function (aResponse, bpClient) {
source.setBreakpoint(location, function (response, bpClient) {
// actualLocation is not returned when breakpoints don't skip forward.
do_check_eq(aResponse.actualLocation, undefined);
do_check_eq(response.actualLocation, undefined);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.frame.where.source.actor, source.actor);
do_check_eq(aPacket.frame.where.line, location.line);
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line);
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a, 1);
do_check_eq(gDebuggee.b, undefined);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
gClient.close().then(gCallback);
});
@ -64,9 +65,9 @@ function test_child_breakpoint()
// Continue until the breakpoint is hit.
gThreadClient.resume();
});
});
/* eslint-disable */
Cu.evalInSandbox(
"var line0 = Error().lineNumber;\n" +
"function foo() {\n" + // line0 + 1
@ -77,4 +78,5 @@ function test_child_breakpoint()
"foo();\n", // line0 + 6
gDebuggee
);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that setting a breakpoint in a line without code in a child script
@ -11,52 +14,50 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_child_skip_breakpoint();
});
});
}
function test_child_skip_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_child_skip_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = { line: gDebuggee.line0 + 3 };
source.setBreakpoint(location, function (aResponse, bpClient) {
source.setBreakpoint(location, function (response, bpClient) {
// Check that the breakpoint has properly skipped forward one line.
do_check_eq(aResponse.actualLocation.source.actor, source.actor);
do_check_eq(aResponse.actualLocation.line, location.line + 1);
do_check_eq(response.actualLocation.source.actor, source.actor);
do_check_eq(response.actualLocation.line, location.line + 1);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.frame.where.source.actor, source.actor);
do_check_eq(aPacket.frame.where.line, location.line + 1);
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line + 1);
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a, 1);
do_check_eq(gDebuggee.b, undefined);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
gClient.close().then(gCallback);
});
@ -68,6 +69,7 @@ function test_child_skip_breakpoint()
});
});
/* eslint-disable */
Cu.evalInSandbox(
"var line0 = Error().lineNumber;\n" +
"function foo() {\n" + // line0 + 1
@ -79,4 +81,5 @@ function test_child_skip_breakpoint()
"foo();\n", // line0 + 7
gDebuggee
);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that setting a breakpoint in a line without code in a deeply-nested
@ -11,52 +14,50 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_nested_breakpoint();
});
});
}
function test_nested_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_nested_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = { line: gDebuggee.line0 + 5 };
source.setBreakpoint(location, function (aResponse, bpClient) {
source.setBreakpoint(location, function (response, bpClient) {
// Check that the breakpoint has properly skipped forward one line.
do_check_eq(aResponse.actualLocation.source.actor, source.actor);
do_check_eq(aResponse.actualLocation.line, location.line + 1);
do_check_eq(response.actualLocation.source.actor, source.actor);
do_check_eq(response.actualLocation.line, location.line + 1);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.frame.where.source.actor, source.actor);
do_check_eq(aPacket.frame.where.line, location.line + 1);
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line + 1);
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a, 1);
do_check_eq(gDebuggee.b, undefined);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
gClient.close().then(gCallback);
});
@ -66,9 +67,9 @@ function test_nested_breakpoint()
// Continue until the breakpoint is hit.
gThreadClient.resume();
});
});
/* eslint-disable */
Cu.evalInSandbox(
"var line0 = Error().lineNumber;\n" +
"function foo() {\n" + // line0 + 1
@ -86,4 +87,5 @@ function test_nested_breakpoint()
"foo();\n", // line0 + 13
gDebuggee
);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that setting a breakpoint in a line without code in the second child
@ -11,52 +14,50 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_second_child_skip_breakpoint();
});
});
}
function test_second_child_skip_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_second_child_skip_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = { line: gDebuggee.line0 + 6 };
source.setBreakpoint(location, function (aResponse, bpClient) {
source.setBreakpoint(location, function (response, bpClient) {
// Check that the breakpoint has properly skipped forward one line.
do_check_eq(aResponse.actualLocation.source.actor, source.actor);
do_check_eq(aResponse.actualLocation.line, location.line + 1);
do_check_eq(response.actualLocation.source.actor, source.actor);
do_check_eq(response.actualLocation.line, location.line + 1);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.frame.where.source.actor, source.actor);
do_check_eq(aPacket.frame.where.line, location.line + 1);
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line + 1);
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a, 1);
do_check_eq(gDebuggee.b, undefined);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
gClient.close().then(gCallback);
});
@ -68,6 +69,7 @@ function test_second_child_skip_breakpoint()
});
});
/* eslint-disable */
Cu.evalInSandbox(
"var line0 = Error().lineNumber;\n" +
"function foo() {\n" + // line0 + 1
@ -82,4 +84,5 @@ function test_second_child_skip_breakpoint()
"foo();\n", // line0 + 10
gDebuggee
);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that setting a breakpoint in a line without code in a child script
@ -11,60 +14,58 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_child_skip_breakpoint();
});
});
}
function test_child_skip_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.eval(aPacket.frame.actor, "foo", function (aResponse) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let obj = gThreadClient.pauseGrip(aPacket.why.frameFinished.return);
function test_child_skip_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.eval(packet.frame.actor, "foo", function (response) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let obj = gThreadClient.pauseGrip(packet.why.frameFinished.return);
obj.getDefinitionSite(runWithBreakpoint);
});
});
function runWithBreakpoint(aPacket) {
let source = gThreadClient.source(aPacket.source);
function runWithBreakpoint(packet) {
let source = gThreadClient.source(packet.source);
let location = { line: gDebuggee.line0 + 3 };
source.setBreakpoint(location, function (aResponse, bpClient) {
source.setBreakpoint(location, function (response, bpClient) {
// Check that the breakpoint has properly skipped forward one line.
do_check_eq(aResponse.actualLocation.source.actor, source.actor);
do_check_eq(aResponse.actualLocation.line, location.line + 1);
do_check_eq(response.actualLocation.source.actor, source.actor);
do_check_eq(response.actualLocation.line, location.line + 1);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.frame.where.source.actor, source.actor);
do_check_eq(aPacket.frame.where.line, location.line + 1);
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line + 1);
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a, 1);
do_check_eq(gDebuggee.b, undefined);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
gClient.close().then(gCallback);
});
@ -77,6 +78,7 @@ function test_child_skip_breakpoint()
}
});
/* eslint-disable */
Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
"function foo() {\n" + // line0 + 1
" this.a = 1;\n" + // line0 + 2
@ -93,4 +95,5 @@ function test_child_skip_breakpoint()
gDebuggee,
"1.7",
"script2.js");
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that removing a breakpoint works.
@ -10,51 +13,49 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_remove_breakpoint();
});
});
}
function test_remove_breakpoint()
{
function test_remove_breakpoint() {
let done = false;
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = { line: gDebuggee.line0 + 2 };
source.setBreakpoint(location, function (aResponse, bpClient) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
source.setBreakpoint(location, function (response, bpClient) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.frame.where.source.actor, source.actor);
do_check_eq(aPacket.frame.where.line, location.line);
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line);
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a, undefined);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
done = true;
gThreadClient.addOneTimeListener("paused",
function (aEvent, aPacket) {
function (event, packet) {
// The breakpoint should not be hit again.
gThreadClient.resume(function () {
do_check_true(false);
@ -62,15 +63,13 @@ function test_remove_breakpoint()
});
gThreadClient.resume();
});
});
// Continue until the breakpoint is hit.
gThreadClient.resume();
});
});
});
/* eslint-disable */
Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
"function foo(stop) {\n" + // line0 + 1
" this.a = 1;\n" + // line0 + 2
@ -81,6 +80,7 @@ function test_remove_breakpoint()
"debugger;\n" + // line1 + 7
"foo();\n", // line1 + 8
gDebuggee);
/* eslint-enable */
if (!done) {
do_check_true(false);
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that setting a breakpoint in a line with multiple entry points
@ -11,56 +14,54 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_child_breakpoint();
});
});
}
function test_child_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_child_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = { line: gDebuggee.line0 + 3 };
source.setBreakpoint(location, function (aResponse, bpClient) {
source.setBreakpoint(location, function (response, bpClient) {
// actualLocation is not returned when breakpoints don't skip forward.
do_check_eq(aResponse.actualLocation, undefined);
do_check_eq(response.actualLocation, undefined);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.i, 0);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.i, 1);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
gClient.close().then(gCallback);
});
@ -69,16 +70,13 @@ function test_child_breakpoint()
// Continue until the breakpoint is hit again.
gThreadClient.resume();
});
// Continue until the breakpoint is hit.
gThreadClient.resume();
});
});
});
/* eslint-disable */
Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
"debugger;\n" + // line0 + 1
"var a, i = 0;\n" + // line0 + 2
@ -86,4 +84,5 @@ function test_child_breakpoint()
" a = i;\n" + // line0 + 4
"}\n", // line0 + 5
gDebuggee);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Make sure that setting a breakpoint in a line with bytecodes in multiple
@ -11,57 +14,55 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_child_breakpoint();
});
});
}
function test_child_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_child_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = { line: gDebuggee.line0 + 2 };
source.setBreakpoint(location, function (aResponse, bpClient) {
source.setBreakpoint(location, function (response, bpClient) {
// actualLocation is not returned when breakpoints don't skip forward.
do_check_eq(aResponse.actualLocation, undefined);
do_check_eq(response.actualLocation, undefined);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a, undefined);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a.b, 1);
do_check_eq(gDebuggee.res, undefined);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
gClient.close().then(gCallback);
});
@ -70,19 +71,17 @@ function test_child_breakpoint()
// Continue until the breakpoint is hit again.
gThreadClient.resume();
});
// Continue until the breakpoint is hit.
gThreadClient.resume();
});
});
});
/* eslint-disable */
Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
"debugger;\n" + // line0 + 1
"var a = { b: 1, f: function() { return 2; } };\n" + // line0+2
"var res = a.f();\n", // line0 + 3
gDebuggee);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Make sure that setting a breakpoint twice in a line without bytecodes works
@ -14,47 +17,45 @@ var gBpActor;
var gCount;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
function run_test_with_server(server, callback) {
gCallback = callback;
gCount = 1;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_child_skip_breakpoint();
});
});
}
function test_child_skip_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_child_skip_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = { line: gDebuggee.line0 + 3};
source.setBreakpoint(location, function (aResponse, bpClient) {
source.setBreakpoint(location, function (response, bpClient) {
// Check that the breakpoint has properly skipped forward one line.
do_check_eq(aResponse.actualLocation.source.actor, source.actor);
do_check_eq(aResponse.actualLocation.line, location.line + 1);
gBpActor = aResponse.actor;
do_check_eq(response.actualLocation.source.actor, source.actor);
do_check_eq(response.actualLocation.line, location.line + 1);
gBpActor = response.actor;
// Set more breakpoints at the same location.
set_breakpoints(source, location);
});
});
/* eslint-disable */
Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
"function foo() {\n" + // line0 + 1
" this.a = 1;\n" + // line0 + 2
@ -64,17 +65,18 @@ function test_child_skip_breakpoint()
"debugger;\n" + // line0 + 6
"foo();\n", // line0 + 7
gDebuggee);
/* eslint-enable */
}
// Set many breakpoints at the same location.
function set_breakpoints(source, location) {
do_check_neq(gCount, NUM_BREAKPOINTS);
source.setBreakpoint(location, function (aResponse, bpClient) {
source.setBreakpoint(location, function (response, bpClient) {
// Check that the breakpoint has properly skipped forward one line.
do_check_eq(aResponse.actualLocation.source.actor, source.actor);
do_check_eq(aResponse.actualLocation.line, location.line + 1);
do_check_eq(response.actualLocation.source.actor, source.actor);
do_check_eq(response.actualLocation.line, location.line + 1);
// Check that the same breakpoint actor was returned.
do_check_eq(aResponse.actor, gBpActor);
do_check_eq(response.actor, gBpActor);
if (++gCount < NUM_BREAKPOINTS) {
set_breakpoints(source, location);
@ -83,18 +85,18 @@ function set_breakpoints(source, location) {
// After setting all the breakpoints, check that only one has effectively
// remained.
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.frame.where.source.actor, source.actor);
do_check_eq(aPacket.frame.where.line, location.line + 1);
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(packet.type, "paused");
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line + 1);
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
// Check that the breakpoint worked.
do_check_eq(gDebuggee.a, 1);
do_check_eq(gDebuggee.b, undefined);
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// We don't expect any more pauses after the breakpoint was hit once.
do_check_true(false);
});
@ -104,10 +106,8 @@ function set_breakpoints(source, location) {
gClient.close().then(gCallback);
});
});
});
// Continue until the breakpoint is hit.
gThreadClient.resume();
});
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Check that execution doesn't pause twice while stepping, when encountering
@ -11,80 +14,78 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_simple_breakpoint();
});
});
}
function test_simple_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = { line: gDebuggee.line0 + 2 };
source.setBreakpoint(location, Task.async(function* (aResponse, bpClient) {
source.setBreakpoint(location, Task.async(function* (response, bpClient) {
const testCallbacks = [
function (aPacket) {
function (packet) {
// Check that the stepping worked.
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5);
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5);
do_check_eq(packet.why.type, "resumeLimit");
},
function (aPacket) {
function (packet) {
// Entered the foo function call frame.
do_check_eq(aPacket.frame.where.line, location.line);
do_check_neq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(packet.frame.where.line, location.line);
do_check_neq(packet.why.type, "breakpoint");
do_check_eq(packet.why.type, "resumeLimit");
},
function (aPacket) {
function (packet) {
// At the end of the foo function call frame.
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3);
do_check_neq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3);
do_check_neq(packet.why.type, "breakpoint");
do_check_eq(packet.why.type, "resumeLimit");
},
function (aPacket) {
function (packet) {
// Check that the breakpoint wasn't the reason for this pause, but
// that the frame is about to be popped while stepping.
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3);
do_check_neq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(aPacket.why.frameFinished.return.type, "undefined");
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3);
do_check_neq(packet.why.type, "breakpoint");
do_check_eq(packet.why.type, "resumeLimit");
do_check_eq(packet.why.frameFinished.return.type, "undefined");
},
function (aPacket) {
function (packet) {
// The foo function call frame was just popped from the stack.
do_check_eq(gDebuggee.a, 1);
do_check_eq(gDebuggee.b, undefined);
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5);
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(aPacket.poppedFrames.length, 1);
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5);
do_check_eq(packet.why.type, "resumeLimit");
do_check_eq(packet.poppedFrames.length, 1);
},
function (aPacket) {
function (packet) {
// Check that the debugger statement wasn't the reason for this pause.
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 6);
do_check_neq(aPacket.why.type, "debuggerStatement");
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 6);
do_check_neq(packet.why.type, "debuggerStatement");
do_check_eq(packet.why.type, "resumeLimit");
},
function (aPacket) {
function (packet) {
// Check that the debugger statement wasn't the reason for this pause.
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 7);
do_check_neq(aPacket.why.type, "debuggerStatement");
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 7);
do_check_neq(packet.why.type, "debuggerStatement");
do_check_eq(packet.why.type, "resumeLimit");
},
];
@ -103,6 +104,7 @@ function test_simple_breakpoint()
}));
});
/* eslint-disable */
Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
"function foo() {\n" + // line0 + 1
" this.a = 1;\n" + // line0 + 2 <-- Breakpoint is set here.
@ -112,4 +114,5 @@ function test_simple_breakpoint()
"debugger;\n" + // line0 + 6
"var b = 2;\n", // line0 + 7
gDebuggee);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Check that a breakpoint or a debugger statement cause execution to pause even
@ -11,78 +14,76 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-stack", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-stack", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_simple_breakpoint();
});
});
}
function test_simple_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = { line: gDebuggee.line0 + 2 };
source.setBreakpoint(location, Task.async(function* (aResponse, bpClient) {
source.setBreakpoint(location, Task.async(function* (response, bpClient) {
const testCallbacks = [
function (aPacket) {
function (packet) {
// Check that the stepping worked.
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5);
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5);
do_check_eq(packet.why.type, "resumeLimit");
},
function (aPacket) {
function (packet) {
// Reached the breakpoint.
do_check_eq(aPacket.frame.where.line, location.line);
do_check_eq(aPacket.why.type, "breakpoint");
do_check_neq(aPacket.why.type, "resumeLimit");
do_check_eq(packet.frame.where.line, location.line);
do_check_eq(packet.why.type, "breakpoint");
do_check_neq(packet.why.type, "resumeLimit");
},
function (aPacket) {
function (packet) {
// Stepped to the closing brace of the function.
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3);
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3);
do_check_eq(packet.why.type, "resumeLimit");
},
function (aPacket) {
function (packet) {
// The frame is about to be popped while stepping.
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3);
do_check_neq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(aPacket.why.frameFinished.return.type, "undefined");
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 3);
do_check_neq(packet.why.type, "breakpoint");
do_check_eq(packet.why.type, "resumeLimit");
do_check_eq(packet.why.frameFinished.return.type, "undefined");
},
function (aPacket) {
function (packet) {
// The foo function call frame was just popped from the stack.
do_check_eq(gDebuggee.a, 1);
do_check_eq(gDebuggee.b, undefined);
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 5);
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(aPacket.poppedFrames.length, 1);
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 5);
do_check_eq(packet.why.type, "resumeLimit");
do_check_eq(packet.poppedFrames.length, 1);
},
function (aPacket) {
function (packet) {
// Check that the debugger statement wasn't the reason for this pause.
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 6);
do_check_neq(aPacket.why.type, "debuggerStatement");
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 6);
do_check_neq(packet.why.type, "debuggerStatement");
do_check_eq(packet.why.type, "resumeLimit");
},
function (aPacket) {
function (packet) {
// Check that the debugger statement wasn't the reason for this pause.
do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 7);
do_check_neq(aPacket.why.type, "debuggerStatement");
do_check_eq(aPacket.why.type, "resumeLimit");
do_check_eq(packet.frame.where.line, gDebuggee.line0 + 7);
do_check_neq(packet.why.type, "debuggerStatement");
do_check_eq(packet.why.type, "resumeLimit");
},
];
@ -101,6 +102,7 @@ function test_simple_breakpoint()
}));
});
/* eslint-disable */
Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
"function foo() {\n" + // line0 + 1
" this.a = 1;\n" + // line0 + 2 <-- Breakpoint is set here.
@ -110,4 +112,5 @@ function test_simple_breakpoint()
"debugger;\n" + // line0 + 6
"var b = 2;\n", // line0 + 7
gDebuggee);
/* eslint-enable */
}

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check that adding a breakpoint in the same place returns the same actor.
*/
@ -9,14 +11,14 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
testSameBreakpoint();
});
});
@ -34,10 +36,11 @@ const testSameBreakpoint = Task.async(function* () {
line: 2
};
let [firstResponse, firstBpClient] = yield setBreakpoint(source, wholeLineLocation);
let [secondResponse, secondBpClient] = yield setBreakpoint(source, wholeLineLocation);
let [, firstBpClient] = yield setBreakpoint(source, wholeLineLocation);
let [, secondBpClient] = yield setBreakpoint(source, wholeLineLocation);
do_check_eq(firstBpClient.actor, secondBpClient.actor, "Should get the same actor w/ whole line breakpoints");
do_check_eq(firstBpClient.actor, secondBpClient.actor,
"Should get the same actor w/ whole line breakpoints");
// Specific column
@ -46,15 +49,17 @@ const testSameBreakpoint = Task.async(function* () {
column: 6
};
[firstResponse, firstBpClient] = yield setBreakpoint(source, columnLocation);
[secondResponse, secondBpClient] = yield setBreakpoint(source, columnLocation);
[, firstBpClient] = yield setBreakpoint(source, columnLocation);
[, secondBpClient] = yield setBreakpoint(source, columnLocation);
do_check_eq(secondBpClient.actor, secondBpClient.actor, "Should get the same actor column breakpoints");
do_check_eq(secondBpClient.actor, secondBpClient.actor,
"Should get the same actor column breakpoints");
finishClient(gClient);
});
function evalCode() {
/* eslint-disable */
Components.utils.evalInSandbox(
"" + function doStuff(k) { // line 1
let arg = 15; // line 2 - Step in here
@ -66,4 +71,5 @@ function evalCode() {
SOURCE_URL,
1
);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check that we can set breakpoints in columns, not just lines.
@ -10,57 +13,54 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-breakpoints", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-breakpoints", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient,
"test-breakpoints",
function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_column_breakpoint();
});
});
}
function test_column_breakpoint()
{
function test_column_breakpoint() {
// Debugger statement
gClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
gClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
let location = {
line: gDebuggee.line0 + 1,
column: 55
};
let timesBreakpointHit = 0;
source.setBreakpoint(location, function (aResponse, bpClient) {
gThreadClient.addListener("paused", function onPaused(aEvent, aPacket) {
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.why.actors[0], bpClient.actor);
do_check_eq(aPacket.frame.where.source.actor, source.actor);
do_check_eq(aPacket.frame.where.line, location.line);
do_check_eq(aPacket.frame.where.column, location.column);
source.setBreakpoint(location, function (response, bpClient) {
gThreadClient.addListener("paused", function onPaused(event, packet) {
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line);
do_check_eq(packet.frame.where.column, location.column);
do_check_eq(gDebuggee.acc, timesBreakpointHit);
do_check_eq(aPacket.frame.environment.bindings.variables.i.value,
do_check_eq(packet.frame.environment.bindings.variables.i.value,
timesBreakpointHit);
if (++timesBreakpointHit === 3) {
gThreadClient.removeListener("paused", onPaused);
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(() => gClient.close().then(gCallback));
});
} else {
@ -71,13 +71,13 @@ function test_column_breakpoint()
// Continue until the breakpoint is hit.
gThreadClient.resume();
});
});
/* eslint-disable */
Components.utils.evalInSandbox(
"var line0 = Error().lineNumber;\n" +
"(function () { debugger; this.acc = 0; for (var i = 0; i < 3; i++) this.acc++; }());",
gDebuggee
);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Test that when we add 2 breakpoints to the same line at different columns and
@ -11,21 +14,20 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, do_test_finished);
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-breakpoints", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-breakpoints", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-breakpoints", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-breakpoints",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_breakpoints_columns();
});
});
@ -56,44 +58,44 @@ function test_breakpoints_columns() {
Components.utils.evalInSandbox(code, gDebuggee, "1.8", "http://example.com/", 1);
}
function set_breakpoints(aEvent, aPacket) {
function set_breakpoints(event, packet) {
let first, second;
let source = gThreadClient.source(aPacket.frame.where.source);
let source = gThreadClient.source(packet.frame.where.source);
source.setBreakpoint(firstLocation, function ({ error, actualLocation },
aBreakpointClient) {
breakpointClient) {
do_check_true(!error, "Should not get an error setting the breakpoint");
do_check_true(!actualLocation, "Should not get an actualLocation");
first = aBreakpointClient;
first = breakpointClient;
source.setBreakpoint(secondLocation, function ({ error, actualLocation },
aBreakpointClient) {
breakpointClient) {
do_check_true(!error, "Should not get an error setting the breakpoint");
do_check_true(!actualLocation, "Should not get an actualLocation");
second = aBreakpointClient;
second = breakpointClient;
test_different_actors(first, second);
});
});
}
function test_different_actors(aFirst, aSecond) {
do_check_neq(aFirst.actor, aSecond.actor,
function test_different_actors(first, second) {
do_check_neq(first.actor, second.actor,
"Each breakpoint should have a different actor");
test_remove_one(aFirst, aSecond);
test_remove_one(first, second);
}
function test_remove_one(aFirst, aSecond) {
aFirst.remove(function ({error}) {
function test_remove_one(first, second) {
first.remove(function ({error}) {
do_check_true(!error, "Should not get an error removing a breakpoint");
let hitSecond;
gClient.addListener("paused", function _onPaused(aEvent, {why, frame}) {
gClient.addListener("paused", function _onPaused(event, {why, frame}) {
if (why.type == "breakpoint") {
hitSecond = true;
do_check_eq(why.actors.length, 1,
"Should only be paused because of one breakpoint actor");
do_check_eq(why.actors[0], aSecond.actor,
do_check_eq(why.actors[0], second.actor,
"Should be paused because of the correct breakpoint actor");
do_check_eq(frame.where.line, secondLocation.line,
"Should be at the right line");

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check that we only break on offsets that are entry points for the line we are
* breaking on. Bug 907278.
@ -11,26 +13,24 @@ var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-breakpoints", aServer);
function run_test_with_server(server, callback) {
gCallback = callback;
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-breakpoints", server);
gDebuggee.console = { log: x => void x };
gClient = new DebuggerClient(aServer.connectPipe());
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient,
"test-breakpoints",
function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
setUpCode();
});
});
@ -51,8 +51,8 @@ function setUpCode() {
);
}
function setBreakpoint(aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function setBreakpoint(event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
gClient.addOneTimeListener("resumed", runCode);
source.setBreakpoint({ line: 2 }, ({ error }) => {

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Make sure that setting a breakpoint in a not-yet-existing script doesn't throw
* an error (see bug 897567). Also make sure that this breakpoint works.
@ -9,28 +11,24 @@
var gDebuggee;
var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-breakpoints", aServer);
function run_test_with_server(server, callback) {
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-breakpoints", server);
gDebuggee.console = { log: x => void x };
gClient = new DebuggerClient(aServer.connectPipe());
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient,
"test-breakpoints",
function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
testBreakpoint();
});
});
@ -39,6 +37,7 @@ function run_test_with_server(aServer, aCallback)
const URL = "test.js";
function setUpCode() {
/* eslint-disable */
Cu.evalInSandbox(
"" + function test() { // 1
var a = 1; // 2
@ -49,11 +48,12 @@ function setUpCode() {
"1.8",
URL
);
/* eslint-enable */
}
const testBreakpoint = Task.async(function* () {
let source = yield getSource(gThreadClient, URL);
let [response, bpClient] = yield setBreakpoint(source, {line: 2});
let [response, ] = yield setBreakpoint(source, {line: 2});
ok(!response.error);
let actor = response.actor;

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Verify that when two of the "same" source are loaded concurrently (like e10s
* frame scripts), breakpoints get hit in scripts defined by all sources.
@ -8,11 +10,8 @@
var gDebuggee;
var gClient;
var gTraceClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-breakpoints");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
@ -22,7 +21,8 @@ function run_test()
do_test_pending();
}
const testBreakpoint = Task.async(function* (threadResponse, tabClient, threadClient, tabResponse) {
const testBreakpoint = Task.async(function* (threadResponse, tabClient,
threadClient, tabResponse) {
evalSetupCode();
// Load the test source once.
@ -34,7 +34,7 @@ const testBreakpoint = Task.async(function* (threadResponse, tabClient, threadCl
// Set a breakpoint in the test source.
const source = yield getSource(threadClient, "test.js");
const [response, bpClient] = yield setBreakpoint(source, {
const [response, ] = yield setBreakpoint(source, {
line: 3
});
ok(!response.error, "Shouldn't get an error setting the BP.");

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Bug 1122064 - make sure that scripts introduced via onNewScripts
* properly populate the `ScriptStore` with all there nested child
@ -10,27 +12,23 @@
var gDebuggee;
var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-breakpoints", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-breakpoints", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient,
"test-breakpoints",
function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test();
});
});
@ -62,6 +60,7 @@ const test = Task.async(function* () {
finishClient(gClient);
});
/* eslint-disable */
function evalCode() {
// Start a new script
Components.utils.evalInSandbox(

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Bug 1333219 - make that setBreakpoint fails when script is not found
* at the specified line.
@ -9,27 +11,23 @@
var gDebuggee;
var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
function run_test() {
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
}
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-breakpoints", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
function run_test_with_server(server, callback) {
initTestDebuggerServer(server);
gDebuggee = addTestGlobal("test-breakpoints", server);
gClient = new DebuggerClient(server.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient,
"test-breakpoints",
function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test();
});
});
@ -46,7 +44,7 @@ const test = Task.async(function* () {
line: gDebuggee.line0 + 2
};
let [res, bpClient] = yield setBreakpoint(source, location);
let [res, ] = yield setBreakpoint(source, location);
ok(!res.error);
let location2 = {

Просмотреть файл

@ -128,7 +128,9 @@ function test_find_actors() {
// Breakpoints by URL
bpSet = new Set(bps.filter(bp => { return bp.originalSourceActor.actorID === "actor1"; }));
bpSet = new Set(bps.filter(bp => {
return bp.originalSourceActor.actorID === "actor1";
}));
for (let bp of bpStore.findActors({ originalSourceActor: { actorID: "actor1" } })) {
bpSet.delete(bp);
}
@ -137,9 +139,12 @@ function test_find_actors() {
// Breakpoints by URL and line
bpSet = new Set(bps.filter(bp => { return bp.originalSourceActor.actorID === "actor1" && bp.originalLine === 10; }));
bpSet = new Set(bps.filter(bp => {
return bp.originalSourceActor.actorID === "actor1" && bp.originalLine === 10;
}));
let first = true;
for (let bp of bpStore.findActors({ originalSourceActor: { actorID: "actor1" }, originalLine: 10 })) {
for (let bp of bpStore.findActors({ originalSourceActor: { actorID: "actor1" },
originalLine: 10 })) {
if (first) {
do_check_eq(bp.originalColumn, undefined,
"Should always get the whole line breakpoint first");

Просмотреть файл

@ -1,27 +1,27 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gClient;
var gDebuggee;
function run_test()
{
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) {
gClient.connect().then(function (type, traits) {
attachTestTab(gClient, "test-1", function (reply, tabClient) {
test_close(transport);
});
});
do_test_pending();
}
function test_close(aTransport)
{
function test_close(transport) {
// Check that, if we fake a transport shutdown
// (like if a device is unplugged)
// the client is automatically closed,
@ -35,5 +35,5 @@ function test_close(aTransport)
});
};
gClient.addListener("closed", onClosed);
aTransport.close();
transport.close();
}

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test the DebuggerClient.request API.
var gClient, gActorId;
@ -24,8 +26,7 @@ TestActor.prototype.requestTypes = {
"error": TestActor.prototype.error
};
function run_test()
{
function run_test() {
DebuggerServer.addGlobalActor(TestActor);
DebuggerServer.init();
@ -42,13 +43,12 @@ function run_test()
run_next_test();
}
function init()
{
function init() {
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect()
.then(() => gClient.listTabs())
.then(aResponse => {
gActorId = aResponse.test;
.then(response => {
gActorId = response.test;
run_next_test();
});
}
@ -72,8 +72,7 @@ function checkStack(expectedName) {
ok(false, "Incomplete stack");
}
function test_client_request_callback()
{
function test_client_request_callback() {
// Test that DebuggerClient.request accepts a `onResponse` callback as 2nd argument
gClient.request({
to: gActorId,
@ -86,8 +85,7 @@ function test_client_request_callback()
});
}
function test_client_request_promise()
{
function test_client_request_promise() {
// Test that DebuggerClient.request returns a promise that resolves on response
let request = gClient.request({
to: gActorId,
@ -102,8 +100,7 @@ function test_client_request_promise()
});
}
function test_client_request_promise_error()
{
function test_client_request_promise_error() {
// Test that DebuggerClient.request returns a promise that reject when server
// returns an explicit error message
let request = gClient.request({
@ -122,8 +119,7 @@ function test_client_request_promise_error()
});
}
function test_client_request_event_emitter()
{
function test_client_request_event_emitter() {
// Test that DebuggerClient.request returns also an EventEmitter object
let request = gClient.request({
to: gActorId,
@ -156,7 +152,8 @@ function test_close_client_while_sending_requests() {
let expectReply = promise.defer();
gClient.expectReply("root", function (response) {
do_check_eq(response.error, "connectionClosed");
do_check_eq(response.message, "server side packet can't be received as the connection just closed.");
do_check_eq(response.message,
"server side packet can't be received as the connection just closed.");
expectReply.resolve();
});
@ -165,22 +162,23 @@ function test_close_client_while_sending_requests() {
ok(false, "First request unexpectedly succeed while closing the connection");
}, response => {
do_check_eq(response.error, "connectionClosed");
do_check_eq(response.message, "'hello' active request packet to '" + gActorId + "' can't be sent as the connection just closed.");
do_check_eq(response.message, "'hello' active request packet to '" +
gActorId + "' can't be sent as the connection just closed.");
})
.then(() => pendingRequest)
.then(() => {
ok(false, "Second request unexpectedly succeed while closing the connection");
}, response => {
do_check_eq(response.error, "connectionClosed");
do_check_eq(response.message, "'hello' pending request packet to '" + gActorId + "' can't be sent as the connection just closed.");
do_check_eq(response.message, "'hello' pending request packet to '" +
gActorId + "' can't be sent as the connection just closed.");
})
.then(() => expectReply.promise)
.then(run_next_test);
});
}
function test_client_request_after_close()
{
function test_client_request_after_close() {
// Test that DebuggerClient.request fails after we called client.close()
// (with promise API)
let request = gClient.request({
@ -193,22 +191,23 @@ function test_client_request_after_close()
}, response => {
ok(true, "Request failed after client.close");
do_check_eq(response.error, "connectionClosed");
ok(response.message.match(/'hello' request packet to '.*' can't be sent as the connection is closed./));
ok(response.message.match(
/'hello' request packet to '.*' can't be sent as the connection is closed./));
run_next_test();
});
}
function test_client_request_after_close_callback()
{
function test_client_request_after_close_callback() {
// Test that DebuggerClient.request fails after we called client.close()
// (with callback API)
let request = gClient.request({
gClient.request({
to: gActorId,
type: "hello"
}, response => {
ok(true, "Request failed after client.close");
do_check_eq(response.error, "connectionClosed");
ok(response.message.match(/'hello' request packet to '.*' can't be sent as the connection is closed./));
ok(response.message.match(
/'hello' request packet to '.*' can't be sent as the connection is closed./));
run_next_test();
});
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check conditional breakpoint when condition evaluates to true.
@ -9,48 +12,45 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-conditional-breakpoint");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-conditional-breakpoint", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-conditional-breakpoint",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_simple_breakpoint();
});
});
do_test_pending();
}
function test_simple_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
source.setBreakpoint({
line: 3,
condition: "a === 1"
}, function (aResponse, bpClient) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
}, function (response, bpClient) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.why.type, "breakpoint");
do_check_eq(aPacket.frame.where.line, 3);
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.frame.where.line, 3);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
finishClient(gClient);
});
});
});
// Continue until the breakpoint is hit.
gThreadClient.resume();
});
});
});
/* eslint-disable */
Components.utils.evalInSandbox("debugger;\n" + // 1
"var a = 1;\n" + // 2
"var b = 2;\n", // 3
@ -58,4 +58,5 @@ function test_simple_breakpoint()
"1.8",
"test.js",
1);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check conditional breakpoint when condition evaluates to false.
@ -9,46 +12,45 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-conditional-breakpoint");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-conditional-breakpoint", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-conditional-breakpoint",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_simple_breakpoint();
});
});
do_test_pending();
}
function test_simple_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
source.setBreakpoint({
line: 3,
condition: "a === 2"
}, function (aResponse, bpClient) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
}, function (response, bpClient) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.why.type, "debuggerStatement");
do_check_eq(aPacket.frame.where.line, 4);
do_check_eq(packet.why.type, "debuggerStatement");
do_check_eq(packet.frame.where.line, 4);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
finishClient(gClient);
});
});
});
// Continue until the breakpoint is hit.
gThreadClient.resume();
});
});
/* eslint-disable */
Components.utils.evalInSandbox("debugger;\n" + // 1
"var a = 1;\n" + // 2
"var b = 2;\n" + // 3
@ -57,4 +59,5 @@ function test_simple_breakpoint()
"1.8",
"test.js",
1);
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check conditional breakpoint when condition throws and make sure it pauses
@ -9,48 +12,45 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-conditional-breakpoint");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-conditional-breakpoint", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-conditional-breakpoint",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_simple_breakpoint();
});
});
do_test_pending();
}
function test_simple_breakpoint()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let source = gThreadClient.source(aPacket.frame.where.source);
function test_simple_breakpoint() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let source = gThreadClient.source(packet.frame.where.source);
source.setBreakpoint({
line: 3,
condition: "throw new Error()"
}, function (aResponse, bpClient) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
}, function (response, bpClient) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value.
do_check_eq(aPacket.why.type, "breakpointConditionThrown");
do_check_eq(aPacket.frame.where.line, 3);
do_check_eq(packet.why.type, "breakpointConditionThrown");
do_check_eq(packet.frame.where.line, 3);
// Remove the breakpoint.
bpClient.remove(function (aResponse) {
bpClient.remove(function (response) {
gThreadClient.resume(function () {
finishClient(gClient);
});
});
});
// Continue until the breakpoint is hit.
gThreadClient.resume();
});
});
});
/* eslint-disable */
Components.utils.evalInSandbox("debugger;\n" + // 1
"var a = 1;\n" + // 2
"var b = 2;\n", // 3
@ -58,4 +58,5 @@ function test_simple_breakpoint()
"1.8",
"test.js",
1);
/* eslint-enable */
}

Просмотреть файл

@ -1,29 +1,31 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gClient;
var gDebuggee;
const xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = testGlobal("test-1");
DebuggerServer.addTestGlobal(gDebuggee);
let transport = DebuggerServer.connectPipe();
gClient = new DebuggerClient(transport);
gClient.addListener("connected", function (aEvent, aType, aTraits) {
gClient.listTabs((aResponse) => {
do_check_true("tabs" in aResponse);
for (let tab of aResponse.tabs) {
gClient.addListener("connected", function (event, type, traits) {
gClient.listTabs((response) => {
do_check_true("tabs" in response);
for (let tab of response.tabs) {
if (tab.title == "test-1") {
test_attach_tab(tab.actor);
return false;
}
}
do_check_true(false); // We should have found our tab in the list.
// We should have found our tab in the list.
do_check_true(false);
return undefined;
});
});
@ -33,42 +35,39 @@ function run_test()
do_test_pending();
}
// Attach to |aTabActor|, and check the response.
function test_attach_tab(aTabActor)
{
gClient.request({ to: aTabActor, type: "attach" }, function (aResponse) {
do_check_false("error" in aResponse);
do_check_eq(aResponse.from, aTabActor);
do_check_eq(aResponse.type, "tabAttached");
do_check_true(typeof aResponse.threadActor === "string");
// Attach to |tabActor|, and check the response.
function test_attach_tab(tabActor) {
gClient.request({ to: tabActor, type: "attach" }, function (response) {
do_check_false("error" in response);
do_check_eq(response.from, tabActor);
do_check_eq(response.type, "tabAttached");
do_check_true(typeof response.threadActor === "string");
test_attach_thread(aResponse.threadActor);
test_attach_thread(response.threadActor);
});
}
// Attach to |aThreadActor|, check the response, and resume it.
function test_attach_thread(aThreadActor)
{
gClient.request({ to: aThreadActor, type: "attach" }, function (aResponse) {
do_check_false("error" in aResponse);
do_check_eq(aResponse.from, aThreadActor);
do_check_eq(aResponse.type, "paused");
do_check_true("why" in aResponse);
do_check_eq(aResponse.why.type, "attached");
// Attach to |threadActor|, check the response, and resume it.
function test_attach_thread(threadActor) {
gClient.request({ to: threadActor, type: "attach" }, function (response) {
do_check_false("error" in response);
do_check_eq(response.from, threadActor);
do_check_eq(response.type, "paused");
do_check_true("why" in response);
do_check_eq(response.why.type, "attached");
test_resume_thread(aThreadActor);
test_resume_thread(threadActor);
});
}
// Resume |aThreadActor|, and see that it stops at the 'debugger'
// Resume |threadActor|, and see that it stops at the 'debugger'
// statement.
function test_resume_thread(aThreadActor)
{
function test_resume_thread(threadActor) {
// Allow the client to resume execution.
gClient.request({ to: aThreadActor, type: "resume" }, function (aResponse) {
do_check_false("error" in aResponse);
do_check_eq(aResponse.from, aThreadActor);
do_check_eq(aResponse.type, "resumed");
gClient.request({ to: threadActor, type: "resume" }, function (response) {
do_check_false("error" in response);
do_check_eq(response.from, threadActor);
do_check_eq(response.type, "resumed");
do_check_eq(xpcInspector.eventLoopNestLevel, 0);
@ -78,14 +77,14 @@ function test_resume_thread(aThreadActor)
do_check_true(gDebuggee.b);
});
gClient.addListener("paused", function (aName, aPacket) {
do_check_eq(aName, "paused");
do_check_false("error" in aPacket);
do_check_eq(aPacket.from, aThreadActor);
do_check_eq(aPacket.type, "paused");
do_check_true("actor" in aPacket);
do_check_true("why" in aPacket);
do_check_eq(aPacket.why.type, "debuggerStatement");
gClient.addListener("paused", function (name, packet) {
do_check_eq(name, "paused");
do_check_false("error" in packet);
do_check_eq(packet.from, threadActor);
do_check_eq(packet.type, "paused");
do_check_true("actor" in packet);
do_check_true("why" in packet);
do_check_eq(packet.why.type, "debuggerStatement");
// Reach around the protocol to check that the debuggee is in the state
// we expect.
@ -95,19 +94,18 @@ function test_resume_thread(aThreadActor)
do_check_eq(xpcInspector.eventLoopNestLevel, 1);
// Let the debuggee continue execution.
gClient.request({ to: aThreadActor, type: "resume" }, cleanup);
gClient.request({ to: threadActor, type: "resume" }, cleanup);
});
}
function cleanup()
{
gClient.addListener("closed", function (aEvent, aResult) {
function cleanup() {
gClient.addListener("closed", function (event, result) {
do_test_finished();
});
try {
let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
do_check_eq(xpcInspector.eventLoopNestLevel, 0);
let inspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
do_check_eq(inspector.eventLoopNestLevel, 0);
} catch (e) {
dump(e);
}

Просмотреть файл

@ -1,44 +1,43 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gClient;
var gTabClient;
var gDebuggee;
function run_test()
{
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);
gClient.connect().then(function ([type, traits]) {
attachTestTab(gClient, "test-1", function (reply, tabClient) {
gTabClient = tabClient;
test_threadAttach(reply.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_threadAttach(threadActorID) {
do_print("Trying to attach to thread " + threadActorID);
gTabClient.attachThread({}, function (response, threadClient) {
do_check_eq(threadClient.state, "paused");
do_check_eq(threadClient.actor, threadActorID);
threadClient.resume(function () {
do_check_eq(threadClient.state, "attached");
test_debugger_statement(threadClient);
});
});
}
function test_debugger_statement(aThreadClient)
{
aThreadClient.addListener("paused", function (aEvent, aPacket) {
do_check_eq(aThreadClient.state, "paused");
function test_debugger_statement(threadClient) {
threadClient.addListener("paused", function (event, packet) {
do_check_eq(threadClient.state, "paused");
// Reach around the protocol to check that the debuggee is in the state
// we expect.
do_check_true(gDebuggee.a);
@ -47,7 +46,7 @@ function test_debugger_statement(aThreadClient)
let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
do_check_eq(xpcInspector.eventLoopNestLevel, 1);
aThreadClient.resume(cleanup);
threadClient.resume(cleanup);
});
Cu.evalInSandbox("var a = true; var b = false; debugger; var b = true;", gDebuggee);
@ -56,9 +55,8 @@ function test_debugger_statement(aThreadClient)
do_check_true(gDebuggee.b);
}
function cleanup()
{
gClient.addListener("closed", function (aEvent) {
function cleanup() {
gClient.addListener("closed", function (event) {
do_test_finished();
});

Просмотреть файл

@ -1,8 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function run_test()
{
"use strict";
function run_test() {
// Should get an exception if we try to interact with DebuggerServer
// before we initialize it...
check_except(function () {
@ -28,28 +29,28 @@ function run_test()
// Make sure we got the test's root actor all set up.
let client1 = DebuggerServer.connectPipe();
client1.hooks = {
onPacket: function (aPacket1) {
do_check_eq(aPacket1.from, "root");
do_check_eq(aPacket1.applicationType, "xpcshell-tests");
onPacket: function (packet1) {
do_check_eq(packet1.from, "root");
do_check_eq(packet1.applicationType, "xpcshell-tests");
// Spin up a second connection, make sure it has its own root
// actor.
let client2 = DebuggerServer.connectPipe();
client2.hooks = {
onPacket: function (aPacket2) {
do_check_eq(aPacket2.from, "root");
do_check_neq(aPacket1.testConnectionPrefix,
aPacket2.testConnectionPrefix);
onPacket: function (packet2) {
do_check_eq(packet2.from, "root");
do_check_neq(packet1.testConnectionPrefix,
packet2.testConnectionPrefix);
client2.close();
},
onClosed: function (aResult) {
onClosed: function (result) {
client1.close();
},
};
client2.ready();
},
onClosed: function (aResult) {
onClosed: function (result) {
do_test_finished();
},
};

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check basic eval resume/re-pause
@ -9,50 +12,48 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_simple_eval();
});
});
do_test_pending();
}
function test_simple_eval()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let arg1Actor = aPacket.frame.arguments[0].actor;
gThreadClient.eval(null, "({ obj: true })", function (aResponse) {
do_check_eq(aResponse.type, "resumed");
function test_simple_eval() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let arg1Actor = packet.frame.arguments[0].actor;
gThreadClient.eval(null, "({ obj: true })", function (response) {
do_check_eq(response.type, "resumed");
// Expect a pause notification immediately.
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value...
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.type, "clientEvaluated");
do_check_eq(aPacket.why.frameFinished.return.type, "object");
do_check_eq(aPacket.why.frameFinished.return.class, "Object");
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "clientEvaluated");
do_check_eq(packet.why.frameFinished.return.type, "object");
do_check_eq(packet.why.frameFinished.return.class, "Object");
// Make sure the previous pause lifetime was correctly dropped.
gClient.request({ to: arg1Actor, type: "bogusRequest" }, function (aResponse) {
do_check_eq(aResponse.error, "noSuchActor");
gClient.request({ to: arg1Actor, type: "bogusRequest" }, function (response) {
do_check_eq(response.error, "noSuchActor");
gThreadClient.resume(function () {
finishClient(gClient);
});
});
});
});
});
});
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe(arg1) { debugger; }
stopMe({obj: true});
} + ")()");
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check eval resume/re-pause with a throw.
@ -9,31 +12,30 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_throw_eval();
});
});
do_test_pending();
}
function test_throw_eval()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.eval(null, "throw 'failure'", function (aResponse) {
do_check_eq(aResponse.type, "resumed");
function test_throw_eval() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.eval(null, "throw 'failure'", function (response) {
do_check_eq(response.type, "resumed");
// Expect a pause notification immediately.
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value...
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.type, "clientEvaluated");
do_check_eq(aPacket.why.frameFinished.throw, "failure");
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "clientEvaluated");
do_check_eq(packet.why.frameFinished.throw, "failure");
gThreadClient.resume(function () {
finishClient(gClient);
});
@ -41,8 +43,10 @@ function test_throw_eval()
});
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe(arg1) { debugger; }
stopMe({obj: true});
} + ")()");
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check syntax errors in an eval.
@ -9,32 +12,31 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_syntax_error_eval();
});
});
do_test_pending();
}
function test_syntax_error_eval()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.eval(null, "%$@!@#", function (aResponse) {
do_check_eq(aResponse.type, "resumed");
function test_syntax_error_eval() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.eval(null, "%$@!@#", function (response) {
do_check_eq(response.type, "resumed");
// Expect a pause notification immediately.
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Check the return value...
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.type, "clientEvaluated");
do_check_eq(aPacket.why.frameFinished.throw.type, "object");
do_check_eq(aPacket.why.frameFinished.throw.class, "Error");
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "clientEvaluated");
do_check_eq(packet.why.frameFinished.throw.type, "object");
do_check_eq(packet.why.frameFinished.throw.class, "Error");
gThreadClient.resume(function () {
finishClient(gClient);
@ -43,8 +45,10 @@ function test_syntax_error_eval()
});
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe(arg1) { debugger; }
stopMe({obj: true});
} + ")()");
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check evals against different frames.
@ -9,43 +12,41 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
test_syntax_error_eval();
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_different_frames_eval();
});
});
do_test_pending();
}
function test_syntax_error_eval()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.getFrames(0, 2, function (aResponse) {
let frame0 = aResponse.frames[0];
let frame1 = aResponse.frames[1];
function test_different_frames_eval() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.getFrames(0, 2, function (response) {
let frame0 = response.frames[0];
let frame1 = response.frames[1];
// Eval against the top frame...
gThreadClient.eval(frame0.actor, "arg", function (aResponse) {
do_check_eq(aResponse.type, "resumed");
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.eval(frame0.actor, "arg", function (response) {
do_check_eq(response.type, "resumed");
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// 'arg' should have been evaluated in frame0
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.type, "clientEvaluated");
do_check_eq(aPacket.why.frameFinished.return, "arg0");
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "clientEvaluated");
do_check_eq(packet.why.frameFinished.return, "arg0");
// Now eval against the second frame.
gThreadClient.eval(frame1.actor, "arg", function (aResponse) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.eval(frame1.actor, "arg", function (response) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// 'arg' should have been evaluated in frame1
do_check_eq(aPacket.type, "paused");
do_check_eq(aPacket.why.frameFinished.return, "arg1");
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.frameFinished.return, "arg1");
gThreadClient.resume(function () {
finishClient(gClient);

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check pauses within evals.
@ -9,34 +12,33 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
test_syntax_error_eval();
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pauses_eval();
});
});
do_test_pending();
}
function test_syntax_error_eval()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.eval(null, "debugger", function (aResponse) {
function test_pauses_eval() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.eval(null, "debugger", function (response) {
// Expect a resume then a debuggerStatement pause.
do_check_eq(aResponse.type, "resumed");
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_eq(aPacket.why.type, "debuggerStatement");
do_check_eq(response.type, "resumed");
gThreadClient.addOneTimeListener("paused", function (event, packet) {
do_check_eq(packet.why.type, "debuggerStatement");
// Resume from the debugger statement should immediately re-pause
// with a clientEvaluated reason.
gThreadClient.resume(function (aPacket) {
do_check_eq(aPacket.type, "resumed");
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_eq(aPacket.why.type, "clientEvaluated");
gThreadClient.resume(function (packet) {
do_check_eq(packet.type, "resumed");
gThreadClient.addOneTimeListener("paused", function (event, packet) {
do_check_eq(packet.why.type, "clientEvaluated");
gThreadClient.resume(function () {
finishClient(gClient);
});

Просмотреть файл

@ -7,8 +7,7 @@
"use strict";
function run_test()
{
function run_test() {
let {EventLoopLagFront} = require("devtools/shared/fronts/eventlooplag");
DebuggerServer.init();
@ -18,7 +17,6 @@ function run_test()
let threshold = 20;
let interval = 10;
let front;
let client = new DebuggerClient(DebuggerServer.connectPipe());

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* Exercise prefix-based forwarding of packets to other transports. */
const { RootActor } = require("devtools/server/actors/root");
@ -9,8 +11,7 @@ var gMainConnection, gMainTransport;
var gSubconnection1, gSubconnection2;
var gClient;
function run_test()
{
function run_test() {
DebuggerServer.init();
add_test(createMainConnection);
@ -31,28 +32,26 @@ function run_test()
* (that is, packets sent on |transport| go to the new connection, and
* |transport|'s hooks receive replies).
*
* |aPrefix| is optional; if present, it's the prefix (minus the '/') for
* |prefix| is optional; if present, it's the prefix (minus the '/') for
* actors in the new connection.
*/
function newConnection(aPrefix)
{
var conn;
DebuggerServer.createRootActor = function (aConn) {
conn = aConn;
return new RootActor(aConn, {});
function newConnection(prefix) {
let conn;
DebuggerServer.createRootActor = function (connection) {
conn = connection;
return new RootActor(connection, {});
};
var transport = DebuggerServer.connectPipe(aPrefix);
let transport = DebuggerServer.connectPipe(prefix);
return { conn: conn, transport: transport };
}
/* Create the main connection for these tests. */
function createMainConnection()
{
function createMainConnection() {
({ conn: gMainConnection, transport: gMainTransport } = newConnection());
gClient = new DebuggerClient(gMainTransport);
gClient.connect().then(([aType, aTraits]) => run_next_test());
gClient.connect().then(([type, traits]) => run_next_test());
}
/*
@ -63,13 +62,13 @@ function createMainConnection()
* - prefix2/root
* - prefix2/actor
*
* Expect proper echos from those named in |aReachables|, and 'noSuchActor'
* Expect proper echos from those named in |reachables|, and 'noSuchActor'
* errors from the others. When we've gotten all our replies (errors or
* otherwise), call |aCompleted|.
* otherwise), call |completed|.
*
* To avoid deep stacks, we call aCompleted from the next tick.
* To avoid deep stacks, we call completed from the next tick.
*/
function tryActors(aReachables, aCompleted) {
function tryActors(reachables, completed) {
let count = 0;
let outerActor;
@ -84,15 +83,21 @@ function tryActors(aReachables, aCompleted) {
count++;
gClient.request({ to: actor, type: "echo", value: "tango"}, // phone home
(aResponse) => {
if (aReachables.has(actor))
do_check_matches({ from: actor, to: actor, type: "echo", value: "tango" }, aResponse);
else
do_check_matches({ from: actor, error: "noSuchActor", message: "No such actor for ID: " + actor }, aResponse);
// phone home
gClient.request(
{ to: actor, type: "echo", value: "tango"},
(response) => {
if (reachables.has(actor)) {
do_check_matches({ from: actor, to: actor,
type: "echo", value: "tango" }, response);
} else {
do_check_matches({ from: actor, error: "noSuchActor",
message: "No such actor for ID: " + actor }, response);
}
if (--count == 0)
do_execute_soon(aCompleted, "tryActors callback " + aCompleted.name);
if (--count == 0) {
do_execute_soon(completed, "tryActors callback " + completed.name);
}
});
}
}
@ -102,56 +107,50 @@ function tryActors(aReachables, aCompleted) {
* but sending messages to prefixed actor names, or anyone else, should get
* an error.
*/
function TestNoForwardingYet()
{
function TestNoForwardingYet() {
tryActors(new Set(["root"]), run_next_test);
}
/*
* Create a new pipe connection which forwards its reply packets to
* gMainConnection's client, and to which gMainConnection forwards packets
* directed to actors whose names begin with |aPrefix + '/'|, and.
* directed to actors whose names begin with |prefix + '/'|, and.
*
* Return an object { conn, transport }, as for newConnection.
*/
function newSubconnection(aPrefix)
{
let { conn, transport } = newConnection(aPrefix);
function newSubconnection(prefix) {
let { conn, transport } = newConnection(prefix);
transport.hooks = {
onPacket: (aPacket) => gMainConnection.send(aPacket),
onPacket: (packet) => gMainConnection.send(packet),
onClosed: () => {}
};
gMainConnection.setForwarding(aPrefix, transport);
gMainConnection.setForwarding(prefix, transport);
return { conn: conn, transport: transport };
}
/* Create a second root actor, to which we can forward things. */
function createSubconnection1()
{
function createSubconnection1() {
let { conn, transport } = newSubconnection("prefix1");
gSubconnection1 = conn;
transport.ready();
gClient.expectReply("prefix1/root", (aReply) => run_next_test());
gClient.expectReply("prefix1/root", (reply) => run_next_test());
}
// Establish forwarding, but don't put any actors in that server.
function TestForwardPrefix1OnlyRoot()
{
function TestForwardPrefix1OnlyRoot() {
tryActors(new Set(["root", "prefix1/root"]), run_next_test);
}
/* Create a third root actor, to which we can forward things. */
function createSubconnection2()
{
function createSubconnection2() {
let { conn, transport } = newSubconnection("prefix2");
gSubconnection2 = conn;
transport.ready();
gClient.expectReply("prefix2/root", (aReply) => run_next_test());
gClient.expectReply("prefix2/root", (reply) => run_next_test());
}
function TestForwardPrefix12OnlyRoot()
{
function TestForwardPrefix12OnlyRoot() {
tryActors(new Set(["root", "prefix1/root", "prefix2/root"]), run_next_test);
}
@ -161,36 +160,39 @@ function TestForwardPrefix12OnlyRoot()
// the reply-sending code attaches the replying actor's name to the packet,
// so simply matching the 'from' field in the reply ensures that we heard
// from the right actor.
function EchoActor(aConnection)
{
this.conn = aConnection;
function EchoActor(connection) {
this.conn = connection;
}
EchoActor.prototype.actorPrefix = "EchoActor";
EchoActor.prototype.onEcho = function (aRequest) {
EchoActor.prototype.onEcho = function (request) {
/*
* Request packets are frozen. Copy aRequest, so that
* Request packets are frozen. Copy request, so that
* DebuggerServerConnection.onPacket can attach a 'from' property.
*/
return JSON.parse(JSON.stringify(aRequest));
return JSON.parse(JSON.stringify(request));
};
EchoActor.prototype.requestTypes = {
"echo": EchoActor.prototype.onEcho
};
function TestForwardPrefix12WithActor1()
{
function TestForwardPrefix12WithActor1() {
let actor = new EchoActor(gSubconnection1);
actor.actorID = "prefix1/actor";
gSubconnection1.addActor(actor);
tryActors(new Set(["root", "prefix1/root", "prefix1/actor", "prefix2/root"]), run_next_test);
tryActors(
new Set(["root", "prefix1/root", "prefix1/actor", "prefix2/root"]),
run_next_test
);
}
function TestForwardPrefix12WithActor12()
{
function TestForwardPrefix12WithActor12() {
let actor = new EchoActor(gSubconnection2);
actor.actorID = "prefix2/actor";
gSubconnection2.addActor(actor);
tryActors(new Set(["root", "prefix1/root", "prefix1/actor", "prefix2/root", "prefix2/actor"]), run_next_test);
tryActors(
new Set(["root", "prefix1/root", "prefix1/actor", "prefix2/root", "prefix2/actor"]),
run_next_test
);
}

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Verify that we get a frame actor along with a debugger statement.
*/
@ -9,26 +11,25 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_true(!!aPacket.frame);
do_check_true(!!aPacket.frame.actor);
do_check_eq(aPacket.frame.callee.name, "stopMe");
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
do_check_true(!!packet.frame);
do_check_true(!!packet.frame.actor);
do_check_eq(packet.frame.callee.name, "stopMe");
gThreadClient.resume(function () {
finishClient(gClient);
});

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Verify that two pauses in a row will keep the same frame actor.
@ -9,25 +12,24 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket2) {
do_check_eq(aPacket1.frame.actor, aPacket2.frame.actor);
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet1) {
gThreadClient.addOneTimeListener("paused", function (event, packet2) {
do_check_eq(packet1.frame.actor, packet2.frame.actor);
gThreadClient.resume(function () {
finishClient(gClient);
});

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Verify that a frame actor is properly expired when the frame goes away.
@ -9,27 +12,26 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket2) {
let poppedFrames = aPacket2.poppedFrames;
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet1) {
gThreadClient.addOneTimeListener("paused", function (event, packet2) {
let poppedFrames = packet2.poppedFrames;
do_check_eq(typeof (poppedFrames), typeof ([]));
do_check_true(poppedFrames.indexOf(aPacket1.frame.actor) >= 0);
do_check_true(poppedFrames.indexOf(packet1.frame.actor) >= 0);
gThreadClient.resume(function () {
finishClient(gClient);
});

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Verify the "frames" request on the thread.
*/
@ -9,14 +11,14 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
@ -46,17 +48,18 @@ var gSliceTests = [
function test_frame_slice() {
if (gSliceTests.length == 0) {
gThreadClient.resume(function () { finishClient(gClient); });
gThreadClient.resume(() => finishClient(gClient));
return;
}
let test = gSliceTests.shift();
gThreadClient.getFrames(test.start, test.count, function (aResponse) {
var testFrames = gFrames.slice(test.start, test.count ? test.start + test.count : undefined);
do_check_eq(testFrames.length, aResponse.frames.length);
for (var i = 0; i < testFrames.length; i++) {
gThreadClient.getFrames(test.start, test.count, function (response) {
let testFrames = gFrames.slice(test.start,
test.count ? test.start + test.count : undefined);
do_check_eq(testFrames.length, response.frames.length);
for (let i = 0; i < testFrames.length; i++) {
let expected = testFrames[i];
let actual = aResponse.frames[i];
let actual = response.frames[i];
if (test.resetActors) {
expected.actor = actual.actor;
@ -70,9 +73,8 @@ function test_frame_slice() {
});
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) {
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
test_frame_slice();
});

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Verify that frame actors retrieved with the frames request
@ -10,64 +13,37 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_frame_slice() {
if (gSliceTests.length == 0) {
gThreadClient.resume(function () { finishClient(gClient); });
return;
}
let test = gSliceTests.shift();
gThreadClient.getFrames(test.start, test.count, function (aResponse) {
var testFrames = gFrames.slice(test.start, test.count ? test.start + test.count : undefined);
do_check_eq(testFrames.length, aResponse.frames.length);
for (var i = 0; i < testFrames.length; i++) {
let expected = testFrames[i];
let actual = aResponse.frames[i];
if (test.resetActors) {
expected.actor = actual.actor;
}
for (var key in expected) {
do_check_eq(expected[key], actual[key]);
}
}
test_frame_slice();
});
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) {
gThreadClient.getFrames(0, null, function (aFrameResponse) {
do_check_eq(aFrameResponse.frames.length, 5);
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.getFrames(0, null, function (frameResponse) {
do_check_eq(frameResponse.frames.length, 5);
// Now wait for the next pause, after which the three
// youngest actors should be popped..
let expectPopped = aFrameResponse.frames.slice(0, 3).map(frame => frame.actor);
let expectPopped = frameResponse.frames.slice(0, 3).map(frame => frame.actor);
expectPopped.sort();
gThreadClient.addOneTimeListener("paused", function (aEvent, aPausePacket) {
let popped = aPausePacket.poppedFrames.sort();
gThreadClient.addOneTimeListener("paused", function (event, pausePacket) {
let popped = pausePacket.poppedFrames.sort();
do_check_eq(popped.length, 3);
for (let i = 0; i < 3; i++) {
do_check_eq(expectPopped[i], popped[i]);
}
gThreadClient.resume(function () { finishClient(gClient); });
gThreadClient.resume(() => finishClient(gClient));
});
gThreadClient.resume();
});

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Verify that wasm frame(s) can be requested from the client.
@ -9,20 +12,22 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
if (typeof WebAssembly == "undefined") {
return; // wasm is not enabled for this platform
// wasm is not enabled for this platform
return;
}
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
gThreadClient.reconfigure({ observeAsmJS: true }, function (aResponse) {
do_check_eq(!!aResponse.error, false);
attachTestTabAndResume(
gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
gThreadClient.reconfigure({ observeAsmJS: true }, function (response) {
do_check_eq(!!response.error, false);
test_pause_frame();
});
});
@ -30,13 +35,12 @@ function run_test()
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) {
gThreadClient.getFrames(0, null, function (aFrameResponse) {
do_check_eq(aFrameResponse.frames.length, 4);
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.getFrames(0, null, function (frameResponse) {
do_check_eq(frameResponse.frames.length, 4);
let wasmFrame = aFrameResponse.frames[1];
let wasmFrame = frameResponse.frames[1];
do_check_eq(wasmFrame.type, "wasmcall");
do_check_eq(wasmFrame.this, undefined);
@ -49,15 +53,16 @@ function test_pause_frame()
});
});
/* eslint-disable comma-spacing, max-len */
gDebuggee.eval("(" + function () {
// WebAssembly bytecode was generated by running:
// js -e 'print(wasmTextToBinary("(module(import \"a\" \"b\")(func(export \"c\")call 0))"))'
var m = new WebAssembly.Module(new Uint8Array([
let m = new WebAssembly.Module(new Uint8Array([
0,97,115,109,1,0,0,0,1,132,128,128,128,0,1,96,0,0,2,135,128,128,128,0,1,1,97,1,
98,0,0,3,130,128,128,128,0,1,0,6,129,128,128,128,0,0,7,133,128,128,128,0,1,1,99,
0,1,10,138,128,128,128,0,1,132,128,128,128,0,0,16,0,11
]));
var i = new WebAssembly.Instance(m, {a: {b: () => {
let i = new WebAssembly.Instance(m, {a: {b: () => {
debugger;
}}});
i.exports.c();

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check a frame actor's arguments property.
*/
@ -9,24 +11,23 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let args = aPacket.frame["arguments"];
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let args = packet.frame.arguments;
do_check_eq(args.length, 6);
do_check_eq(args[0], 42);
do_check_eq(args[1], true);
@ -43,7 +44,7 @@ function test_pause_frame()
});
gDebuggee.eval("(" + function () {
function stopMe(aNumber, aBool, aString, aNull, aUndefined, aObject) {
function stopMe(number, bool, string, null_, undef, object) {
debugger;
}
stopMe(42, true, "nasu", null, undefined, { foo: "bar" });

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check a frame actor's bindings property.
*/
@ -9,36 +11,35 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let bindings = aPacket.frame.environment.bindings;
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let bindings = packet.frame.environment.bindings;
let args = bindings.arguments;
let vars = bindings.variables;
do_check_eq(args.length, 6);
do_check_eq(args[0].aNumber.value, 42);
do_check_eq(args[1].aBool.value, true);
do_check_eq(args[2].aString.value, "nasu");
do_check_eq(args[3].aNull.value.type, "null");
do_check_eq(args[4].aUndefined.value.type, "undefined");
do_check_eq(args[5].aObject.value.type, "object");
do_check_eq(args[5].aObject.value.class, "Object");
do_check_true(!!args[5].aObject.value.actor);
do_check_eq(args[0].number.value, 42);
do_check_eq(args[1].bool.value, true);
do_check_eq(args[2].string.value, "nasu");
do_check_eq(args[3].null_.value.type, "null");
do_check_eq(args[4].undef.value.type, "undefined");
do_check_eq(args[5].object.value.type, "object");
do_check_eq(args[5].object.value.class, "Object");
do_check_true(!!args[5].object.value.actor);
do_check_eq(vars.a.value, 1);
do_check_eq(vars.b.value, true);
@ -47,17 +48,17 @@ function test_pause_frame()
do_check_true(!!vars.c.value.actor);
let objClient = gThreadClient.pauseGrip(vars.c.value);
objClient.getPrototypeAndProperties(function (aResponse) {
do_check_eq(aResponse.ownProperties.a.configurable, true);
do_check_eq(aResponse.ownProperties.a.enumerable, true);
do_check_eq(aResponse.ownProperties.a.writable, true);
do_check_eq(aResponse.ownProperties.a.value, "a");
objClient.getPrototypeAndProperties(function (response) {
do_check_eq(response.ownProperties.a.configurable, true);
do_check_eq(response.ownProperties.a.enumerable, true);
do_check_eq(response.ownProperties.a.writable, true);
do_check_eq(response.ownProperties.a.value, "a");
do_check_eq(aResponse.ownProperties.b.configurable, true);
do_check_eq(aResponse.ownProperties.b.enumerable, true);
do_check_eq(aResponse.ownProperties.b.writable, true);
do_check_eq(aResponse.ownProperties.b.value.type, "undefined");
do_check_false("class" in aResponse.ownProperties.b.value);
do_check_eq(response.ownProperties.b.configurable, true);
do_check_eq(response.ownProperties.b.enumerable, true);
do_check_eq(response.ownProperties.b.writable, true);
do_check_eq(response.ownProperties.b.value.type, "undefined");
do_check_false("class" in response.ownProperties.b.value);
gThreadClient.resume(function () {
finishClient(gClient);
@ -65,8 +66,9 @@ function test_pause_frame()
});
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe(aNumber, aBool, aString, aNull, aUndefined, aObject) {
function stopMe(number, bool, string, null_, undef, object) {
var a = 1;
var b = true;
var c = { a: "a", b: undefined };
@ -74,4 +76,5 @@ function test_pause_frame()
}
stopMe(42, true, "nasu", null, undefined, { foo: "bar" });
} + ")()");
/* eslint-enable */
}

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check a frame actor's parent bindings.
*/
@ -9,24 +11,23 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let parentEnv = aPacket.frame.environment.parent;
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let parentEnv = packet.frame.environment.parent;
let bindings = parentEnv.bindings;
let args = bindings.arguments;
let vars = bindings.variables;
@ -40,10 +41,10 @@ function test_pause_frame()
parentEnv = parentEnv.parent.parent;
do_check_neq(parentEnv, undefined);
let objClient = gThreadClient.pauseGrip(parentEnv.object);
objClient.getPrototypeAndProperties(function (aResponse) {
do_check_eq(aResponse.ownProperties.Object.value.type, "object");
do_check_eq(aResponse.ownProperties.Object.value.class, "Function");
do_check_true(!!aResponse.ownProperties.Object.value.actor);
objClient.getPrototypeAndProperties(function (response) {
do_check_eq(response.ownProperties.Object.value.type, "object");
do_check_eq(response.ownProperties.Object.value.class, "Function");
do_check_true(!!response.ownProperties.Object.value.actor);
gThreadClient.resume(function () {
finishClient(gClient);
@ -51,8 +52,9 @@ function test_pause_frame()
});
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe(aNumber, aBool, aString, aNull, aUndefined, aObject) {
function stopMe(number, bool, string, null_, undef, object) {
var a = 1;
var b = true;
var c = { a: "a" };

Просмотреть файл

@ -1,6 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* strict mode code may not contain 'with' statements */
/* eslint-disable strict */
/**
* Check a |with| frame actor's bindings.
*/
@ -9,24 +12,23 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let env = aPacket.frame.environment;
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let env = packet.frame.environment;
do_check_neq(env, undefined);
let parentEnv = env.parent;
@ -36,18 +38,18 @@ function test_pause_frame()
let args = bindings.arguments;
let vars = bindings.variables;
do_check_eq(args.length, 1);
do_check_eq(args[0].aNumber.value, 10);
do_check_eq(args[0].number.value, 10);
do_check_eq(vars.r.value, 10);
do_check_eq(vars.a.value, Math.PI * 100);
do_check_eq(vars.arguments.value.class, "Arguments");
do_check_true(!!vars.arguments.value.actor);
let objClient = gThreadClient.pauseGrip(env.object);
objClient.getPrototypeAndProperties(function (aResponse) {
do_check_eq(aResponse.ownProperties.PI.value, Math.PI);
do_check_eq(aResponse.ownProperties.cos.value.type, "object");
do_check_eq(aResponse.ownProperties.cos.value.class, "Function");
do_check_true(!!aResponse.ownProperties.cos.value.actor);
objClient.getPrototypeAndProperties(function (response) {
do_check_eq(response.ownProperties.PI.value, Math.PI);
do_check_eq(response.ownProperties.cos.value.type, "object");
do_check_eq(response.ownProperties.cos.value.class, "Function");
do_check_true(!!response.ownProperties.cos.value.actor);
gThreadClient.resume(function () {
finishClient(gClient);
@ -55,10 +57,11 @@ function test_pause_frame()
});
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe(aNumber) {
function stopMe(number) {
var a;
var r = aNumber;
var r = number;
with (Math) {
a = PI * r * r;
debugger;
@ -66,4 +69,5 @@ function test_pause_frame()
}
stopMe(10);
} + ")()");
/* eslint-enable */
}

Просмотреть файл

@ -1,49 +1,52 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
/* strict mode code may not contain 'with' statements */
/* eslint-disable strict */
/**
* Check the environment bindongs of a |with| within a |with|.
* Check the environment bindings of a |with| within a |with|.
*/
var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let env = aPacket.frame.environment;
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let env = packet.frame.environment;
do_check_neq(env, undefined);
let objClient = gThreadClient.pauseGrip(env.object);
objClient.getPrototypeAndProperties(function (aResponse) {
do_check_eq(aResponse.ownProperties.one.value, 1);
do_check_eq(aResponse.ownProperties.two.value, 2);
do_check_eq(aResponse.ownProperties.foo, undefined);
objClient.getPrototypeAndProperties(function (response) {
do_check_eq(response.ownProperties.one.value, 1);
do_check_eq(response.ownProperties.two.value, 2);
do_check_eq(response.ownProperties.foo, undefined);
let parentEnv = env.parent;
do_check_neq(parentEnv, undefined);
let parentClient = gThreadClient.pauseGrip(parentEnv.object);
parentClient.getPrototypeAndProperties(function (aResponse) {
do_check_eq(aResponse.ownProperties.PI.value, Math.PI);
do_check_eq(aResponse.ownProperties.cos.value.type, "object");
do_check_eq(aResponse.ownProperties.cos.value.class, "Function");
do_check_true(!!aResponse.ownProperties.cos.value.actor);
parentClient.getPrototypeAndProperties(function (response) {
do_check_eq(response.ownProperties.PI.value, Math.PI);
do_check_eq(response.ownProperties.cos.value.type, "object");
do_check_eq(response.ownProperties.cos.value.class, "Function");
do_check_true(!!response.ownProperties.cos.value.actor);
parentEnv = parentEnv.parent;
do_check_neq(parentEnv, undefined);
@ -52,7 +55,7 @@ function test_pause_frame()
let args = bindings.arguments;
let vars = bindings.variables;
do_check_eq(args.length, 1);
do_check_eq(args[0].aNumber.value, 10);
do_check_eq(args[0].number.value, 10);
do_check_eq(vars.r.value, 10);
do_check_eq(vars.a.value, Math.PI * 100);
do_check_eq(vars.arguments.value.class, "Arguments");
@ -64,13 +67,13 @@ function test_pause_frame()
});
});
});
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function stopMe(aNumber) {
function stopMe(number) {
var a, obj = { one: 1, two: 2 };
var r = aNumber;
var r = number;
with (Math) {
a = PI * r * r;
with (obj) {
@ -81,4 +84,5 @@ function test_pause_frame()
}
stopMe(10);
} + ")()");
/* eslint-enable */
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
/**
* Check the environment bindings of a |with| in global scope.
@ -9,44 +12,43 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let env = aPacket.frame.environment;
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let env = packet.frame.environment;
do_check_neq(env, undefined);
let objClient = gThreadClient.pauseGrip(env.object);
objClient.getPrototypeAndProperties(function (aResponse) {
do_check_eq(aResponse.ownProperties.PI.value, Math.PI);
do_check_eq(aResponse.ownProperties.cos.value.type, "object");
do_check_eq(aResponse.ownProperties.cos.value.class, "Function");
do_check_true(!!aResponse.ownProperties.cos.value.actor);
objClient.getPrototypeAndProperties(function (response) {
do_check_eq(response.ownProperties.PI.value, Math.PI);
do_check_eq(response.ownProperties.cos.value.type, "object");
do_check_eq(response.ownProperties.cos.value.class, "Function");
do_check_true(!!response.ownProperties.cos.value.actor);
// Skip the global lexical scope.
let parentEnv = env.parent.parent;
do_check_neq(parentEnv, undefined);
let parentClient = gThreadClient.pauseGrip(parentEnv.object);
parentClient.getPrototypeAndProperties(function (aResponse) {
do_check_eq(aResponse.ownProperties.a.value, Math.PI * 100);
do_check_eq(aResponse.ownProperties.r.value, 10);
do_check_eq(aResponse.ownProperties.Object.value.type, "object");
do_check_eq(aResponse.ownProperties.Object.value.class, "Function");
do_check_true(!!aResponse.ownProperties.Object.value.actor);
parentClient.getPrototypeAndProperties(function (response) {
do_check_eq(response.ownProperties.a.value, Math.PI * 100);
do_check_eq(response.ownProperties.r.value, 10);
do_check_eq(response.ownProperties.Object.value.type, "object");
do_check_eq(response.ownProperties.Object.value.class, "Function");
do_check_true(!!response.ownProperties.Object.value.actor);
gThreadClient.resume(function () {
finishClient(gClient);

Просмотреть файл

@ -1,32 +1,32 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-grips");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-grips",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_banana_environment();
});
});
do_test_pending();
}
function test_banana_environment()
{
function test_banana_environment() {
gThreadClient.addOneTimeListener("paused",
function (aEvent, aPacket) {
equal(aPacket.type, "paused");
let env = aPacket.frame.environment;
function (event, packet) {
equal(packet.type, "paused");
let env = packet.frame.environment;
equal(env.type, "function");
equal(env.function.name, "banana3");
let parent = env.parent;
@ -47,14 +47,12 @@ function test_banana_environment()
});
});
gDebuggee.eval("\
function banana(x) { \n\
return function banana2(y) { \n\
return function banana3(z) { \n\
debugger; \n\
}; \n\
}; \n\
} \n\
banana('x')('y')('z'); \n\
");
gDebuggee.eval("function banana(x) {\n" +
" return function banana2(y) {\n" +
" return function banana3(z) {\n" +
" debugger;\n" +
" };\n" +
" };\n" +
"}\n" +
"banana('x')('y')('z');\n");
}

Просмотреть файл

@ -1,31 +1,32 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
var gDebuggee;
var gClient;
var gThreadClient;
// Test that the EnvironmentClient's getBindings() method works as expected.
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-bindings");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-bindings", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-bindings",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_banana_environment();
});
});
do_test_pending();
}
function test_banana_environment()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let environment = aPacket.frame.environment;
function test_banana_environment() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let environment = packet.frame.environment;
do_check_eq(environment.type, "function");
let parent = environment.parent;
@ -35,30 +36,28 @@ function test_banana_environment()
do_check_eq(grandpa.type, "function");
let envClient = gThreadClient.environment(environment);
envClient.getBindings(aResponse => {
do_check_eq(aResponse.bindings.arguments[0].z.value, "z");
envClient.getBindings(response => {
do_check_eq(response.bindings.arguments[0].z.value, "z");
let parentClient = gThreadClient.environment(parent);
parentClient.getBindings(aResponse => {
do_check_eq(aResponse.bindings.variables.banana3.value.class, "Function");
parentClient.getBindings(response => {
do_check_eq(response.bindings.variables.banana3.value.class, "Function");
let grandpaClient = gThreadClient.environment(grandpa);
grandpaClient.getBindings(aResponse => {
do_check_eq(aResponse.bindings.arguments[0].y.value, "y");
grandpaClient.getBindings(response => {
do_check_eq(response.bindings.arguments[0].y.value, "y");
gThreadClient.resume(() => finishClient(gClient));
});
});
});
});
gDebuggee.eval("\
function banana(x) { \n\
return function banana2(y) { \n\
return function banana3(z) { \n\
debugger; \n\
}; \n\
}; \n\
} \n\
banana('x')('y')('z'); \n\
");
gDebuggee.eval("function banana(x) {\n" +
" return function banana2(y) {\n" +
" return function banana3(z) {\n" +
" debugger;\n" +
" };\n" +
" };\n" +
"}\n" +
"banana('x')('y')('z');\n");
}

Просмотреть файл

@ -1,27 +1,29 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable max-nested-callbacks */
"use strict";
var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.addOneTimeListener("framesadded", function () {
do_check_eq(gThreadClient.cachedFrames.length, 3);
do_check_true(gThreadClient.moreFrames);
@ -39,6 +41,7 @@ function test_pause_frame()
do_check_true(gThreadClient.fillFrames(3));
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
var recurseLeft = 5;
function recurse() {
@ -50,4 +53,5 @@ function test_pause_frame()
}
recurse();
} + ")()");
/* eslint-enable */
}

Просмотреть файл

@ -1,27 +1,28 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
// Ask for exactly the number of frames we expect.
gThreadClient.addOneTimeListener("framesadded", function () {
do_check_false(gThreadClient.moreFrames);
@ -32,6 +33,7 @@ function test_pause_frame()
do_check_true(gThreadClient.fillFrames(3));
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
var recurseLeft = 1;
function recurse() {
@ -43,4 +45,5 @@ function test_pause_frame()
}
recurse();
} + ")()");
/* eslint-enable */
}

Просмотреть файл

@ -1,12 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-grips");
gDebuggee.eval(function stopMe(arg1) {
@ -15,39 +16,38 @@ function run_test()
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-grips",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_named_function();
});
});
do_test_pending();
}
function test_named_function()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let args = aPacket.frame.arguments;
function test_named_function() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let args = packet.frame.arguments;
do_check_eq(args[0].class, "Function");
do_check_eq(args[0].name, "stopMe");
do_check_eq(args[0].displayName, "stopMe");
let objClient = gThreadClient.pauseGrip(args[0]);
objClient.getParameterNames(function (aResponse) {
do_check_eq(aResponse.parameterNames.length, 1);
do_check_eq(aResponse.parameterNames[0], "arg1");
objClient.getParameterNames(function (response) {
do_check_eq(response.parameterNames.length, 1);
do_check_eq(response.parameterNames[0], "arg1");
gThreadClient.resume(test_inferred_name_function);
});
});
gDebuggee.eval("stopMe(stopMe)");
}
function test_inferred_name_function() {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let args = aPacket.frame.arguments;
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let args = packet.frame.arguments;
do_check_eq(args[0].class, "Function");
// No name for an anonymous function, but it should have an inferred name.
@ -55,11 +55,11 @@ function test_inferred_name_function() {
do_check_eq(args[0].displayName, "m");
let objClient = gThreadClient.pauseGrip(args[0]);
objClient.getParameterNames(function (aResponse) {
do_check_eq(aResponse.parameterNames.length, 3);
do_check_eq(aResponse.parameterNames[0], "foo");
do_check_eq(aResponse.parameterNames[1], "bar");
do_check_eq(aResponse.parameterNames[2], "baz");
objClient.getParameterNames(function (response) {
do_check_eq(response.parameterNames.length, 3);
do_check_eq(response.parameterNames[0], "foo");
do_check_eq(response.parameterNames[1], "bar");
do_check_eq(response.parameterNames[2], "baz");
gThreadClient.resume(test_anonymous_function);
});
@ -69,8 +69,8 @@ function test_inferred_name_function() {
}
function test_anonymous_function() {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let args = aPacket.frame.arguments;
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let args = packet.frame.arguments;
do_check_eq(args[0].class, "Function");
// No name for an anonymous function, and no inferred name, either.
@ -78,11 +78,11 @@ function test_anonymous_function() {
do_check_eq(args[0].displayName, undefined);
let objClient = gThreadClient.pauseGrip(args[0]);
objClient.getParameterNames(function (aResponse) {
do_check_eq(aResponse.parameterNames.length, 3);
do_check_eq(aResponse.parameterNames[0], "foo");
do_check_eq(aResponse.parameterNames[1], "bar");
do_check_eq(aResponse.parameterNames[2], "baz");
objClient.getParameterNames(function (response) {
do_check_eq(response.parameterNames.length, 3);
do_check_eq(response.parameterNames[0], "foo");
do_check_eq(response.parameterNames[1], "bar");
do_check_eq(response.parameterNames[2], "baz");
gThreadClient.resume(function () {
finishClient(gClient);

Просмотреть файл

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* Test if getExecutableLines return correct information
*/
@ -20,8 +22,8 @@ function run_test() {
attachTestTabAndResume(
gClient,
"test-get-executable-lines",
function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_executable_lines();
}
);

Просмотреть файл

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* Test if getExecutableLines return correct information
*/
@ -20,8 +22,8 @@ function run_test() {
attachTestTabAndResume(
gClient,
"test-get-executable-lines",
function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_executable_lines();
}
);

Просмотреть файл

@ -24,7 +24,8 @@ const TEST_DATA = [
},
{
desc: "Multiple rules test case",
input: "#id{color:red;background:yellow;}.class-one .class-two { position:absolute; line-height: 45px}",
input: "#id{color:red;background:yellow;}.class-one .class-two " +
"{ position:absolute; line-height: 45px}",
line: 1,
column: 34,
expected: {offset: 56, text: " position:absolute; line-height: 45px"}

Просмотреть файл

@ -1,22 +1,22 @@
function run_test()
{
/* eslint-disable strict */
function run_test() {
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
var xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
var g = testGlobal("test1");
let xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(Ci.nsIJSInspector);
let g = testGlobal("test1");
var dbg = new Debugger();
let dbg = new Debugger();
dbg.uncaughtExceptionHook = testExceptionHook;
dbg.addDebuggee(g);
dbg.onDebuggerStatement = function (aFrame) {
do_check_true(aFrame === dbg.getNewestFrame());
dbg.onDebuggerStatement = function (frame) {
do_check_true(frame === dbg.getNewestFrame());
// Execute from the nested event loop, dbg.getNewestFrame() won't
// be working anymore.
do_execute_soon(function () {
try {
do_check_true(aFrame === dbg.getNewestFrame());
do_check_true(frame === dbg.getNewestFrame());
} finally {
xpcInspector.exitNestedEventLoop("test");
}

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Test that setting ignoreCaughtExceptions will cause the debugger to ignore
@ -10,26 +13,25 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_eq(aPacket.why.type, "exception");
do_check_eq(aPacket.why.exception, "bar");
function test_pause_frame() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
do_check_eq(packet.why.type, "exception");
do_check_eq(packet.why.exception, "bar");
gThreadClient.resume(function () {
finishClient(gClient);
});
@ -39,6 +41,7 @@ function test_pause_frame()
});
try {
/* eslint-disable */
gDebuggee.eval("(" + function () {
debugger;
try {
@ -46,5 +49,8 @@ function test_pause_frame()
} catch (e) {}
throw "bar";
} + ")()");
} catch (e) {}
/* eslint-enable */
} catch (e) {
/* Empty */
}
}

Просмотреть файл

@ -1,41 +1,42 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Test that the debugger automatically ignores NS_ERROR_NO_INTERFACE
* exceptions, but not normal ones.
*/
var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-no-interface");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-no-interface", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-no-interface",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_pause_frame();
});
});
do_test_pending();
}
function test_pause_frame()
{
function test_pause_frame() {
gThreadClient.pauseOnExceptions(true, false, function () {
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
do_check_eq(aPacket.why.type, "exception");
do_check_eq(aPacket.why.exception, 42);
gThreadClient.addOneTimeListener("paused", function (event, packet) {
do_check_eq(packet.why.type, "exception");
do_check_eq(packet.why.exception, 42);
gThreadClient.resume(function () {
finishClient(gClient);
});
});
/* eslint-disable */
gDebuggee.eval("(" + function () {
function QueryInterface() {
throw Components.results.NS_ERROR_NO_INTERFACE;
@ -50,5 +51,6 @@ function test_pause_frame()
stopMe();
} catch (e) {}
} + ")()");
/* eslint-enable */
});
}

Просмотреть файл

@ -1,48 +1,47 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
var gClient;
var gDebuggee;
function run_test()
{
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) {
gClient.connect().then(function (type, traits) {
attachTestTab(gClient, "test-1", test_attach);
});
do_test_pending();
}
function test_attach(aResponse, aTabClient)
{
aTabClient.attachThread({}, function (aResponse, aThreadClient) {
do_check_eq(aThreadClient.paused, true);
aThreadClient.resume(function () {
test_interrupt(aThreadClient);
function test_attach(response, tabClient) {
tabClient.attachThread({}, function (response, threadClient) {
do_check_eq(threadClient.paused, true);
threadClient.resume(function () {
test_interrupt(threadClient);
});
});
}
function test_interrupt(aThreadClient)
{
do_check_eq(aThreadClient.paused, false);
aThreadClient.interrupt(function (aResponse) {
do_check_eq(aThreadClient.paused, true);
aThreadClient.resume(function () {
do_check_eq(aThreadClient.paused, false);
function test_interrupt(threadClient) {
do_check_eq(threadClient.paused, false);
threadClient.interrupt(function (response) {
do_check_eq(threadClient.paused, true);
threadClient.resume(function () {
do_check_eq(threadClient.paused, false);
cleanup();
});
});
}
function cleanup()
{
gClient.addListener("closed", function (aEvent) {
function cleanup() {
gClient.addListener("closed", function (event) {
do_test_finished();
});
gClient.close();

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test the LayoutChangesObserver
var {

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check basic getSources functionality.
*/
@ -11,33 +13,32 @@ var gThreadClient;
var gNumTimesSourcesSent = 0;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.request = (function (request) {
return function (aRequest, aOnResponse) {
if (aRequest.type === "sources") {
gClient.request = (function (origRequest) {
return function (request, onResponse) {
if (request.type === "sources") {
++gNumTimesSourcesSent;
}
return request.call(this, aRequest, aOnResponse);
return origRequest.call(this, request, onResponse);
};
}(gClient.request));
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_simple_listsources();
});
});
do_test_pending();
}
function test_simple_listsources()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.getSources(function (aResponse) {
do_check_true(aResponse.sources.some(function (s) {
function test_simple_listsources() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.getSources(function (response) {
do_check_true(response.sources.some(function (s) {
return s.url && s.url.match(/test_listsources-01.js/);
}));
@ -51,9 +52,11 @@ function test_simple_listsources()
});
});
/* eslint-disable */
Components.utils.evalInSandbox("var line0 = Error().lineNumber;\n" +
"debugger;\n" + // line0 + 1
"var a = 1;\n" + // line0 + 2
"var b = 2;\n", // line0 + 3
gDebuggee);
/* eslint-enable */
}

Просмотреть файл

@ -1,44 +1,44 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check getting sources before there are any.
*/
var gDebuggee;
var gClient;
var gThreadClient;
var gNumTimesSourcesSent = 0;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.request = (function (request) {
return function (aRequest, aOnResponse) {
if (aRequest.type === "sources") {
gClient.request = (function (origRequest) {
return function (request, onResponse) {
if (request.type === "sources") {
++gNumTimesSourcesSent;
}
return request.call(this, aRequest, aOnResponse);
return origRequest.call(this, request, onResponse);
};
}(gClient.request));
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_listing_zero_sources();
});
});
do_test_pending();
}
function test_listing_zero_sources()
{
gThreadClient.getSources(function (aPacket) {
do_check_true(!aPacket.error);
do_check_true(!!aPacket.sources);
do_check_eq(aPacket.sources.length, 0);
function test_listing_zero_sources() {
gThreadClient.getSources(function (packet) {
do_check_true(!packet.error);
do_check_true(!!packet.sources);
do_check_eq(packet.sources.length, 0);
do_check_true(gNumTimesSourcesSent <= 1,
"Should only send one sources request at most, even though we"

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check getSources functionality when there are lots of sources.
*/
@ -9,29 +11,28 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-sources");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-sources", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-sources",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_simple_listsources();
});
});
do_test_pending();
}
function test_simple_listsources()
{
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.getSources(function (aResponse) {
function test_simple_listsources() {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
gThreadClient.getSources(function (response) {
do_check_true(
!aResponse.error,
!response.error,
"There shouldn't be an error fetching large amounts of sources.");
do_check_true(aResponse.sources.some(function (s) {
do_check_true(response.sources.some(function (s) {
return s.url.match(/foo-999.js$/);
}));

Просмотреть файл

@ -1,5 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow */
"use strict";
/**
* Check getSources functionality with sourcemaps.

Просмотреть файл

@ -14,8 +14,7 @@ function run_test() {
const TEST_STRING = "This is a very long string!";
function makeMockLongStringActor()
{
function makeMockLongStringActor() {
let string = TEST_STRING;
let actor = new LongStringActor(string);
actor.actorID = "longString1";
@ -27,8 +26,7 @@ function makeMockLongStringActor()
return actor;
}
function test_LSA_destroy()
{
function test_LSA_destroy() {
let actor = makeMockLongStringActor();
do_check_eq(actor.registeredPool.longStringActors[TEST_STRING], actor);
@ -36,27 +34,18 @@ function test_LSA_destroy()
do_check_eq(actor.registeredPool.longStringActors[TEST_STRING], void 0);
}
function test_LSA_substring()
{
let actor = makeMockLongStringActor();
do_check_eq(actor._substring(0, 4), TEST_STRING.substring(0, 4));
do_check_eq(actor._substring(6, 9), TEST_STRING.substring(6, 9));
do_check_eq(actor._substring(0, TEST_STRING.length), TEST_STRING);
}
function test_LSA_grip()
{
function test_LSA_grip() {
let actor = makeMockLongStringActor();
let grip = actor.grip();
do_check_eq(grip.type, "longString");
do_check_eq(grip.initial, TEST_STRING.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH));
do_check_eq(grip.initial,
TEST_STRING.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH));
do_check_eq(grip.length, TEST_STRING.length);
do_check_eq(grip.actor, actor.actorID);
}
function test_LSA_onSubstring()
{
function test_LSA_onSubstring() {
let actor = makeMockLongStringActor();
let response;

Просмотреть файл

@ -1,12 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-grips");
gDebuggee.eval(function stopMe(arg1) {
@ -15,16 +16,16 @@ function run_test()
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-grips",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_longstring_grip();
});
});
do_test_pending();
}
function test_longstring_grip()
{
function test_longstring_grip() {
let longString = "All I want is to be a monkey of moderate intelligence who"
+ " wears a suit... that's why I'm transferring to business school! Maybe I"
+ " love you so much, I love you no matter who you are pretending to be."
@ -38,20 +39,21 @@ function test_longstring_grip()
DebuggerServer.LONG_STRING_LENGTH = 200;
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
let args = aPacket.frame.arguments;
gThreadClient.addOneTimeListener("paused", function (event, packet) {
let args = packet.frame.arguments;
do_check_eq(args.length, 1);
let grip = args[0];
try {
do_check_eq(grip.type, "longString");
do_check_eq(grip.length, longString.length);
do_check_eq(grip.initial, longString.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH));
do_check_eq(grip.initial,
longString.substr(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH));
let longStringClient = gThreadClient.pauseLongString(grip);
longStringClient.substring(22, 28, function (aResponse) {
longStringClient.substring(22, 28, function (response) {
try {
do_check_eq(aResponse.substring, "monkey");
do_check_eq(response.substring, "monkey");
} finally {
gThreadClient.resume(function () {
finishClient(gClient);

Просмотреть файл

@ -1,12 +1,13 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-grips");
gDebuggee.eval(function stopMe(arg1) {
@ -16,19 +17,18 @@ function run_test()
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(
gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
gClient, "test-grips", function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_longstring_grip();
});
});
do_test_pending();
}
function test_longstring_grip()
{
function test_longstring_grip() {
DebuggerServer.LONG_STRING_LENGTH = 200;
gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
gThreadClient.addOneTimeListener("paused", function (event, packet) {
try {
let fakeLongStringGrip = {
type: "longString",
@ -37,9 +37,9 @@ function test_longstring_grip()
initial: ""
};
let longStringClient = gThreadClient.pauseLongString(fakeLongStringGrip);
longStringClient.substring(22, 28, function (aResponse) {
longStringClient.substring(22, 28, function (response) {
try {
do_check_true(!!aResponse.error,
do_check_true(!!response.error,
"We should not get a response, but an error.");
} finally {
gThreadClient.resume(function () {

Просмотреть файл

@ -7,8 +7,7 @@
"use strict";
function run_test()
{
function run_test() {
let EventEmitter = require("devtools/shared/event-emitter");
function MonitorClient(client, form) {
@ -64,7 +63,7 @@ function run_test()
do_check_eq(event.curve, "test");
do_check_eq(event.value, 42);
do_check_eq(event.time, time);
monitor.stop(function (aResponse) {
monitor.stop(function (response) {
monitor.destroy();
finishClient(client);
});

Просмотреть файл

@ -1,13 +1,13 @@
function run_test()
{
/* eslint-disable strict */
function run_test() {
Components.utils.import("resource://gre/modules/jsdebugger.jsm");
addDebuggerToGlobal(this);
var g = testGlobal("test1");
let g = testGlobal("test1");
var dbg = new Debugger();
let dbg = new Debugger();
dbg.addDebuggee(g);
dbg.onDebuggerStatement = function (aFrame) {
let args = aFrame.arguments;
dbg.onDebuggerStatement = function (frame) {
let args = frame.arguments;
try {
args[0];
do_check_true(true);
@ -21,7 +21,8 @@ function run_test()
g2 = testGlobal("test2");
g2.g = g;
g2.eval("(" + function createBadEvent() {
let parser = Components.classes["@mozilla.org/xmlextras/domparser;1"].createInstance(Components.interfaces.nsIDOMParser);
let parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
.createInstance(Components.interfaces.nsIDOMParser);
let doc = parser.parseFromString("<foo></foo>", "text/xml");
g.stopMe(doc.createEvent("MouseEvent"));
} + ")()");

Просмотреть файл

@ -2,6 +2,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that we can nest event loops when needed in
// ThreadActor.prototype.unsafeSynchronize.
@ -10,12 +12,15 @@ var gThreadActor;
function run_test() {
initTestDebuggerServer();
let gDebuggee = addTestGlobal("test-nesting");
addTestGlobal("test-nesting");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-nesting", function (aResponse, aTabClient, aThreadClient) {
attachTestTabAndResume(
gClient, "test-nesting",
function (response, tabClient, threadClient) {
// Reach over the protocol connection and get a reference to the thread actor.
gThreadActor = aThreadClient._transport._serverConnection.getActor(aThreadClient._actor);
gThreadActor =
threadClient._transport._serverConnection.getActor(threadClient._actor);
test_nesting();
});
@ -25,7 +30,7 @@ function run_test() {
function test_nesting() {
const thread = gThreadActor;
const { resolve, reject, promise: p } = promise.defer();
const { resolve, promise: p } = promise.defer();
let currentStep = 0;

Просмотреть файл

@ -2,6 +2,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that we can nest event loops and then automatically exit nested event
// loops when requested.
@ -10,13 +12,16 @@ var gThreadActor;
function run_test() {
initTestDebuggerServer();
let gDebuggee = addTestGlobal("test-nesting");
addTestGlobal("test-nesting");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-nesting", function (aResponse, aTabClient, aThreadClient) {
attachTestTabAndResume(
gClient, "test-nesting",
function (response, tabClient, threadClient) {
// Reach over the protocol connection and get a reference to the thread
// actor.
gThreadActor = aThreadClient._transport._serverConnection.getActor(aThreadClient._actor);
gThreadActor =
threadClient._transport._serverConnection.getActor(threadClient._actor);
test_nesting();
});
@ -26,7 +31,7 @@ function run_test() {
function test_nesting() {
const thread = gThreadActor;
const { resolve, reject, promise: p } = promise.defer();
const { resolve, promise: p } = promise.defer();
// The following things should happen (in order):
// 1. In the new event loop (created by unsafeSynchronize)

Просмотреть файл

@ -1,6 +1,9 @@
/* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* eslint-disable no-shadow, max-nested-callbacks */
"use strict";
// Test that we can detect nested event loops in tabs with the same URL.
@ -13,8 +16,9 @@ function run_test() {
// Conect the first client to the first debuggee.
gClient1 = new DebuggerClient(DebuggerServer.connectPipe());
gClient1.connect(function () {
attachTestThread(gClient1, "test-nesting1", function (aResponse, aTabClient, aThreadClient) {
gThreadClient1 = aThreadClient;
attachTestThread(gClient1, "test-nesting1",
function (response, tabClient, threadClient) {
gThreadClient1 = threadClient;
start_second_connection();
});
});
@ -24,25 +28,24 @@ function run_test() {
function start_second_connection() {
gClient2 = new DebuggerClient(DebuggerServer.connectPipe());
gClient2.connect(function () {
attachTestThread(gClient2, "test-nesting1", function (aResponse, aTabClient, aThreadClient) {
gThreadClient2 = aThreadClient;
attachTestThread(gClient2, "test-nesting1",
function (response, tabClient, threadClient) {
gThreadClient2 = threadClient;
test_nesting();
});
});
}
function test_nesting() {
const { resolve, reject, promise: p } = promise.defer();
gThreadClient1.resume(response => {
do_check_eq(response.error, "wrongOrder");
gThreadClient2.resume(response => {
do_check_true(!response.error);
do_check_eq(response.from, gThreadClient2.actor);
gThreadClient1.resume(aResponse => {
do_check_eq(aResponse.error, "wrongOrder");
gThreadClient2.resume(aResponse => {
do_check_true(!aResponse.error);
do_check_eq(aResponse.from, gThreadClient2.actor);
gThreadClient1.resume(aResponse => {
do_check_true(!aResponse.error);
do_check_eq(aResponse.from, gThreadClient1.actor);
gThreadClient1.resume(response => {
do_check_true(!response.error);
do_check_eq(response.from, gThreadClient1.actor);
gClient1.close(() => finishClient(gClient2));
});

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check basic newSource packet sent from server.
*/
@ -9,27 +11,26 @@ var gDebuggee;
var gClient;
var gThreadClient;
function run_test()
{
function run_test() {
initTestDebuggerServer();
gDebuggee = addTestGlobal("test-stack");
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect().then(function () {
attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
attachTestTabAndResume(gClient, "test-stack",
function (response, tabClient, threadClient) {
gThreadClient = threadClient;
test_simple_new_source();
});
});
do_test_pending();
}
function test_simple_new_source()
{
gThreadClient.addOneTimeListener("newSource", function (aEvent, aPacket) {
do_check_eq(aEvent, "newSource");
do_check_eq(aPacket.type, "newSource");
do_check_true(!!aPacket.source);
do_check_true(!!aPacket.source.url.match(/test_new_source-01.js$/));
function test_simple_new_source() {
gThreadClient.addOneTimeListener("newSource", function (event, packet) {
do_check_eq(event, "newSource");
do_check_eq(packet.type, "newSource");
do_check_true(!!packet.source);
do_check_true(!!packet.source.url.match(/test_new_source-01.js$/));
finishClient(gClient);
});

Просмотреть файл

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test the basic functionality of the nsIJSInspector component.
var gCount = 0;
const MAX = 10;
@ -13,13 +15,11 @@ var requestor = (count) => ({
connection: "conn" + (count % 3)
});
function run_test()
{
function run_test() {
test_nesting();
}
function test_nesting()
{
function test_nesting() {
do_check_eq(inspector.eventLoopNestLevel, 0);
tm.currentThread.dispatch({ run: enterEventLoop}, 0);
@ -33,7 +33,7 @@ function enterEventLoop() {
if (gCount++ < MAX) {
tm.currentThread.dispatch({ run: enterEventLoop}, 0);
let r = Object.create(requestor(gCount));
Object.create(requestor(gCount));
do_check_eq(inspector.eventLoopNestLevel, gCount);
do_check_eq(inspector.lastNestRequestor.url, requestor(gCount - 1).url);

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше