зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1619993 - Use Debugger.Object values consistently across watchpoints. r=jlast
Differential Revision: https://phabricator.services.mozilla.com/D65671 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5b855de25b
Коммит
576f75f1f3
|
@ -2,6 +2,10 @@
|
|||
* 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/>. */
|
||||
|
||||
async function getScopeValue(dbg, index) {
|
||||
return (await waitForElement(dbg, "scopeValue", index)).innerText;
|
||||
}
|
||||
|
||||
// - Tests adding a watchpoint
|
||||
// - Tests removing a watchpoint
|
||||
// - Tests adding a watchpoint, resuming to after the youngest frame has popped,
|
||||
|
@ -30,6 +34,7 @@ add_task(async function() {
|
|||
await waitForPaused(dbg);
|
||||
await waitForState(dbg, () => dbg.selectors.getSelectedInlinePreviews());
|
||||
assertPausedAtSourceAndLine(dbg, sourceId, 17);
|
||||
is(await getScopeValue(dbg, 5), "3");
|
||||
|
||||
info("Resume and wait to pause at the access to b in the first `obj.b;`");
|
||||
resume(dbg);
|
||||
|
@ -62,7 +67,7 @@ add_task(async function() {
|
|||
getWatchpointItem2.click();
|
||||
pressKey(dbg, "Escape");
|
||||
await addedWatchpoint2;
|
||||
|
||||
|
||||
info("Resume and wait to pause at the access to b in getB");
|
||||
resume(dbg);
|
||||
await waitForPaused(dbg);
|
||||
|
@ -81,7 +86,7 @@ add_task(async function() {
|
|||
el2.scrollIntoView();
|
||||
clickElementWithSelector(dbg, ".remove-get-watchpoint");
|
||||
await removedWatchpoint2;
|
||||
|
||||
|
||||
info("Add back the get watchpoint on b");
|
||||
const addedWatchpoint3 = waitForDispatch(dbg, "SET_WATCHPOINT");
|
||||
await rightClickScopeNode(dbg, 5);
|
||||
|
|
|
@ -780,9 +780,7 @@ const proto = {
|
|||
retval.value = this.hooks.createValueGrip(desc.value);
|
||||
} else if (this.thread.getWatchpoint(obj, name.toString())) {
|
||||
const watchpoint = this.thread.getWatchpoint(obj, name.toString());
|
||||
retval.value = this.hooks.createValueGrip(
|
||||
this.obj.makeDebuggeeValue(watchpoint.desc.value)
|
||||
);
|
||||
retval.value = this.hooks.createValueGrip(watchpoint.desc.value);
|
||||
retval.watchpoint = watchpoint.watchpointType;
|
||||
} else {
|
||||
if ("get" in desc) {
|
||||
|
|
|
@ -10,28 +10,33 @@ class WatchpointMap {
|
|||
this._watchpoints = new Map();
|
||||
}
|
||||
|
||||
setWatchpoint(objActor, data) {
|
||||
_setWatchpoint(objActor, data) {
|
||||
const { property, label, watchpointType } = data;
|
||||
const obj = objActor.rawValue();
|
||||
|
||||
if (this.has(obj, property)) {
|
||||
return;
|
||||
const desc = objActor.obj.getOwnPropertyDescriptor(property);
|
||||
|
||||
if (this.has(obj, property) || desc.set || desc.get || !desc.configurable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const desc =
|
||||
Object.getOwnPropertyDescriptor(obj, property) ||
|
||||
objActor.obj.getOwnPropertyDescriptor(property);
|
||||
|
||||
if (desc.set || desc.get || !desc.configurable) {
|
||||
return;
|
||||
function getValue() {
|
||||
return typeof desc.value === "object" && desc.value
|
||||
? desc.value.unsafeDereference()
|
||||
: desc.value;
|
||||
}
|
||||
|
||||
const pauseAndRespond = type => {
|
||||
function setValue(v) {
|
||||
desc.value = objActor.obj.makeDebuggeeValue(v);
|
||||
}
|
||||
const maybeHandlePause = type => {
|
||||
const frame = this.thread.dbg.getNewestFrame();
|
||||
this.thread._pauseAndRespond(frame, {
|
||||
type: type,
|
||||
message: label,
|
||||
});
|
||||
|
||||
if (this.thread.hasMoved(frame, type) && !this.thread.skipBreakpoints) {
|
||||
this.thread._pauseAndRespond(frame, {
|
||||
type: type,
|
||||
message: label,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (watchpointType === "get") {
|
||||
|
@ -39,20 +44,11 @@ class WatchpointMap {
|
|||
configurable: desc.configurable,
|
||||
enumerable: desc.enumerable,
|
||||
set: objActor.obj.makeDebuggeeValue(v => {
|
||||
desc.value = v;
|
||||
setValue(v);
|
||||
}),
|
||||
get: objActor.obj.makeDebuggeeValue(() => {
|
||||
const frame = this.thread.dbg.getNewestFrame();
|
||||
|
||||
if (!this.thread.hasMoved(frame, "getWatchpoint")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this.thread.skipBreakpoints) {
|
||||
pauseAndRespond("getWatchpoint");
|
||||
}
|
||||
|
||||
return desc.value;
|
||||
maybeHandlePause("getWatchpoint");
|
||||
return getValue();
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
@ -62,31 +58,25 @@ class WatchpointMap {
|
|||
configurable: desc.configurable,
|
||||
enumerable: desc.enumerable,
|
||||
set: objActor.obj.makeDebuggeeValue(v => {
|
||||
const frame = this.thread.dbg.getNewestFrame();
|
||||
|
||||
if (!this.thread.hasMoved(frame, "setWatchpoint")) {
|
||||
desc.value = v;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.thread.skipBreakpoints) {
|
||||
pauseAndRespond("setWatchpoint");
|
||||
}
|
||||
|
||||
desc.value = v;
|
||||
maybeHandlePause("setWatchpoint");
|
||||
setValue(v);
|
||||
}),
|
||||
get: objActor.obj.makeDebuggeeValue(() => {
|
||||
return desc.value;
|
||||
return getValue();
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
add(objActor, data) {
|
||||
// Get the object's description before calling setWatchpoint,
|
||||
// otherwise we'll get the modified property descriptor instead
|
||||
const desc = objActor.obj.getOwnPropertyDescriptor(data.property);
|
||||
this.setWatchpoint(objActor, data);
|
||||
const desc = this._setWatchpoint(objActor, data);
|
||||
if (!desc) {
|
||||
return;
|
||||
}
|
||||
|
||||
const objWatchpoints =
|
||||
this._watchpoints.get(objActor.rawValue()) || new Map();
|
||||
|
|
Загрузка…
Ссылка в новой задаче