зеркало из https://github.com/mozilla/gecko-dev.git
merge m-c to fx-team
This commit is contained in:
Коммит
fc3315fbfe
|
@ -1103,6 +1103,8 @@ let RemoteDebugger = {
|
|||
DebuggerServer.registerModule("devtools/server/actors/inspector");
|
||||
DebuggerServer.registerModule("devtools/server/actors/styleeditor");
|
||||
DebuggerServer.registerModule("devtools/server/actors/stylesheets");
|
||||
DebuggerServer.registerModule("devtools/server/actors/tracer");
|
||||
DebuggerServer.registerModule("devtools/server/actors/webgl");
|
||||
}
|
||||
DebuggerServer.addActors('chrome://browser/content/dbg-browser-actors.js');
|
||||
DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/webapps.js");
|
||||
|
|
|
@ -235,7 +235,7 @@ let DebuggerController = {
|
|||
if (target.chrome) {
|
||||
this._startChromeDebugging(chromeDebugger, startedDebugging.resolve);
|
||||
} else {
|
||||
this._startDebuggingTab(threadActor, startedDebugging.resolve);
|
||||
this._startDebuggingTab(startedDebugging.resolve);
|
||||
const startedTracing = promise.defer();
|
||||
this._startTracingTab(traceActor, startedTracing.resolve);
|
||||
|
||||
|
@ -339,13 +339,13 @@ let DebuggerController = {
|
|||
/**
|
||||
* Sets up a debugging session.
|
||||
*
|
||||
* @param string aThreadActor
|
||||
* The remote protocol grip of the tab.
|
||||
* @param function aCallback
|
||||
* A function to invoke once the client attaches to the active thread.
|
||||
*/
|
||||
_startDebuggingTab: function(aThreadActor, aCallback) {
|
||||
this.client.attachThread(aThreadActor, (aResponse, aThreadClient) => {
|
||||
_startDebuggingTab: function(aCallback) {
|
||||
this._target.activeTab.attachThread({
|
||||
useSourceMaps: Prefs.sourceMapsEnabled
|
||||
}, (aResponse, aThreadClient) => {
|
||||
if (!aThreadClient) {
|
||||
Cu.reportError("Couldn't attach to thread: " + aResponse.error);
|
||||
return;
|
||||
|
@ -355,12 +355,14 @@ let DebuggerController = {
|
|||
this.ThreadState.connect();
|
||||
this.StackFrames.connect();
|
||||
this.SourceScripts.connect();
|
||||
if (aThreadClient.paused) {
|
||||
aThreadClient.resume(this._ensureResumptionOrder);
|
||||
}
|
||||
|
||||
if (aCallback) {
|
||||
aCallback();
|
||||
}
|
||||
}, { useSourceMaps: Prefs.sourceMapsEnabled });
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -382,7 +384,9 @@ let DebuggerController = {
|
|||
this.ThreadState.connect();
|
||||
this.StackFrames.connect();
|
||||
this.SourceScripts.connect();
|
||||
if (aThreadClient.paused) {
|
||||
aThreadClient.resume(this._ensureResumptionOrder);
|
||||
}
|
||||
|
||||
if (aCallback) {
|
||||
aCallback();
|
||||
|
@ -419,7 +423,7 @@ let DebuggerController = {
|
|||
* away old sources and get them again.
|
||||
*/
|
||||
reconfigureThread: function(aUseSourceMaps) {
|
||||
this.client.reconfigureThread({ useSourceMaps: aUseSourceMaps }, aResponse => {
|
||||
this.activeThread.reconfigure({ useSourceMaps: aUseSourceMaps }, aResponse => {
|
||||
if (aResponse.error) {
|
||||
let msg = "Couldn't reconfigure thread: " + aResponse.message;
|
||||
Cu.reportError(msg);
|
||||
|
@ -432,8 +436,10 @@ let DebuggerController = {
|
|||
this.SourceScripts.handleTabNavigation();
|
||||
|
||||
// Update the stack frame list.
|
||||
if (this.activeThread.paused) {
|
||||
this.activeThread._clearFrames();
|
||||
this.activeThread.fillFrames(CALL_STACK_PAGE_SIZE);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ function test() {
|
|||
is(gEvents.itemCount, 0, "There should be no events before reloading.");
|
||||
|
||||
let reloaded = waitForSourcesAfterReload();
|
||||
gDebugger.gClient.activeTab.reload();
|
||||
gDebugger.DebuggerController._target.activeTab.reload();
|
||||
|
||||
is(gEvents.itemCount, 0, "There should be no events while reloading.");
|
||||
yield reloaded;
|
||||
|
|
|
@ -47,7 +47,7 @@ function test() {
|
|||
|
||||
let reloading = once(gDebugger.gTarget, "will-navigate");
|
||||
let reloaded = waitForSourcesAfterReload();
|
||||
gDebugger.gClient.activeTab.reload();
|
||||
gDebugger.DebuggerController._target.activeTab.reload();
|
||||
|
||||
yield reloading;
|
||||
|
||||
|
@ -89,7 +89,7 @@ function test() {
|
|||
|
||||
let reloading = once(gDebugger.gTarget, "will-navigate");
|
||||
let reloaded = waitForSourcesAfterReload();
|
||||
gDebugger.gClient.activeTab.reload();
|
||||
gDebugger.DebuggerController._target.activeTab.reload();
|
||||
|
||||
yield reloading;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ function testBreakOnAll() {
|
|||
|
||||
// Test calling pauseOnDOMEvents from a paused state.
|
||||
gThreadClient.pauseOnDOMEvents("*", (aPacket) => {
|
||||
is(aPacket, undefined,
|
||||
is(aPacket.error, undefined,
|
||||
"The pause-on-any-event request completed successfully.");
|
||||
|
||||
gClient.addOneTimeListener("paused", (aEvent, aPacket) => {
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
const TAB_URL = EXAMPLE_URL + "doc_binary_search.html";
|
||||
const JS_URL = EXAMPLE_URL + "code_binary_search.js";
|
||||
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gEditor, gSources, gFrames, gPrefs, gOptions;
|
||||
let gDebuggee, gPanel, gDebugger, gEditor;
|
||||
let gSources, gFrames, gPrefs, gOptions;
|
||||
|
||||
function test() {
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
|
@ -26,7 +25,6 @@ function test() {
|
|||
waitForSourceShown(gPanel, ".coffee")
|
||||
.then(testToggleGeneratedSource)
|
||||
.then(testSetBreakpoint)
|
||||
.then(testHitBreakpoint)
|
||||
.then(testToggleOnPause)
|
||||
.then(testResume)
|
||||
.then(() => closeDebuggerAndFinish(gPanel))
|
||||
|
@ -68,19 +66,7 @@ function testSetBreakpoint() {
|
|||
ok(!aResponse.error,
|
||||
"Should be able to set a breakpoint in a js file.");
|
||||
|
||||
deferred.resolve();
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function testHitBreakpoint() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
gDebugger.gThreadClient.resume(aResponse => {
|
||||
ok(!aResponse.error, "Shouldn't get an error resuming.");
|
||||
is(aResponse.type, "resumed", "Type should be 'resumed'.");
|
||||
|
||||
gDebugger.gClient.addOneTimeListener("resumed", () => {
|
||||
waitForCaretAndScopes(gPanel, 7).then(() => {
|
||||
// Make sure that we have JavaScript stack frames.
|
||||
is(gFrames.itemCount, 1,
|
||||
|
@ -97,6 +83,7 @@ function testHitBreakpoint() {
|
|||
// paused state.
|
||||
gDebuggee.binary_search([0, 2, 3, 5, 7, 10], 5);
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
@ -148,7 +135,6 @@ function testResume() {
|
|||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
const TAB_URL = EXAMPLE_URL + "doc_minified.html";
|
||||
const JS_URL = EXAMPLE_URL + "code_math.js";
|
||||
|
||||
let gTab, gDebuggee, gPanel, gDebugger;
|
||||
let gDebuggee, gPanel, gDebugger;
|
||||
let gEditor, gSources, gFrames;
|
||||
|
||||
function test() {
|
||||
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
|
||||
gTab = aTab;
|
||||
gDebuggee = aDebuggee;
|
||||
gPanel = aPanel;
|
||||
gDebugger = gPanel.panelWin;
|
||||
|
@ -24,7 +23,6 @@ function test() {
|
|||
waitForSourceShown(gPanel, JS_URL)
|
||||
.then(checkInitialSource)
|
||||
.then(testSetBreakpoint)
|
||||
.then(testHitBreakpoint)
|
||||
.then(() => resumeDebuggerThenCloseAndFinish(gPanel))
|
||||
.then(null, aError => {
|
||||
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
|
||||
|
@ -45,27 +43,13 @@ function checkInitialSource() {
|
|||
function testSetBreakpoint() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
gDebugger.gThreadClient.interrupt(aResponse => {
|
||||
gDebugger.gThreadClient.setBreakpoint({ url: JS_URL, line: 30, column: 21 }, aResponse => {
|
||||
ok(!aResponse.error,
|
||||
"Should be able to set a breakpoint in a js file.");
|
||||
ok(!aResponse.actualLocation,
|
||||
"Should be able to set a breakpoint on line 30 and column 10.");
|
||||
|
||||
deferred.resolve();
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function testHitBreakpoint() {
|
||||
let deferred = promise.defer();
|
||||
|
||||
gDebugger.gThreadClient.resume(aResponse => {
|
||||
ok(!aResponse.error, "Shouldn't get an error resuming.");
|
||||
is(aResponse.type, "resumed", "Type should be 'resumed'.");
|
||||
|
||||
gDebugger.gClient.addOneTimeListener("resumed", () => {
|
||||
waitForCaretAndScopes(gPanel, 30).then(() => {
|
||||
// Make sure that we have the right stack frames.
|
||||
is(gFrames.itemCount, 9,
|
||||
|
@ -82,13 +66,12 @@ function testHitBreakpoint() {
|
|||
// paused state.
|
||||
gDebuggee.arithmetic();
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
gDebugger = null;
|
||||
|
|
|
@ -101,7 +101,7 @@ function testSetBreakpoint() {
|
|||
|
||||
function reloadPage() {
|
||||
let loaded = waitForSourceAndCaret(gPanel, ".js", 3);
|
||||
gDebugger.gClient.activeTab.reload();
|
||||
gDebugger.DebuggerController._target.activeTab.reload();
|
||||
return loaded.then(() => ok(true, "Page was reloaded and execution resumed."));
|
||||
}
|
||||
|
||||
|
|
|
@ -410,7 +410,7 @@ function ensureThreadClientState(aPanel, aState) {
|
|||
|
||||
function navigateActiveTabTo(aPanel, aUrl, aWaitForEventName, aEventRepeat) {
|
||||
let finished = waitForDebuggerEvents(aPanel, aWaitForEventName, aEventRepeat);
|
||||
let activeTab = aPanel.panelWin.gClient.activeTab;
|
||||
let activeTab = aPanel.panelWin.DebuggerController._target.activeTab;
|
||||
aUrl ? activeTab.navigateTo(aUrl) : activeTab.reload();
|
||||
return finished;
|
||||
}
|
||||
|
|
|
@ -284,6 +284,7 @@ TabTarget.prototype = {
|
|||
this._remote.reject("Unable to attach to the tab");
|
||||
return;
|
||||
}
|
||||
this.activeTab = aTabClient;
|
||||
this.threadActor = aResponse.threadActor;
|
||||
this._remote.resolve(null);
|
||||
});
|
||||
|
@ -444,11 +445,14 @@ TabTarget.prototype = {
|
|||
this._teardownListeners();
|
||||
}
|
||||
|
||||
let cleanupAndResolve = () => {
|
||||
this._cleanup();
|
||||
this._destroyer.resolve(null);
|
||||
};
|
||||
// If this target was not remoted, the promise will be resolved before the
|
||||
// function returns.
|
||||
if (this._tab && !this._client) {
|
||||
this._cleanup();
|
||||
this._destroyer.resolve(null);
|
||||
cleanupAndResolve();
|
||||
} else if (this._client) {
|
||||
// If, on the other hand, this target was remoted, the promise will be
|
||||
// resolved after the remote connection is closed.
|
||||
|
@ -457,15 +461,15 @@ TabTarget.prototype = {
|
|||
if (this.isLocalTab) {
|
||||
// We started with a local tab and created the client ourselves, so we
|
||||
// should close it.
|
||||
this._client.close(() => {
|
||||
this._cleanup();
|
||||
this._destroyer.resolve(null);
|
||||
});
|
||||
this._client.close(cleanupAndResolve);
|
||||
} else {
|
||||
// The client was handed to us, so we are not responsible for closing
|
||||
// it.
|
||||
this._cleanup();
|
||||
this._destroyer.resolve(null);
|
||||
// it. We just need to detach from the tab, if already attached.
|
||||
if (this.activeTab) {
|
||||
this.activeTab.detach(cleanupAndResolve);
|
||||
} else {
|
||||
cleanupAndResolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -481,6 +485,7 @@ TabTarget.prototype = {
|
|||
} else {
|
||||
promiseTargets.delete(this._form);
|
||||
}
|
||||
this.activeTab = null;
|
||||
this._client = null;
|
||||
this._tab = null;
|
||||
this._form = null;
|
||||
|
|
|
@ -212,7 +212,7 @@ OptionsPanel.prototype = {
|
|||
}.bind(menulist));
|
||||
}
|
||||
|
||||
this.target.client.attachTab(this.target.client.activeTab._actor, (response) => {
|
||||
this.target.client.attachTab(this.target.activeTab._actor, (response) => {
|
||||
this._origJavascriptEnabled = response.javascriptEnabled;
|
||||
this._origCacheEnabled = response.cacheEnabled;
|
||||
|
||||
|
@ -248,7 +248,7 @@ OptionsPanel.prototype = {
|
|||
"javascriptEnabled": !checked
|
||||
};
|
||||
|
||||
this.target.client.reconfigureTab(options);
|
||||
this.target.activeTab.reconfigure(options);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -264,7 +264,7 @@ OptionsPanel.prototype = {
|
|||
"cacheEnabled": !checked
|
||||
};
|
||||
|
||||
this.target.client.reconfigureTab(options);
|
||||
this.target.activeTab.reconfigure(options);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
|
@ -291,7 +291,7 @@ OptionsPanel.prototype = {
|
|||
"cacheEnabled": this._origCacheEnabled,
|
||||
"javascriptEnabled": this._origJavascriptEnabled
|
||||
};
|
||||
this.target.client.reconfigureTab(options, () => {
|
||||
this.target.activeTab.reconfigure(options, () => {
|
||||
this.toolbox = null;
|
||||
deferred.resolve();
|
||||
}, true);
|
||||
|
|
|
@ -1217,7 +1217,7 @@ Toolbox.prototype = {
|
|||
outstanding.push(panel.destroy());
|
||||
} catch (e) {
|
||||
// We don't want to stop here if any panel fail to close.
|
||||
console.error(e);
|
||||
console.error("Panel " + id + ":", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -229,12 +229,12 @@ function navigateInHistory(aTarget, aDirection, aWaitForTargetEvent = "navigate"
|
|||
}
|
||||
|
||||
function navigate(aTarget, aUrl, aWaitForTargetEvent = "navigate") {
|
||||
executeSoon(() => aTarget.client.activeTab.navigateTo(aUrl));
|
||||
executeSoon(() => aTarget.activeTab.navigateTo(aUrl));
|
||||
return once(aTarget, aWaitForTargetEvent);
|
||||
}
|
||||
|
||||
function reload(aTarget, aWaitForTargetEvent = "navigate") {
|
||||
executeSoon(() => aTarget.client.activeTab.reload());
|
||||
executeSoon(() => aTarget.activeTab.reload());
|
||||
return once(aTarget, aWaitForTargetEvent);
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,9 @@ BreadcrumbsWidget.prototype = {
|
|||
// Repeated calls to ensureElementIsVisible would interfere with each other
|
||||
// and may sometimes result in incorrect scroll positions.
|
||||
setNamedTimeout("breadcrumb-select", ENSURE_SELECTION_VISIBLE_DELAY, () => {
|
||||
if (this._list.ensureElementIsVisible) {
|
||||
this._list.ensureElementIsVisible(aElement);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -4866,6 +4866,34 @@
|
|||
"n_buckets": "1000",
|
||||
"description": "The time (in milliseconds) that it took to display a selected source to the user."
|
||||
},
|
||||
"DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": "10000",
|
||||
"n_buckets": "1000",
|
||||
"description": "The time (in milliseconds) that it took a 'reconfigure tab' request to go round trip."
|
||||
},
|
||||
"DEVTOOLS_DEBUGGER_RDP_REMOTE_RECONFIGURETAB_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": "10000",
|
||||
"n_buckets": "1000",
|
||||
"description": "The time (in milliseconds) that it took a 'reconfigure tab' request to go round trip."
|
||||
},
|
||||
"DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETHREAD_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": "10000",
|
||||
"n_buckets": "1000",
|
||||
"description": "The time (in milliseconds) that it took a 'reconfigure thread' request to go round trip."
|
||||
},
|
||||
"DEVTOOLS_DEBUGGER_RDP_REMOTE_RECONFIGURETHREAD_MS": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
"high": "10000",
|
||||
"n_buckets": "1000",
|
||||
"description": "The time (in milliseconds) that it took a 'reconfigure thread' request to go round trip."
|
||||
},
|
||||
"WEBRTC_ICE_SUCCESS_RATE": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "boolean",
|
||||
|
|
|
@ -234,9 +234,12 @@ this.DebuggerClient = function (aTransport)
|
|||
{
|
||||
this._transport = aTransport;
|
||||
this._transport.hooks = this;
|
||||
this._threadClients = {};
|
||||
this._tabClients = {};
|
||||
this._consoleClients = {};
|
||||
|
||||
// Map actor ID to client instance for each actor type.
|
||||
this._threadClients = new Map;
|
||||
this._tabClients = new Map;
|
||||
this._tracerClients = new Map;
|
||||
this._consoleClients = new Map;
|
||||
|
||||
this._pendingRequests = [];
|
||||
this._activeRequests = new Map;
|
||||
|
@ -281,7 +284,7 @@ this.DebuggerClient = function (aTransport)
|
|||
*/
|
||||
DebuggerClient.requester = function (aPacketSkeleton,
|
||||
{ telemetry, before, after }) {
|
||||
return function (...args) {
|
||||
return DevToolsUtils.makeInfallible(function (...args) {
|
||||
let histogram, startTime;
|
||||
if (telemetry) {
|
||||
let transportType = this._transport.onOutputStreamReady === undefined
|
||||
|
@ -311,7 +314,7 @@ DebuggerClient.requester = function (aPacketSkeleton,
|
|||
outgoingPacket = before.call(this, outgoingPacket);
|
||||
}
|
||||
|
||||
this.request(outgoingPacket, function (aResponse) {
|
||||
this.request(outgoingPacket, DevToolsUtils.makeInfallible(function (aResponse) {
|
||||
if (after) {
|
||||
let { from } = aResponse;
|
||||
aResponse = after.call(this, aResponse);
|
||||
|
@ -323,19 +326,15 @@ DebuggerClient.requester = function (aPacketSkeleton,
|
|||
// The callback is always the last parameter.
|
||||
let thisCallback = args[maxPosition + 1];
|
||||
if (thisCallback) {
|
||||
try {
|
||||
thisCallback(aResponse);
|
||||
} catch (e) {
|
||||
DevToolsUtils.reportException("DebuggerClient.requester callback", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (histogram) {
|
||||
histogram.add(+new Date - startTime);
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this), "DebuggerClient.requester request callback"));
|
||||
|
||||
};
|
||||
}, "DebuggerClient.requester");
|
||||
};
|
||||
|
||||
function args(aPos) {
|
||||
|
@ -390,43 +389,35 @@ DebuggerClient.prototype = {
|
|||
});
|
||||
}
|
||||
|
||||
// In this function, we're using the hoisting behavior of nested
|
||||
// function definitions to write the code in the order it will actually
|
||||
// execute. So converting to arrow functions to get rid of 'self' would
|
||||
// be unhelpful here.
|
||||
let self = this;
|
||||
const detachClients = (clientMap, next) => {
|
||||
const clients = clientMap.values();
|
||||
const total = clientMap.size;
|
||||
let numFinished = 0;
|
||||
|
||||
let continuation = function () {
|
||||
self._consoleClients = {};
|
||||
detachThread();
|
||||
if (total == 0) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
|
||||
for each (let client in this._consoleClients) {
|
||||
continuation = client.close.bind(client, continuation);
|
||||
for (let client of clients) {
|
||||
let method = client instanceof WebConsoleClient ? "close" : "detach";
|
||||
client[method](() => {
|
||||
if (++numFinished === total) {
|
||||
clientMap.clear();
|
||||
next();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
continuation();
|
||||
|
||||
function detachThread() {
|
||||
if (self.activeThread) {
|
||||
self.activeThread.detach(detachTab);
|
||||
} else {
|
||||
detachTab();
|
||||
}
|
||||
}
|
||||
|
||||
function detachTab() {
|
||||
if (self.activeTab) {
|
||||
self.activeTab.detach(closeTransport);
|
||||
} else {
|
||||
closeTransport();
|
||||
}
|
||||
}
|
||||
|
||||
function closeTransport() {
|
||||
self._transport.close();
|
||||
self._transport = null;
|
||||
}
|
||||
detachClients(this._consoleClients, () => {
|
||||
detachClients(this._threadClients, () => {
|
||||
detachClients(this._tabClients, () => {
|
||||
this._transport.close();
|
||||
this._transport = null;
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/*
|
||||
|
@ -451,6 +442,16 @@ DebuggerClient.prototype = {
|
|||
* (which will be undefined on error).
|
||||
*/
|
||||
attachTab: function (aTabActor, aOnResponse) {
|
||||
if (this._tabClients.has(aTabActor)) {
|
||||
let cachedTab = this._tabClients.get(aTabActor);
|
||||
let cachedResponse = {
|
||||
cacheEnabled: cachedTab.cacheEnabled,
|
||||
javascriptEnabled: cachedTab.javascriptEnabled
|
||||
};
|
||||
setTimeout(() => aOnResponse(cachedResponse, cachedTab), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
let packet = {
|
||||
to: aTabActor,
|
||||
type: "attach"
|
||||
|
@ -458,9 +459,8 @@ DebuggerClient.prototype = {
|
|||
this.request(packet, (aResponse) => {
|
||||
let tabClient;
|
||||
if (!aResponse.error) {
|
||||
tabClient = new TabClient(this, aTabActor);
|
||||
this._tabClients[aTabActor] = tabClient;
|
||||
this.activeTab = tabClient;
|
||||
tabClient = new TabClient(this, aResponse);
|
||||
this._tabClients.set(aTabActor, tabClient);
|
||||
}
|
||||
aOnResponse(aResponse, tabClient);
|
||||
});
|
||||
|
@ -479,6 +479,11 @@ DebuggerClient.prototype = {
|
|||
*/
|
||||
attachConsole:
|
||||
function (aConsoleActor, aListeners, aOnResponse) {
|
||||
if (this._consoleClients.has(aConsoleActor)) {
|
||||
setTimeout(() => aOnResponse({}, this._consoleClients.get(aConsoleActor)), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
let packet = {
|
||||
to: aConsoleActor,
|
||||
type: "startListeners",
|
||||
|
@ -489,14 +494,14 @@ DebuggerClient.prototype = {
|
|||
let consoleClient;
|
||||
if (!aResponse.error) {
|
||||
consoleClient = new WebConsoleClient(this, aConsoleActor);
|
||||
this._consoleClients[aConsoleActor] = consoleClient;
|
||||
this._consoleClients.set(aConsoleActor, consoleClient);
|
||||
}
|
||||
aOnResponse(aResponse, consoleClient);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Attach to a thread actor.
|
||||
* Attach to a global-scoped thread actor for chrome debugging.
|
||||
*
|
||||
* @param string aThreadActor
|
||||
* The actor ID for the thread to attach.
|
||||
|
@ -508,6 +513,11 @@ DebuggerClient.prototype = {
|
|||
* - useSourceMaps: whether to use source maps or not.
|
||||
*/
|
||||
attachThread: function (aThreadActor, aOnResponse, aOptions={}) {
|
||||
if (this._threadClients.has(aThreadActor)) {
|
||||
setTimeout(() => aOnResponse({}, this._threadClients.get(aThreadActor)), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
let packet = {
|
||||
to: aThreadActor,
|
||||
type: "attach",
|
||||
|
@ -516,8 +526,7 @@ DebuggerClient.prototype = {
|
|||
this.request(packet, (aResponse) => {
|
||||
if (!aResponse.error) {
|
||||
var threadClient = new ThreadClient(this, aThreadActor);
|
||||
this._threadClients[aThreadActor] = threadClient;
|
||||
this.activeThread = threadClient;
|
||||
this._threadClients.set(aThreadActor, threadClient);
|
||||
}
|
||||
aOnResponse(aResponse, threadClient);
|
||||
});
|
||||
|
@ -533,52 +542,24 @@ DebuggerClient.prototype = {
|
|||
* (which will be undefined on error).
|
||||
*/
|
||||
attachTracer: function (aTraceActor, aOnResponse) {
|
||||
if (this._tracerClients.has(aTraceActor)) {
|
||||
setTimeout(() => aOnResponse({}, this._tracerClients.get(aTraceActor)), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
let packet = {
|
||||
to: aTraceActor,
|
||||
type: "attach"
|
||||
};
|
||||
this.request(packet, (aResponse) => {
|
||||
if (!aResponse.error) {
|
||||
let traceClient = new TraceClient(this, aTraceActor);
|
||||
aOnResponse(aResponse, traceClient);
|
||||
var traceClient = new TraceClient(this, aTraceActor);
|
||||
this._tracerClients.set(aTraceActor, traceClient);
|
||||
}
|
||||
aOnResponse(aResponse, traceClient);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Reconfigure a thread actor.
|
||||
*
|
||||
* @param object aOptions
|
||||
* A dictionary object of the new options to use in the thread actor.
|
||||
* @param function aOnResponse
|
||||
* Called with the response packet.
|
||||
*/
|
||||
reconfigureThread: function (aOptions, aOnResponse) {
|
||||
let packet = {
|
||||
to: this.activeThread._actor,
|
||||
type: "reconfigure",
|
||||
options: aOptions
|
||||
};
|
||||
this.request(packet, aOnResponse);
|
||||
},
|
||||
|
||||
/**
|
||||
* Reconfigure a tab actor.
|
||||
*
|
||||
* @param object aOptions
|
||||
* A dictionary object of the new options to use in the tab actor.
|
||||
* @param function aOnResponse
|
||||
* Called with the response packet.
|
||||
*/
|
||||
reconfigureTab: function (aOptions, aOnResponse) {
|
||||
let packet = {
|
||||
to: this.activeTab._actor,
|
||||
type: "reconfigure",
|
||||
options: aOptions
|
||||
};
|
||||
this.request(packet, aOnResponse);
|
||||
},
|
||||
|
||||
/**
|
||||
* Release an object actor.
|
||||
*
|
||||
|
@ -697,17 +678,18 @@ DebuggerClient.prototype = {
|
|||
|
||||
// Packets that indicate thread state changes get special treatment.
|
||||
if (aPacket.type in ThreadStateTypes &&
|
||||
aPacket.from in this._threadClients) {
|
||||
this._threadClients[aPacket.from]._onThreadState(aPacket);
|
||||
this._threadClients.has(aPacket.from)) {
|
||||
this._threadClients.get(aPacket.from)._onThreadState(aPacket);
|
||||
}
|
||||
// On navigation the server resumes, so the client must resume as well.
|
||||
// We achieve that by generating a fake resumption packet that triggers
|
||||
// the client's thread state change listeners.
|
||||
if (this.activeThread &&
|
||||
aPacket.type == UnsolicitedNotifications.tabNavigated &&
|
||||
aPacket.from in this._tabClients) {
|
||||
let resumption = { from: this.activeThread._actor, type: "resumed" };
|
||||
this.activeThread._onThreadState(resumption);
|
||||
if (aPacket.type == UnsolicitedNotifications.tabNavigated &&
|
||||
this._tabClients.has(aPacket.from) &&
|
||||
this._tabClients.get(aPacket.from).thread) {
|
||||
let thread = this._tabClients.get(aPacket.from).thread;
|
||||
let resumption = { from: thread._actor, type: "resumed" };
|
||||
thread._onThreadState(resumption);
|
||||
}
|
||||
// Only try to notify listeners on events, not responses to requests
|
||||
// that lack a packet type.
|
||||
|
@ -959,18 +941,52 @@ SSProto.translatePacket = function (aPacket, aReplacePacket, aExtraPacket,
|
|||
*
|
||||
* @param aClient DebuggerClient
|
||||
* The debugger client parent.
|
||||
* @param aActor string
|
||||
* The actor ID for this tab.
|
||||
* @param aForm object
|
||||
* The protocol form for this tab.
|
||||
*/
|
||||
function TabClient(aClient, aActor) {
|
||||
this._client = aClient;
|
||||
this._actor = aActor;
|
||||
this.request = this._client.request;
|
||||
function TabClient(aClient, aForm) {
|
||||
this.client = aClient;
|
||||
this._actor = aForm.from;
|
||||
this._threadActor = aForm.threadActor;
|
||||
this.javascriptEnabled = aForm.javascriptEnabled;
|
||||
this.cacheEnabled = aForm.cacheEnabled;
|
||||
this.thread = null;
|
||||
this.request = this.client.request;
|
||||
}
|
||||
|
||||
TabClient.prototype = {
|
||||
get actor() { return this._actor },
|
||||
get _transport() { return this._client._transport; },
|
||||
get _transport() { return this.client._transport; },
|
||||
|
||||
/**
|
||||
* Attach to a thread actor.
|
||||
*
|
||||
* @param object aOptions
|
||||
* Configuration options.
|
||||
* - useSourceMaps: whether to use source maps or not.
|
||||
* @param function aOnResponse
|
||||
* Called with the response packet and a ThreadClient
|
||||
* (which will be undefined on error).
|
||||
*/
|
||||
attachThread: function(aOptions={}, aOnResponse) {
|
||||
if (this.thread) {
|
||||
setTimeout(() => aOnResponse({}, this.thread), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
let packet = {
|
||||
to: this._threadActor,
|
||||
type: "attach",
|
||||
options: aOptions
|
||||
};
|
||||
this.request(packet, (aResponse) => {
|
||||
if (!aResponse.error) {
|
||||
this.thread = new ThreadClient(this, this._threadActor);
|
||||
this.client._threadClients.set(this._threadActor, this.thread);
|
||||
}
|
||||
aOnResponse(aResponse, this.thread);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Detach the client from the tab actor.
|
||||
|
@ -981,11 +997,14 @@ TabClient.prototype = {
|
|||
detach: DebuggerClient.requester({
|
||||
type: "detach"
|
||||
}, {
|
||||
after: function (aResponse) {
|
||||
if (this.activeTab === this._client._tabClients[this.actor]) {
|
||||
this.activeTab = undefined;
|
||||
before: function (aPacket) {
|
||||
if (this.thread) {
|
||||
this.thread.detach();
|
||||
}
|
||||
delete this._client._tabClients[this.actor];
|
||||
return aPacket;
|
||||
},
|
||||
after: function (aResponse) {
|
||||
this.client._tabClients.delete(this.actor);
|
||||
return aResponse;
|
||||
},
|
||||
telemetry: "TABDETACH"
|
||||
|
@ -1012,6 +1031,21 @@ TabClient.prototype = {
|
|||
}, {
|
||||
telemetry: "NAVIGATETO"
|
||||
}),
|
||||
|
||||
/**
|
||||
* Reconfigure the tab actor.
|
||||
*
|
||||
* @param object aOptions
|
||||
* A dictionary object of the new options to use in the tab actor.
|
||||
* @param function aOnResponse
|
||||
* Called with the response packet.
|
||||
*/
|
||||
reconfigure: DebuggerClient.requester({
|
||||
type: "reconfigure",
|
||||
options: args(0)
|
||||
}, {
|
||||
telemetry: "RECONFIGURETAB"
|
||||
}),
|
||||
};
|
||||
|
||||
eventSource(TabClient.prototype);
|
||||
|
@ -1077,19 +1111,21 @@ RootClient.prototype = {
|
|||
* is a front to the thread actor created in the server side, hiding the
|
||||
* protocol details in a traditional JavaScript API.
|
||||
*
|
||||
* @param aClient DebuggerClient
|
||||
* The debugger client parent.
|
||||
* @param aClient DebuggerClient|TabClient
|
||||
* The parent of the thread (tab for tab-scoped debuggers, DebuggerClient
|
||||
* for chrome debuggers).
|
||||
* @param aActor string
|
||||
* The actor ID for this thread.
|
||||
*/
|
||||
function ThreadClient(aClient, aActor) {
|
||||
this._client = aClient;
|
||||
this._parent = aClient;
|
||||
this.client = aClient instanceof DebuggerClient ? aClient : aClient.client;
|
||||
this._actor = aActor;
|
||||
this._frameCache = [];
|
||||
this._scriptCache = {};
|
||||
this._pauseGrips = {};
|
||||
this._threadGrips = {};
|
||||
this.request = this._client.request;
|
||||
this.request = this.client.request;
|
||||
}
|
||||
|
||||
ThreadClient.prototype = {
|
||||
|
@ -1104,12 +1140,12 @@ ThreadClient.prototype = {
|
|||
_actor: null,
|
||||
get actor() { return this._actor; },
|
||||
|
||||
get compat() { return this._client.compat; },
|
||||
get _transport() { return this._client._transport; },
|
||||
get compat() { return this.client.compat; },
|
||||
get _transport() { return this.client._transport; },
|
||||
|
||||
_assertPaused: function (aCommand) {
|
||||
if (!this.paused) {
|
||||
throw Error(aCommand + " command sent while not paused.");
|
||||
throw Error(aCommand + " command sent while not paused. Currently " + this._state);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1156,6 +1192,21 @@ ThreadClient.prototype = {
|
|||
telemetry: "RESUME"
|
||||
}),
|
||||
|
||||
/**
|
||||
* Reconfigure the thread actor.
|
||||
*
|
||||
* @param object aOptions
|
||||
* A dictionary object of the new options to use in the thread actor.
|
||||
* @param function aOnResponse
|
||||
* Called with the response packet.
|
||||
*/
|
||||
reconfigure: DebuggerClient.requester({
|
||||
type: "reconfigure",
|
||||
options: args(0)
|
||||
}, {
|
||||
telemetry: "RECONFIGURETHREAD"
|
||||
}),
|
||||
|
||||
/**
|
||||
* Resume a paused thread.
|
||||
*/
|
||||
|
@ -1222,7 +1273,7 @@ ThreadClient.prototype = {
|
|||
// If the debuggee is paused, we have to send the flag via a reconfigure
|
||||
// request.
|
||||
if (this.paused) {
|
||||
this._client.reconfigureThread({
|
||||
this.reconfigure({
|
||||
pauseOnExceptions: aPauseOnExceptions,
|
||||
ignoreCaughtExceptions: aIgnoreCaughtExceptions
|
||||
}, aOnResponse);
|
||||
|
@ -1256,12 +1307,16 @@ ThreadClient.prototype = {
|
|||
// If the debuggee is paused, the value of the array will be communicated in
|
||||
// the next resumption. Otherwise we have to force a pause in order to send
|
||||
// the array.
|
||||
if (this.paused)
|
||||
return void setTimeout(onResponse, 0);
|
||||
if (this.paused) {
|
||||
setTimeout(() => onResponse({}), 0);
|
||||
return;
|
||||
}
|
||||
this.interrupt(response => {
|
||||
// Can't continue if pausing failed.
|
||||
if (response.error)
|
||||
return void onResponse(response);
|
||||
if (response.error) {
|
||||
onResponse(response);
|
||||
return;
|
||||
}
|
||||
this.resume(onResponse);
|
||||
});
|
||||
},
|
||||
|
@ -1310,10 +1365,8 @@ ThreadClient.prototype = {
|
|||
type: "detach"
|
||||
}, {
|
||||
after: function (aResponse) {
|
||||
if (this.activeThread === this._client._threadClients[this.actor]) {
|
||||
this.activeThread = null;
|
||||
}
|
||||
delete this._client._threadClients[this.actor];
|
||||
this.client._threadClients.delete(this.actor);
|
||||
this._parent.thread = null;
|
||||
return aResponse;
|
||||
},
|
||||
telemetry: "THREADDETACH"
|
||||
|
@ -1332,11 +1385,11 @@ ThreadClient.prototype = {
|
|||
let doSetBreakpoint = function (aCallback) {
|
||||
let packet = { to: this._actor, type: "setBreakpoint",
|
||||
location: aLocation };
|
||||
this._client.request(packet, function (aResponse) {
|
||||
this.client.request(packet, function (aResponse) {
|
||||
// Ignoring errors, since the user may be setting a breakpoint in a
|
||||
// dead script that will reappear on a page reload.
|
||||
if (aOnResponse) {
|
||||
let bpClient = new BreakpointClient(this._client, aResponse.actor,
|
||||
let bpClient = new BreakpointClient(this.client, aResponse.actor,
|
||||
aLocation);
|
||||
if (aCallback) {
|
||||
aCallback(aOnResponse(aResponse, bpClient));
|
||||
|
@ -1570,7 +1623,7 @@ ThreadClient.prototype = {
|
|||
return this._pauseGrips[aGrip.actor];
|
||||
}
|
||||
|
||||
let client = new ObjectClient(this._client, aGrip);
|
||||
let client = new ObjectClient(this.client, aGrip);
|
||||
this._pauseGrips[aGrip.actor] = client;
|
||||
return client;
|
||||
},
|
||||
|
@ -1590,7 +1643,7 @@ ThreadClient.prototype = {
|
|||
return this[aGripCacheName][aGrip.actor];
|
||||
}
|
||||
|
||||
let client = new LongStringClient(this._client, aGrip);
|
||||
let client = new LongStringClient(this.client, aGrip);
|
||||
this[aGripCacheName][aGrip.actor] = client;
|
||||
return client;
|
||||
},
|
||||
|
@ -1655,14 +1708,14 @@ ThreadClient.prototype = {
|
|||
this._clearFrames();
|
||||
this._clearPauseGrips();
|
||||
aPacket.type === ThreadStateTypes.detached && this._clearThreadGrips();
|
||||
this._client._eventsEnabled && this.notify(aPacket.type, aPacket);
|
||||
this.client._eventsEnabled && this.notify(aPacket.type, aPacket);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return an EnvironmentClient instance for the given environment actor form.
|
||||
*/
|
||||
environment: function (aForm) {
|
||||
return new EnvironmentClient(this._client, aForm);
|
||||
return new EnvironmentClient(this.client, aForm);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1673,8 +1726,7 @@ ThreadClient.prototype = {
|
|||
return this._threadGrips[aForm.actor];
|
||||
}
|
||||
|
||||
return this._threadGrips[aForm.actor] = new SourceClient(this._client,
|
||||
aForm);
|
||||
return this._threadGrips[aForm.actor] = new SourceClient(this, aForm);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1724,8 +1776,15 @@ TraceClient.prototype = {
|
|||
/**
|
||||
* Detach from the trace actor.
|
||||
*/
|
||||
detach: DebuggerClient.requester({ type: "detach" },
|
||||
{ telemetry: "TRACERDETACH" }),
|
||||
detach: DebuggerClient.requester({
|
||||
type: "detach"
|
||||
}, {
|
||||
after: function (aResponse) {
|
||||
this._client._tracerClients.delete(this.actor);
|
||||
return aResponse;
|
||||
},
|
||||
telemetry: "TRACERDETACH"
|
||||
}),
|
||||
|
||||
/**
|
||||
* Start a new trace.
|
||||
|
@ -1964,8 +2023,8 @@ LongStringClient.prototype = {
|
|||
/**
|
||||
* A SourceClient provides a way to access the source text of a script.
|
||||
*
|
||||
* @param aClient DebuggerClient
|
||||
* The debugger client parent.
|
||||
* @param aClient ThreadClient
|
||||
* The thread client parent.
|
||||
* @param aForm Object
|
||||
* The form sent across the remote debugging protocol.
|
||||
*/
|
||||
|
@ -1973,12 +2032,12 @@ function SourceClient(aClient, aForm) {
|
|||
this._form = aForm;
|
||||
this._isBlackBoxed = aForm.isBlackBoxed;
|
||||
this._isPrettyPrinted = aForm.isPrettyPrinted;
|
||||
this._client = aClient;
|
||||
this._activeThread = aClient;
|
||||
this._client = aClient.client;
|
||||
}
|
||||
|
||||
SourceClient.prototype = {
|
||||
get _transport() this._client._transport,
|
||||
get _activeThread() this._client.activeThread,
|
||||
get isBlackBoxed() this._isBlackBoxed,
|
||||
get isPrettyPrinted() this._isPrettyPrinted,
|
||||
get actor() this._form.actor,
|
||||
|
@ -2089,8 +2148,7 @@ SourceClient.prototype = {
|
|||
}
|
||||
|
||||
let { contentType, source } = aResponse;
|
||||
let longString = this._client.activeThread.threadLongString(
|
||||
source);
|
||||
let longString = this._activeThread.threadLongString(source);
|
||||
longString.substring(0, longString.length, function (aResponse) {
|
||||
if (aResponse.error) {
|
||||
aCallback(aResponse);
|
||||
|
|
|
@ -655,8 +655,6 @@ ThreadActor.prototype = {
|
|||
this.onResume();
|
||||
}
|
||||
|
||||
this._state = "exited";
|
||||
|
||||
this.clearDebuggees();
|
||||
this.conn.removeActorPool(this._threadLifetimePool);
|
||||
this._threadLifetimePool = null;
|
||||
|
@ -682,6 +680,7 @@ ThreadActor.prototype = {
|
|||
*/
|
||||
exit: function () {
|
||||
this.disconnect();
|
||||
this._state = "exited";
|
||||
},
|
||||
|
||||
// Request handlers
|
||||
|
@ -691,7 +690,8 @@ ThreadActor.prototype = {
|
|||
}
|
||||
|
||||
if (this.state !== "detached") {
|
||||
return { error: "wrongState" };
|
||||
return { error: "wrongState",
|
||||
message: "Current state is " + this.state };
|
||||
}
|
||||
|
||||
this._state = "attached";
|
||||
|
@ -741,6 +741,8 @@ ThreadActor.prototype = {
|
|||
|
||||
onDetach: function (aRequest) {
|
||||
this.disconnect();
|
||||
this._state = "detached";
|
||||
|
||||
dumpn("ThreadActor.prototype.onDetach: returning 'detached' packet");
|
||||
return {
|
||||
type: "detached"
|
||||
|
|
|
@ -677,7 +677,7 @@ WebappsActor.prototype = {
|
|||
} catch(e) {
|
||||
deferred.resolve({
|
||||
error: "noIcon",
|
||||
message: "The icon file '" + iconURL + "' doesn't exists"
|
||||
message: "The icon file '" + iconURL + "' doesn't exist"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -890,27 +890,25 @@ BrowserTabActor.prototype = {
|
|||
*/
|
||||
onWindowCreated:
|
||||
makeInfallible(function BTA_onWindowCreated(evt) {
|
||||
if (evt.target === this.browser.contentDocument) {
|
||||
// pageshow events for non-persisted pages have already been handled by a
|
||||
// prior DOMWindowCreated event.
|
||||
if (evt.type == "pageshow" && !evt.persisted) {
|
||||
if (!this._attached || (evt.type == "pageshow" && !evt.persisted)) {
|
||||
return;
|
||||
}
|
||||
if (this._attached) {
|
||||
if (evt.target === this.browser.contentDocument ) {
|
||||
this.threadActor.clearDebuggees();
|
||||
if (this.threadActor.dbg) {
|
||||
this.threadActor.dbg.enabled = true;
|
||||
this.threadActor.global = evt.target.defaultView.wrappedJSObject;
|
||||
this.threadActor.maybePauseOnExceptions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this._attached) {
|
||||
this.threadActor.global = evt.target.defaultView.wrappedJSObject;
|
||||
// Refresh the debuggee list when a new window object appears (top window or
|
||||
// iframe).
|
||||
if (this.threadActor.attached) {
|
||||
this.threadActor.findGlobals();
|
||||
}
|
||||
}
|
||||
}, "BrowserTabActor.prototype.onWindowCreated"),
|
||||
|
||||
/**
|
||||
|
|
|
@ -376,6 +376,7 @@ var DebuggerServer = {
|
|||
this.registerModule("devtools/server/actors/webgl");
|
||||
this.registerModule("devtools/server/actors/stylesheets");
|
||||
this.registerModule("devtools/server/actors/styleeditor");
|
||||
this.registerModule("devtools/server/actors/tracer");
|
||||
}
|
||||
if (!("ContentAppActor" in DebuggerServer)) {
|
||||
this.addActors("resource://gre/modules/devtools/server/actors/childtab.js");
|
||||
|
|
|
@ -154,9 +154,10 @@ function attachTestTab(aClient, aTitle, aCallback) {
|
|||
// thread.
|
||||
function attachTestThread(aClient, aTitle, aCallback) {
|
||||
attachTestTab(aClient, aTitle, function (aResponse, aTabClient) {
|
||||
aClient.attachThread(aResponse.threadActor, function (aResponse, aThreadClient) {
|
||||
function onAttach(aResponse, aThreadClient) {
|
||||
aCallback(aResponse, aTabClient, aThreadClient);
|
||||
}, { useSourceMaps: true });
|
||||
}
|
||||
aTabClient.attachThread({ useSourceMaps: true }, onAttach);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -14,15 +14,15 @@ function run_test()
|
|||
gClient = new DebuggerClient(transport);
|
||||
gClient.connect(function(aType, aTraits) {
|
||||
attachTestTab(gClient, "test-1", function(aReply, aTabClient) {
|
||||
test_attach(aReply.threadActor);
|
||||
test_attach(aTabClient);
|
||||
});
|
||||
});
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
function test_attach(aThreadActorID)
|
||||
function test_attach(aTabClient)
|
||||
{
|
||||
gClient.attachThread(aThreadActorID, function(aResponse, aThreadClient) {
|
||||
aTabClient.attachThread({}, function(aResponse, aThreadClient) {
|
||||
do_check_eq(aThreadClient.state, "paused");
|
||||
aThreadClient.resume(cleanup);
|
||||
});
|
||||
|
|
|
@ -43,12 +43,12 @@ function setUpCode() {
|
|||
}
|
||||
|
||||
function setBreakpoint() {
|
||||
gClient.addOneTimeListener("resumed", runCode);
|
||||
gThreadClient.setBreakpoint({
|
||||
url: URL,
|
||||
line: 1
|
||||
}, ({ error }) => {
|
||||
do_check_true(!error);
|
||||
gThreadClient.resume(runCode);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ Cu.import("resource://gre/modules/devtools/dbg-server.jsm");
|
|||
Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
|
||||
|
||||
var gClient;
|
||||
var gTabClient;
|
||||
var gDebuggee;
|
||||
|
||||
function run_test()
|
||||
|
@ -17,6 +18,7 @@ function run_test()
|
|||
gClient = new DebuggerClient(transport);
|
||||
gClient.connect(function(aType, aTraits) {
|
||||
attachTestTab(gClient, "test-1", function(aReply, aTabClient) {
|
||||
gTabClient = aTabClient;
|
||||
test_threadAttach(aReply.threadActor);
|
||||
});
|
||||
});
|
||||
|
@ -26,7 +28,7 @@ function run_test()
|
|||
function test_threadAttach(aThreadActorID)
|
||||
{
|
||||
do_print("Trying to attach to thread " + aThreadActorID);
|
||||
gClient.attachThread(aThreadActorID, function(aResponse, aThreadClient) {
|
||||
gTabClient.attachThread({}, function(aResponse, aThreadClient) {
|
||||
do_check_eq(aThreadClient.state, "paused");
|
||||
do_check_eq(aThreadClient.actor, aThreadActorID);
|
||||
aThreadClient.resume(function() {
|
||||
|
|
|
@ -20,21 +20,21 @@ function run_test()
|
|||
|
||||
function test_attach(aResponse, aTabClient)
|
||||
{
|
||||
gClient.attachThread(aResponse.threadActor, function(aResponse, aThreadClient) {
|
||||
aTabClient.attachThread({}, function(aResponse, aThreadClient) {
|
||||
do_check_eq(aThreadClient.paused, true);
|
||||
aThreadClient.resume(function() {
|
||||
test_interrupt();
|
||||
test_interrupt(aThreadClient);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function test_interrupt()
|
||||
function test_interrupt(aThreadClient)
|
||||
{
|
||||
do_check_eq(gClient.activeThread.paused, false);
|
||||
gClient.activeThread.interrupt(function(aResponse) {
|
||||
do_check_eq(gClient.activeThread.paused, true);
|
||||
gClient.activeThread.resume(function() {
|
||||
do_check_eq(gClient.activeThread.paused, false);
|
||||
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);
|
||||
cleanup();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Test that we can detect nested event loops in tabs with the same URL.
|
||||
|
||||
const { defer } = devtools.require("sdk/core/promise");
|
||||
var gClient1, gClient2;
|
||||
var gClient1, gClient2, gThreadClient1, gThreadClient2;
|
||||
|
||||
function run_test() {
|
||||
initTestDebuggerServer();
|
||||
|
@ -15,6 +15,7 @@ function run_test() {
|
|||
gClient1 = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
gClient1.connect(function () {
|
||||
attachTestThread(gClient1, "test-nesting1", function (aResponse, aTabClient, aThreadClient) {
|
||||
gThreadClient1 = aThreadClient;
|
||||
start_second_connection();
|
||||
});
|
||||
});
|
||||
|
@ -25,6 +26,7 @@ function start_second_connection() {
|
|||
gClient2 = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
gClient2.connect(function () {
|
||||
attachTestThread(gClient2, "test-nesting1", function (aResponse, aTabClient, aThreadClient) {
|
||||
gThreadClient2 = aThreadClient;
|
||||
test_nesting();
|
||||
});
|
||||
});
|
||||
|
@ -33,15 +35,15 @@ function start_second_connection() {
|
|||
function test_nesting() {
|
||||
const { resolve, reject, promise } = defer();
|
||||
|
||||
gClient1.activeThread.resume(aResponse => {
|
||||
gThreadClient1.resume(aResponse => {
|
||||
do_check_eq(aResponse.error, "wrongOrder");
|
||||
gClient2.activeThread.resume(aResponse => {
|
||||
gThreadClient2.resume(aResponse => {
|
||||
do_check_true(!aResponse.error);
|
||||
do_check_eq(aResponse.from, gClient2.activeThread.actor);
|
||||
do_check_eq(aResponse.from, gThreadClient2.actor);
|
||||
|
||||
gClient1.activeThread.resume(aResponse => {
|
||||
gThreadClient1.resume(aResponse => {
|
||||
do_check_true(!aResponse.error);
|
||||
do_check_eq(aResponse.from, gClient1.activeThread.actor);
|
||||
do_check_eq(aResponse.from, gThreadClient1.actor);
|
||||
|
||||
gClient1.close(() => finishClient(gClient2));
|
||||
});
|
||||
|
|
|
@ -59,7 +59,7 @@ function test_definition_site(func, obj) {
|
|||
|
||||
function test_bad_definition_site(obj) {
|
||||
try {
|
||||
obj.getDefinitionSite(() => do_check_true(false));
|
||||
obj._client.request("definitionSite", () => do_check_true(false));
|
||||
} catch (e) {
|
||||
gThreadClient.resume(() => finishClient(gClient));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Test that reattaching to a previously detached thread works.
|
||||
*/
|
||||
|
||||
var gClient, gDebuggee, gThreadClient, gTabClient;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
initTestDebuggerServer();
|
||||
gDebuggee = testGlobal("test-reattach");
|
||||
DebuggerServer.addTestGlobal(gDebuggee);
|
||||
|
||||
let transport = DebuggerServer.connectPipe();
|
||||
gClient = new DebuggerClient(transport);
|
||||
gClient.connect(() => {
|
||||
attachTestTab(gClient, "test-reattach", (aReply, aTabClient) => {
|
||||
gTabClient = aTabClient;
|
||||
test_attach();
|
||||
});
|
||||
});
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
function test_attach()
|
||||
{
|
||||
gTabClient.attachThread({}, (aResponse, aThreadClient) => {
|
||||
do_check_eq(aThreadClient.state, "paused");
|
||||
gThreadClient = aThreadClient;
|
||||
aThreadClient.resume(test_detach);
|
||||
});
|
||||
}
|
||||
|
||||
function test_detach()
|
||||
{
|
||||
gThreadClient.detach(() => {
|
||||
do_check_eq(gThreadClient.state, "detached");
|
||||
do_check_eq(gTabClient.thread, null);
|
||||
test_reattach();
|
||||
});
|
||||
}
|
||||
|
||||
function test_reattach()
|
||||
{
|
||||
gTabClient.attachThread({}, (aResponse, aThreadClient) => {
|
||||
do_check_neq(gThreadClient, aThreadClient);
|
||||
do_check_eq(aThreadClient.state, "paused");
|
||||
do_check_eq(gTabClient.thread, aThreadClient);
|
||||
aThreadClient.resume(cleanup);
|
||||
});
|
||||
}
|
||||
|
||||
function cleanup()
|
||||
{
|
||||
gClient.close(do_test_finished);
|
||||
}
|
|
@ -30,6 +30,7 @@ reason = bug 821285
|
|||
[test_dbgglobal.js]
|
||||
[test_dbgclient_debuggerstatement.js]
|
||||
[test_attach.js]
|
||||
[test_reattach-thread.js]
|
||||
[test_blackboxing-01.js]
|
||||
[test_blackboxing-02.js]
|
||||
[test_blackboxing-03.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче