Bug 1582304: Ensure you can add a watchpoint to property within a bucket, prototype, or default properties.

Differential Revision: https://phabricator.services.mozilla.com/D49496

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Miriam 2019-10-17 00:45:31 +00:00
Родитель 6752dad196
Коммит b43fd031d9
5 изменённых файлов: 44 добавлений и 19 удалений

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

@ -7,7 +7,7 @@
import type { GripProperties, Node, Props, ReduxAction } from "./types";
const { loadItemProperties } = require("./utils/load-properties");
const { getPathExpression, getValue } = require("./utils/node");
const { getPathExpression, getValue, nodeIsBucket } = require("./utils/node");
const { getLoadedProperties, getActors, getWatchpoints } = require("./reducer");
type Dispatch = ReduxAction => void;
@ -79,7 +79,12 @@ function nodePropertiesLoaded(
function addWatchpoint(item, watchpoint: string) {
return async function({ dispatch, client }: ThunkArgs) {
const { parent, name } = item;
const object = getValue(parent);
let object = getValue(parent);
if (nodeIsBucket(parent)) {
object = getValue(parent.parent);
}
if (!object) {
return;
}
@ -103,9 +108,15 @@ function addWatchpoint(item, watchpoint: string) {
*/
function removeWatchpoint(item) {
return async function({ dispatch, client }: ThunkArgs) {
const object = getValue(item.parent);
const property = item.name;
const path = item.parent.path;
const { parent, name } = item;
let object = getValue(parent);
if (nodeIsBucket(parent)) {
object = getValue(parent.parent);
}
const property = name;
const path = parent.path;
const actor = object.actor;
await client.removeWatchpoint(object, property);

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

@ -826,8 +826,10 @@ function getChildren(options: {
// e.g. `b` in { a: { b: 2 } } resolves to `a.b`
function getPathExpression(item) {
if (item && item.parent) {
return `${getPathExpression(item.parent)}.${item.name}`;
let parent = nodeIsBucket(item.parent) ? item.parent.parent : item.parent;
return `${getPathExpression(parent)}.${item.name}`;
}
return item.name;
}

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

@ -119,12 +119,7 @@ class Scopes extends PureComponent<Props, State> {
onContextMenu = (event: any, item: any) => {
const { addWatchpoint, removeWatchpoint } = this.props;
if (
!features.watchpoints ||
!item.parent ||
!item.parent.contents ||
!item.contents.configurable
) {
if (!features.watchpoints || !item.parent || !item.contents.configurable) {
return;
}

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

@ -2359,7 +2359,8 @@ function getChildren(options) {
function getPathExpression(item) {
if (item && item.parent) {
return `${getPathExpression(item.parent)}.${item.name}`;
let parent = nodeIsBucket(item.parent) ? item.parent.parent : item.parent;
return `${getPathExpression(parent)}.${item.name}`;
}
return item.name;
@ -7907,7 +7908,8 @@ const {
const {
getPathExpression,
getValue
getValue,
nodeIsBucket
} = __webpack_require__(114);
const {
@ -7996,7 +7998,11 @@ function addWatchpoint(item, watchpoint) {
parent,
name
} = item;
const object = getValue(parent);
let object = getValue(parent);
if (nodeIsBucket(parent)) {
object = getValue(parent.parent);
}
if (!object) {
return;
@ -8028,9 +8034,18 @@ function removeWatchpoint(item) {
dispatch,
client
}) {
const object = getValue(item.parent);
const property = item.name;
const path = item.parent.path;
const {
parent,
name
} = item;
let object = getValue(parent);
if (nodeIsBucket(parent)) {
object = getValue(parent.parent);
}
const property = name;
const path = parent.path;
const actor = object.actor;
await client.removeWatchpoint(object, property);
dispatch({

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

@ -115,7 +115,9 @@ const proto = {
}
const obj = this.rawValue();
const desc = Object.getOwnPropertyDescriptor(obj, property);
const desc =
Object.getOwnPropertyDescriptor(obj, property) ||
this.obj.getOwnPropertyDescriptor(property);
if (desc.set || desc.get || !desc.configurable) {
return;