forked from mirrors/gecko-dev
Bug 1326410 - Fixing ESLint Errors. r=ntim
MozReview-Commit-ID: HZ3iBCW0hEf
This commit is contained in:
parent
869af55a16
commit
b7b3908f8f
12 changed files with 92 additions and 197 deletions
|
|
@ -115,7 +115,6 @@ devtools/server/tests/browser/**
|
||||||
devtools/server/tests/mochitest/**
|
devtools/server/tests/mochitest/**
|
||||||
devtools/server/tests/unit/**
|
devtools/server/tests/unit/**
|
||||||
devtools/shared/heapsnapshot/**
|
devtools/shared/heapsnapshot/**
|
||||||
devtools/shared/transport/tests/unit/**
|
|
||||||
devtools/shared/webconsole/test/**
|
devtools/shared/webconsole/test/**
|
||||||
|
|
||||||
# Ignore devtools pre-processed files
|
# Ignore devtools pre-processed files
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/* exported Cr, CC, NetUtil, defer, errorCount, initTestDebuggerServer,
|
||||||
|
writeTestTempFile, socket_transport, local_transport, really_long
|
||||||
|
*/
|
||||||
|
|
||||||
var Cc = Components.classes;
|
var Cc = Components.classes;
|
||||||
var Ci = Components.interfaces;
|
var Ci = Components.interfaces;
|
||||||
var Cu = Components.utils;
|
var Cu = Components.utils;
|
||||||
|
|
@ -17,7 +21,6 @@ const defer = require("devtools/shared/defer");
|
||||||
const { Task } = require("devtools/shared/task");
|
const { Task } = require("devtools/shared/task");
|
||||||
|
|
||||||
const Services = require("Services");
|
const Services = require("Services");
|
||||||
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
|
||||||
|
|
||||||
// We do not want to log packets by default, because in some tests,
|
// We do not want to log packets by default, because in some tests,
|
||||||
// we can be sending large amounts of data. The test harness has
|
// we can be sending large amounts of data. The test harness has
|
||||||
|
|
@ -31,27 +34,21 @@ Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
|
||||||
const { DebuggerServer } = require("devtools/server/main");
|
const { DebuggerServer } = require("devtools/server/main");
|
||||||
const { DebuggerClient } = require("devtools/shared/client/main");
|
const { DebuggerClient } = require("devtools/shared/client/main");
|
||||||
|
|
||||||
function testExceptionHook(ex) {
|
// Convert an nsIScriptError 'flags' value into an appropriate string.
|
||||||
try {
|
function scriptErrorFlagsToKind(flags) {
|
||||||
do_report_unexpected_exception(ex);
|
let kind;
|
||||||
} catch (ex) {
|
if (flags & Ci.nsIScriptError.warningFlag) {
|
||||||
return {throw: ex};
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert an nsIScriptError 'aFlags' value into an appropriate string.
|
|
||||||
function scriptErrorFlagsToKind(aFlags) {
|
|
||||||
var kind;
|
|
||||||
if (aFlags & Ci.nsIScriptError.warningFlag)
|
|
||||||
kind = "warning";
|
kind = "warning";
|
||||||
if (aFlags & Ci.nsIScriptError.exceptionFlag)
|
}
|
||||||
|
if (flags & Ci.nsIScriptError.exceptionFlag) {
|
||||||
kind = "exception";
|
kind = "exception";
|
||||||
else
|
} else {
|
||||||
kind = "error";
|
kind = "error";
|
||||||
|
}
|
||||||
|
|
||||||
if (aFlags & Ci.nsIScriptError.strictFlag)
|
if (flags & Ci.nsIScriptError.strictFlag) {
|
||||||
kind = "strict " + kind;
|
kind = "strict " + kind;
|
||||||
|
}
|
||||||
|
|
||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
|
|
@ -60,23 +57,24 @@ function scriptErrorFlagsToKind(aFlags) {
|
||||||
// into the ether.
|
// into the ether.
|
||||||
var errorCount = 0;
|
var errorCount = 0;
|
||||||
var listener = {
|
var listener = {
|
||||||
observe: function (aMessage) {
|
observe: function (message) {
|
||||||
errorCount++;
|
errorCount++;
|
||||||
|
let string = "";
|
||||||
try {
|
try {
|
||||||
// If we've been given an nsIScriptError, then we can print out
|
// If we've been given an nsIScriptError, then we can print out
|
||||||
// something nicely formatted, for tools like Emacs to pick up.
|
// something nicely formatted, for tools like Emacs to pick up.
|
||||||
var scriptError = aMessage.QueryInterface(Ci.nsIScriptError);
|
message.QueryInterface(Ci.nsIScriptError);
|
||||||
dump(aMessage.sourceName + ":" + aMessage.lineNumber + ": " +
|
dump(message.sourceName + ":" + message.lineNumber + ": " +
|
||||||
scriptErrorFlagsToKind(aMessage.flags) + ": " +
|
scriptErrorFlagsToKind(message.flags) + ": " +
|
||||||
aMessage.errorMessage + "\n");
|
message.errorMessage + "\n");
|
||||||
var string = aMessage.errorMessage;
|
string = message.errorMessage;
|
||||||
} catch (x) {
|
} catch (x) {
|
||||||
// Be a little paranoid with message, as the whole goal here is to lose
|
// Be a little paranoid with message, as the whole goal here is to lose
|
||||||
// no information.
|
// no information.
|
||||||
try {
|
try {
|
||||||
var string = "" + aMessage.message;
|
string = message.message;
|
||||||
} catch (x) {
|
} catch (e) {
|
||||||
var string = "<error converting error message to string>";
|
string = "<error converting error message to string>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,7 +84,7 @@ var listener = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Throw in most cases, but ignore the "strict" messages
|
// Throw in most cases, but ignore the "strict" messages
|
||||||
if (!(aMessage.flags & Ci.nsIScriptError.strictFlag)) {
|
if (!(message.flags & Ci.nsIScriptError.strictFlag)) {
|
||||||
do_throw("head_dbg.js got console message: " + string + "\n");
|
do_throw("head_dbg.js got console message: " + string + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -96,80 +94,6 @@ var consoleService = Cc["@mozilla.org/consoleservice;1"]
|
||||||
.getService(Ci.nsIConsoleService);
|
.getService(Ci.nsIConsoleService);
|
||||||
consoleService.registerListener(listener);
|
consoleService.registerListener(listener);
|
||||||
|
|
||||||
function check_except(func) {
|
|
||||||
try {
|
|
||||||
func();
|
|
||||||
} catch (e) {
|
|
||||||
do_check_true(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dump("Should have thrown an exception: " + func.toString());
|
|
||||||
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;
|
|
||||||
return sandbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
function addTestGlobal(aName)
|
|
||||||
{
|
|
||||||
let global = testGlobal(aName);
|
|
||||||
DebuggerServer.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);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aCallback(null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach to |aClient|'s tab whose title is |aTitle|; pass |aCallback| 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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// TabClient referring to the tab, and a ThreadClient referring to the
|
|
||||||
// thread.
|
|
||||||
function attachTestThread(aClient, aTitle, aCallback) {
|
|
||||||
attachTestTab(aClient, aTitle, function (aResponse, aTabClient) {
|
|
||||||
function onAttach(aResponse, aThreadClient) {
|
|
||||||
aCallback(aResponse, aTabClient, aThreadClient);
|
|
||||||
}
|
|
||||||
aTabClient.attachThread({ useSourceMaps: 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
|
|
||||||
// the 'resume' packet, a TabClient for the tab, and a ThreadClient for the
|
|
||||||
// thread.
|
|
||||||
function attachTestTabAndResume(aClient, aTitle, aCallback) {
|
|
||||||
attachTestThread(aClient, aTitle, function (aResponse, aTabClient, aThreadClient) {
|
|
||||||
aThreadClient.resume(function (aResponse) {
|
|
||||||
aCallback(aResponse, aTabClient, aThreadClient);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the testing debugger server.
|
* Initialize the testing debugger server.
|
||||||
*/
|
*/
|
||||||
|
|
@ -184,35 +108,6 @@ function initTestDebuggerServer() {
|
||||||
DebuggerServer.init();
|
DebuggerServer.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishClient(aClient) {
|
|
||||||
aClient.close().then(function () {
|
|
||||||
do_test_finished();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
return Services.io.newFileURI(file).spec;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the full path of the file with the specified name in a
|
|
||||||
* platform-independent and URL-like form.
|
|
||||||
*/
|
|
||||||
function getFilePath(aName, aAllowMissing = false) {
|
|
||||||
let file = do_get_file(aName, aAllowMissing);
|
|
||||||
let path = Services.io.newFileURI(file).spec;
|
|
||||||
let filePrePath = "file://";
|
|
||||||
if ("nsILocalFileWin" in Ci &&
|
|
||||||
file instanceof Ci.nsILocalFileWin) {
|
|
||||||
filePrePath += "/";
|
|
||||||
}
|
|
||||||
return path.slice(filePrePath.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper around do_get_file to prefix files with the name of current test to
|
* Wrapper around do_get_file to prefix files with the name of current test to
|
||||||
* avoid collisions when running in parallel.
|
* avoid collisions when running in parallel.
|
||||||
|
|
@ -224,16 +119,16 @@ function getTestTempFile(fileName, allowMissing) {
|
||||||
return do_get_file(fileName + "-" + thisTest, allowMissing);
|
return do_get_file(fileName + "-" + thisTest, allowMissing);
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeTestTempFile(aFileName, aContent) {
|
function writeTestTempFile(fileName, content) {
|
||||||
let file = getTestTempFile(aFileName, true);
|
let file = getTestTempFile(fileName, true);
|
||||||
let stream = Cc["@mozilla.org/network/file-output-stream;1"]
|
let stream = Cc["@mozilla.org/network/file-output-stream;1"]
|
||||||
.createInstance(Ci.nsIFileOutputStream);
|
.createInstance(Ci.nsIFileOutputStream);
|
||||||
stream.init(file, -1, -1, 0);
|
stream.init(file, -1, -1, 0);
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
let numWritten = stream.write(aContent, aContent.length);
|
let numWritten = stream.write(content, content.length);
|
||||||
aContent = aContent.slice(numWritten);
|
content = content.slice(numWritten);
|
||||||
} while (aContent.length > 0);
|
} while (content.length > 0);
|
||||||
} finally {
|
} finally {
|
||||||
stream.close();
|
stream.close();
|
||||||
}
|
}
|
||||||
|
|
@ -248,10 +143,10 @@ var socket_transport = Task.async(function* () {
|
||||||
authenticator.allowConnection = () => {
|
authenticator.allowConnection = () => {
|
||||||
return DebuggerServer.AuthenticationResult.ALLOW;
|
return DebuggerServer.AuthenticationResult.ALLOW;
|
||||||
};
|
};
|
||||||
let listener = DebuggerServer.createListener();
|
let debuggerListener = DebuggerServer.createListener();
|
||||||
listener.portOrPath = -1;
|
debuggerListener.portOrPath = -1;
|
||||||
listener.authenticator = authenticator;
|
debuggerListener.authenticator = authenticator;
|
||||||
yield listener.open();
|
yield debuggerListener.open();
|
||||||
}
|
}
|
||||||
let port = DebuggerServer._listeners[0].port;
|
let port = DebuggerServer._listeners[0].port;
|
||||||
do_print("Debugger server port is " + port);
|
do_print("Debugger server port is " + port);
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ function json_reply(client, response) {
|
||||||
// Send bulk data to server
|
// Send bulk data to server
|
||||||
let copyDeferred = defer();
|
let copyDeferred = defer();
|
||||||
request.on("bulk-send-ready", ({writer, done}) => {
|
request.on("bulk-send-ready", ({writer, done}) => {
|
||||||
let input = Cc["@mozilla.org/io/string-input-stream;1"].
|
let input = Cc["@mozilla.org/io/string-input-stream;1"]
|
||||||
createInstance(Ci.nsIStringInputStream);
|
.createInstance(Ci.nsIStringInputStream);
|
||||||
input.setData(reallyLong, reallyLong.length);
|
input.setData(reallyLong, reallyLong.length);
|
||||||
try {
|
try {
|
||||||
writer.copyFrom(input, () => {
|
writer.copyFrom(input, () => {
|
||||||
|
|
|
||||||
|
|
@ -150,6 +150,18 @@ var test_bulk_request_cs = Task.async(function* (transportFactory, actorType, re
|
||||||
client.listTabs(clientDeferred.resolve);
|
client.listTabs(clientDeferred.resolve);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function bulkSendReadyCallback({copyFrom}) {
|
||||||
|
NetUtil.asyncFetch({
|
||||||
|
uri: NetUtil.newURI(getTestTempFile("bulk-input")),
|
||||||
|
loadUsingSystemPrincipal: true
|
||||||
|
}, input => {
|
||||||
|
copyFrom(input).then(() => {
|
||||||
|
input.close();
|
||||||
|
bulkCopyDeferred.resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
clientDeferred.promise.then(response => {
|
clientDeferred.promise.then(response => {
|
||||||
let request = client.startBulkRequest({
|
let request = client.startBulkRequest({
|
||||||
actor: response.testBulk,
|
actor: response.testBulk,
|
||||||
|
|
@ -158,17 +170,7 @@ var test_bulk_request_cs = Task.async(function* (transportFactory, actorType, re
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send bulk data to server
|
// Send bulk data to server
|
||||||
request.on("bulk-send-ready", ({copyFrom}) => {
|
request.on("bulk-send-ready", bulkSendReadyCallback);
|
||||||
NetUtil.asyncFetch({
|
|
||||||
uri: NetUtil.newURI(getTestTempFile("bulk-input")),
|
|
||||||
loadUsingSystemPrincipal: true
|
|
||||||
}, input => {
|
|
||||||
copyFrom(input).then(() => {
|
|
||||||
input.close();
|
|
||||||
bulkCopyDeferred.resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set up reply handling for this type
|
// Set up reply handling for this type
|
||||||
replyHandlers[replyType](request).then(() => {
|
replyHandlers[replyType](request).then(() => {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
var gPort;
|
var gPort;
|
||||||
var gExtraListener;
|
var gExtraListener;
|
||||||
|
|
||||||
function run_test()
|
function run_test() {
|
||||||
{
|
|
||||||
do_print("Starting test at " + new Date().toTimeString());
|
do_print("Starting test at " + new Date().toTimeString());
|
||||||
initTestDebuggerServer();
|
initTestDebuggerServer();
|
||||||
|
|
||||||
|
|
@ -16,8 +16,7 @@ function run_test()
|
||||||
run_next_test();
|
run_next_test();
|
||||||
}
|
}
|
||||||
|
|
||||||
function* test_socket_conn()
|
function* test_socket_conn() {
|
||||||
{
|
|
||||||
do_check_eq(DebuggerServer.listeningSockets, 0);
|
do_check_eq(DebuggerServer.listeningSockets, 0);
|
||||||
let AuthenticatorType = DebuggerServer.Authenticators.get("PROMPT");
|
let AuthenticatorType = DebuggerServer.Authenticators.get("PROMPT");
|
||||||
let authenticator = new AuthenticatorType.Server();
|
let authenticator = new AuthenticatorType.Server();
|
||||||
|
|
@ -53,9 +52,9 @@ function* test_socket_conn()
|
||||||
|
|
||||||
let closedDeferred = defer();
|
let closedDeferred = defer();
|
||||||
transport.hooks = {
|
transport.hooks = {
|
||||||
onPacket: function (aPacket) {
|
onPacket: function (packet) {
|
||||||
this.onPacket = function (aPacket) {
|
this.onPacket = function ({unicode}) {
|
||||||
do_check_eq(aPacket.unicode, unicodeString);
|
do_check_eq(unicode, unicodeString);
|
||||||
transport.close();
|
transport.close();
|
||||||
};
|
};
|
||||||
// Verify that things work correctly when bigger than the output
|
// Verify that things work correctly when bigger than the output
|
||||||
|
|
@ -64,9 +63,9 @@ function* test_socket_conn()
|
||||||
type: "echo",
|
type: "echo",
|
||||||
reallylong: really_long(),
|
reallylong: really_long(),
|
||||||
unicode: unicodeString});
|
unicode: unicodeString});
|
||||||
do_check_eq(aPacket.from, "root");
|
do_check_eq(packet.from, "root");
|
||||||
},
|
},
|
||||||
onClosed: function (aStatus) {
|
onClosed: function (status) {
|
||||||
closedDeferred.resolve();
|
closedDeferred.resolve();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -74,8 +73,7 @@ function* test_socket_conn()
|
||||||
return closedDeferred.promise;
|
return closedDeferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function* test_socket_shutdown()
|
function* test_socket_shutdown() {
|
||||||
{
|
|
||||||
do_check_eq(DebuggerServer.listeningSockets, 2);
|
do_check_eq(DebuggerServer.listeningSockets, 2);
|
||||||
gExtraListener.close();
|
gExtraListener.close();
|
||||||
do_check_eq(DebuggerServer.listeningSockets, 1);
|
do_check_eq(DebuggerServer.listeningSockets, 1);
|
||||||
|
|
@ -87,7 +85,7 @@ function* test_socket_shutdown()
|
||||||
|
|
||||||
do_print("Connecting to a server socket at " + new Date().toTimeString());
|
do_print("Connecting to a server socket at " + new Date().toTimeString());
|
||||||
try {
|
try {
|
||||||
let transport = yield DebuggerClient.socketConnect({
|
yield DebuggerClient.socketConnect({
|
||||||
host: "127.0.0.1",
|
host: "127.0.0.1",
|
||||||
port: gPort
|
port: gPort
|
||||||
});
|
});
|
||||||
|
|
@ -98,24 +96,22 @@ function* test_socket_shutdown()
|
||||||
// machines it may just time out.
|
// machines it may just time out.
|
||||||
do_check_true(true);
|
do_check_true(true);
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shouldn't reach this, should never connect.
|
// Shouldn't reach this, should never connect.
|
||||||
do_check_true(false);
|
do_check_true(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_pipe_conn()
|
function test_pipe_conn() {
|
||||||
{
|
|
||||||
let transport = DebuggerServer.connectPipe();
|
let transport = DebuggerServer.connectPipe();
|
||||||
transport.hooks = {
|
transport.hooks = {
|
||||||
onPacket: function (aPacket) {
|
onPacket: function (packet) {
|
||||||
do_check_eq(aPacket.from, "root");
|
do_check_eq(packet.from, "root");
|
||||||
transport.close();
|
transport.close();
|
||||||
},
|
},
|
||||||
onClosed: function (aStatus) {
|
onClosed: function (status) {
|
||||||
run_next_test();
|
run_next_test();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
* Bug 755412 - checks if the server drops the connection on an improperly
|
* Bug 755412 - checks if the server drops the connection on an improperly
|
||||||
* framed packet, i.e. when the length header is invalid.
|
* framed packet, i.e. when the length header is invalid.
|
||||||
*/
|
*/
|
||||||
|
"use strict";
|
||||||
|
|
||||||
const { RawPacket } = require("devtools/shared/transport/packets");
|
const { RawPacket } = require("devtools/shared/transport/packets");
|
||||||
|
|
||||||
|
|
@ -61,8 +62,8 @@ var test_helper = Task.async(function* (payload) {
|
||||||
});
|
});
|
||||||
let closedDeferred = defer();
|
let closedDeferred = defer();
|
||||||
transport.hooks = {
|
transport.hooks = {
|
||||||
onPacket: function (aPacket) {
|
onPacket: function (packet) {
|
||||||
this.onPacket = function (aPacket) {
|
this.onPacket = function () {
|
||||||
do_throw(new Error("This connection should be dropped."));
|
do_throw(new Error("This connection should be dropped."));
|
||||||
transport.close();
|
transport.close();
|
||||||
};
|
};
|
||||||
|
|
@ -71,7 +72,7 @@ var test_helper = Task.async(function* (payload) {
|
||||||
transport._outgoing.push(new RawPacket(transport, payload));
|
transport._outgoing.push(new RawPacket(transport, payload));
|
||||||
transport._flushOutgoing();
|
transport._flushOutgoing();
|
||||||
},
|
},
|
||||||
onClosed: function (aStatus) {
|
onClosed: function (status) {
|
||||||
do_check_true(true);
|
do_check_true(true);
|
||||||
closedDeferred.resolve();
|
closedDeferred.resolve();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
const StreamUtils = require("devtools/shared/transport/stream-utils");
|
const StreamUtils = require("devtools/shared/transport/stream-utils");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ function run_test() {
|
||||||
/** * Tests ***/
|
/** * Tests ***/
|
||||||
|
|
||||||
var test_bulk_send_error = Task.async(function* (transportFactory) {
|
var test_bulk_send_error = Task.async(function* (transportFactory) {
|
||||||
let deferred = defer();
|
|
||||||
let transport = yield transportFactory();
|
let transport = yield transportFactory();
|
||||||
|
|
||||||
let client = new DebuggerClient(transport);
|
let client = new DebuggerClient(transport);
|
||||||
|
|
@ -33,6 +32,5 @@ var test_bulk_send_error = Task.async(function* (transportFactory) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
do_check_true(true);
|
do_check_true(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
const { JSONPacket, BulkPacket } =
|
const { JSONPacket, BulkPacket } =
|
||||||
require("devtools/shared/transport/packets");
|
require("devtools/shared/transport/packets");
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,9 @@ var test_bulk_transfer_transport = Task.async(function* (transportFactory) {
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
transport.hooks = {
|
transport.hooks = {
|
||||||
onPacket: function (aPacket) {
|
onPacket: function (packet) {
|
||||||
// We've received the initial start up packet
|
// We've received the initial start up packet
|
||||||
do_check_eq(aPacket.from, "root");
|
do_check_eq(packet.from, "root");
|
||||||
|
|
||||||
// Server
|
// Server
|
||||||
do_check_eq(Object.keys(DebuggerServer._connections).length, 1);
|
do_check_eq(Object.keys(DebuggerServer._connections).length, 1);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
const { RootActor } = require("devtools/server/actors/root");
|
const { RootActor } = require("devtools/server/actors/root");
|
||||||
const { DebuggerServer } = require("devtools/server/main");
|
const { DebuggerServer } = require("devtools/server/main");
|
||||||
|
|
@ -7,8 +8,8 @@ const { DebuggerServer } = require("devtools/server/main");
|
||||||
/**
|
/**
|
||||||
* Root actor that doesn't have the bulk trait.
|
* Root actor that doesn't have the bulk trait.
|
||||||
*/
|
*/
|
||||||
function createRootActor(aConnection) {
|
function createRootActor(connection) {
|
||||||
let root = new RootActor(aConnection, {
|
let root = new RootActor(connection, {
|
||||||
globalActorFactories: DebuggerServer.globalActorFactories
|
globalActorFactories: DebuggerServer.globalActorFactories
|
||||||
});
|
});
|
||||||
root.applicationType = "xpcshell-tests";
|
root.applicationType = "xpcshell-tests";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
const { ActorPool, appendExtraActors, createExtraActors } =
|
const { ActorPool, appendExtraActors, createExtraActors } =
|
||||||
require("devtools/server/actors/common");
|
require("devtools/server/actors/common");
|
||||||
|
|
@ -9,8 +10,8 @@ const { DebuggerServer } = require("devtools/server/main");
|
||||||
const promise = require("promise");
|
const promise = require("promise");
|
||||||
|
|
||||||
var gTestGlobals = [];
|
var gTestGlobals = [];
|
||||||
DebuggerServer.addTestGlobal = function (aGlobal) {
|
DebuggerServer.addTestGlobal = function (global) {
|
||||||
gTestGlobals.push(aGlobal);
|
gTestGlobals.push(global);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A mock tab list, for use by tests. This simply presents each global in
|
// A mock tab list, for use by tests. This simply presents each global in
|
||||||
|
|
@ -20,18 +21,18 @@ DebuggerServer.addTestGlobal = function (aGlobal) {
|
||||||
// As implemented now, we consult gTestGlobals when we're constructed, not
|
// As implemented now, we consult gTestGlobals when we're constructed, not
|
||||||
// when we're iterated over, so tests have to add their globals before the
|
// when we're iterated over, so tests have to add their globals before the
|
||||||
// root actor is created.
|
// root actor is created.
|
||||||
function TestTabList(aConnection) {
|
function TestTabList(connection) {
|
||||||
this.conn = aConnection;
|
this.conn = connection;
|
||||||
|
|
||||||
// An array of actors for each global added with
|
// An array of actors for each global added with
|
||||||
// DebuggerServer.addTestGlobal.
|
// DebuggerServer.addTestGlobal.
|
||||||
this._tabActors = [];
|
this._tabActors = [];
|
||||||
|
|
||||||
// A pool mapping those actors' names to the actors.
|
// A pool mapping those actors' names to the actors.
|
||||||
this._tabActorPool = new ActorPool(aConnection);
|
this._tabActorPool = new ActorPool(connection);
|
||||||
|
|
||||||
for (let global of gTestGlobals) {
|
for (let global of gTestGlobals) {
|
||||||
let actor = new TestTabActor(aConnection, global);
|
let actor = new TestTabActor(connection, global);
|
||||||
actor.selected = false;
|
actor.selected = false;
|
||||||
this._tabActors.push(actor);
|
this._tabActors.push(actor);
|
||||||
this._tabActorPool.addActor(actor);
|
this._tabActorPool.addActor(actor);
|
||||||
|
|
@ -40,7 +41,7 @@ function TestTabList(aConnection) {
|
||||||
this._tabActors[0].selected = true;
|
this._tabActors[0].selected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
aConnection.addActorPool(this._tabActorPool);
|
connection.addActorPool(this._tabActorPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestTabList.prototype = {
|
TestTabList.prototype = {
|
||||||
|
|
@ -50,18 +51,18 @@ TestTabList.prototype = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function createRootActor(aConnection) {
|
function createRootActor(connection) {
|
||||||
let root = new RootActor(aConnection, {
|
let root = new RootActor(connection, {
|
||||||
tabList: new TestTabList(aConnection),
|
tabList: new TestTabList(connection),
|
||||||
globalActorFactories: DebuggerServer.globalActorFactories
|
globalActorFactories: DebuggerServer.globalActorFactories
|
||||||
});
|
});
|
||||||
root.applicationType = "xpcshell-tests";
|
root.applicationType = "xpcshell-tests";
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TestTabActor(aConnection, aGlobal) {
|
function TestTabActor(connection, global) {
|
||||||
this.conn = aConnection;
|
this.conn = connection;
|
||||||
this._global = aGlobal;
|
this._global = global;
|
||||||
this._threadActor = new ThreadActor(this, this._global);
|
this._threadActor = new ThreadActor(this, this._global);
|
||||||
this.conn.addActor(this._threadActor);
|
this.conn.addActor(this._threadActor);
|
||||||
this._attached = false;
|
this._attached = false;
|
||||||
|
|
@ -96,7 +97,7 @@ TestTabActor.prototype = {
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
|
|
||||||
onAttach: function (aRequest) {
|
onAttach: function (request) {
|
||||||
this._attached = true;
|
this._attached = true;
|
||||||
|
|
||||||
let response = { type: "tabAttached", threadActor: this._threadActor.actorID };
|
let response = { type: "tabAttached", threadActor: this._threadActor.actorID };
|
||||||
|
|
@ -105,9 +106,9 @@ TestTabActor.prototype = {
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
|
|
||||||
onDetach: function (aRequest) {
|
onDetach: function (request) {
|
||||||
if (!this._attached) {
|
if (!this._attached) {
|
||||||
return { "error":"wrongState" };
|
return { "error": "wrongState" };
|
||||||
}
|
}
|
||||||
return { type: "detached" };
|
return { type: "detached" };
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue