зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1514248 - Reimplement xpcshell test debugging using a public thread-actor API. r=jlast
Differential Revision: https://phabricator.services.mozilla.com/D14561 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
9ee6538956
Коммит
4ee33b0d6d
|
@ -563,8 +563,8 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
|
|||
* A promise that resolves to a JSON object representing the
|
||||
* response.
|
||||
*/
|
||||
setBreakpoint: function(line, column, condition, noSliding) {
|
||||
if (this.threadActor.state !== "paused") {
|
||||
setBreakpoint: function(line, column, condition, noSliding, inNestedLoop) {
|
||||
if (!inNestedLoop && this.threadActor.state !== "paused") {
|
||||
const errorObject = {
|
||||
error: "wrongState",
|
||||
message: "Cannot set breakpoint while debuggee is running.",
|
||||
|
|
|
@ -80,6 +80,10 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
|||
// server.
|
||||
this._hiddenBreakpoints = new Map();
|
||||
|
||||
// A Set of URLs string to watch for when new sources are found by
|
||||
// the debugger instance.
|
||||
this._onLoadBreakpointURLs = new Set();
|
||||
|
||||
this.global = global;
|
||||
|
||||
this._allEventsListener = this._allEventsListener.bind(this);
|
||||
|
@ -96,9 +100,12 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
|||
this._onOpeningRequest = this._onOpeningRequest.bind(this);
|
||||
EventEmitter.on(this._parent, "window-ready", this._onWindowReady);
|
||||
|
||||
// Set a wrappedJSObject property so |this| can be sent via the observer svc
|
||||
// for the xpcshell harness.
|
||||
this.wrappedJSObject = this;
|
||||
if (Services.obs) {
|
||||
// Set a wrappedJSObject property so |this| can be sent via the observer svc
|
||||
// for the xpcshell harness.
|
||||
this.wrappedJSObject = this;
|
||||
Services.obs.notifyObservers(this, "devtools-thread-instantiated");
|
||||
}
|
||||
},
|
||||
|
||||
// Used by the ObjectActor to keep track of the depth of grip() calls.
|
||||
|
@ -306,6 +313,17 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Tell the thread to automatically add a breakpoint on the first line of
|
||||
* a given file, when it is first loaded.
|
||||
*
|
||||
* This is currently only used by the xpcshell test harness, and unless
|
||||
* we decide to expand the scope of this feature, we should keep it that way.
|
||||
*/
|
||||
setBreakpointOnLoad(urls) {
|
||||
this._onLoadBreakpointURLs = new Set(urls);
|
||||
},
|
||||
|
||||
_findXHRBreakpointIndex(p, m) {
|
||||
return this._xhrBreakpoints.findIndex(
|
||||
({ path, method }) => path === p && method === m);
|
||||
|
@ -2017,6 +2035,12 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
|
|||
}
|
||||
}
|
||||
|
||||
if (this._onLoadBreakpointURLs.has(source.url)) {
|
||||
this.unsafeSynchronize(
|
||||
sourceActor.setBreakpoint(1, undefined, undefined, undefined, true)
|
||||
);
|
||||
}
|
||||
|
||||
this._debuggerSourcesSeen.add(source);
|
||||
return true;
|
||||
},
|
||||
|
|
|
@ -397,7 +397,6 @@ function _setupDebuggerServer(breakpointFiles, callback) {
|
|||
"See also https://bugzil.la/1215378.");
|
||||
}
|
||||
let { DebuggerServer } = require("devtools/server/main");
|
||||
let { OriginalLocation } = require("devtools/server/actors/common");
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.registerAllActors();
|
||||
let { createRootActor } = require("resource://testing-common/dbg-actors.js");
|
||||
|
@ -406,29 +405,14 @@ function _setupDebuggerServer(breakpointFiles, callback) {
|
|||
|
||||
// An observer notification that tells us when we can "resume" script
|
||||
// execution.
|
||||
const TOPICS = ["devtools-thread-resumed", "xpcshell-test-devtools-shutdown"];
|
||||
const TOPICS = ["devtools-thread-instantiated", "devtools-thread-resumed", "xpcshell-test-devtools-shutdown"];
|
||||
let observe = function(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "devtools-thread-resumed":
|
||||
// Exceptions in here aren't reported and block the debugger from
|
||||
// resuming, so...
|
||||
try {
|
||||
// Add a breakpoint for the first line in our test files.
|
||||
let threadActor = subject.wrappedJSObject;
|
||||
for (let file of breakpointFiles) {
|
||||
// Pass an empty `source` object to workaround `source` function assertion
|
||||
let sourceActor = threadActor.sources.source({originalUrl: file, source: {}});
|
||||
sourceActor._getOrCreateBreakpointActor(new OriginalLocation(sourceActor, 1));
|
||||
}
|
||||
} catch (ex) {
|
||||
info("Failed to initialize breakpoints: " + ex + "\n" + ex.stack);
|
||||
}
|
||||
break;
|
||||
case "xpcshell-test-devtools-shutdown":
|
||||
// the debugger has shutdown before we got a resume event - nothing
|
||||
// special to do here.
|
||||
break;
|
||||
if (topic === "devtools-thread-instantiated") {
|
||||
const threadActor = subject.wrappedJSObject;
|
||||
threadActor.setBreakpointOnLoad(breakpointFiles);
|
||||
return;
|
||||
}
|
||||
|
||||
for (let topicToRemove of TOPICS) {
|
||||
_Services.obs.removeObserver(observe, topicToRemove);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче