Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 16a25c4

Browse files
committed
Have consitent pseudo-nodes in ObjectInspector.
`__proto__` is renamed to `<prototype>` and `[default properties]` is renamed to `<default properties>` so all our pseudo nodes share the same syntax, i.e. `<${name}>`.
1 parent 42a7ff7 commit 16a25c4

File tree

14 files changed

+41
-40
lines changed

14 files changed

+41
-40
lines changed

packages/devtools-reps/src/object-inspector/tests/component/__snapshots__/entries.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ exports[`ObjectInspector - entries does not call enumEntries if entries are alre
4747
| | ▼ 10: \\"key-10\\" → \\"value-10\\"
4848
| | | <key>: \\"key-10\\"
4949
| | | <value>: \\"value-10\\"
50-
| ▼ __proto__: {}"
50+
| ▼ <prototype>: {}"
5151
`;
5252
5353
exports[`ObjectInspector - entries renders Object with entries as expected 1`] = `
@@ -60,5 +60,5 @@ exports[`ObjectInspector - entries renders Object with entries as expected 1`] =
6060
| | ▼ 1: Symbol(b) → \\"value-b\\"
6161
| | | <key>: Symbol(b)
6262
| | | <value>: \\"value-b\\"
63-
| ▼ __proto__: {}"
63+
| ▼ <prototype>: {}"
6464
`;

packages/devtools-reps/src/object-inspector/tests/component/__snapshots__/expand.js.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ exports[`ObjectInspector - state has the expected expandedPaths state when click
3131
"▼ {}
3232
| a: 1
3333
| Symbol(): \\"hello\\"
34-
| ▶︎ __proto__: Object {}
34+
| ▶︎ <prototype>: Object {}
3535
▶︎ Proxy { <target>: {}, <handler>: (3) […] }"
3636
`;
3737
@@ -51,7 +51,7 @@ exports[`ObjectInspector - state has the expected expandedPaths state when click
5151
"▼ {}
5252
| a: 1
5353
| Symbol(): \\"hello\\"
54-
| ▶︎ __proto__: Object {}
54+
| ▶︎ <prototype>: Object {}
5555
▼ Proxy
5656
| ▶︎ <target>: Object {}
5757
| ▶︎ <handler>: Array(3) [ … ]"
@@ -64,14 +64,14 @@ exports[`ObjectInspector - state has the expected state when expanding a node 1`
6464
6565
exports[`ObjectInspector - state has the expected state when expanding a node 2`] = `
6666
"▼ {}
67-
| ▶︎ __proto__: Object { }
67+
| ▶︎ <prototype>: Object { }
6868
▶︎ Proxy { <target>: {}, <handler>: (3) […] }"
6969
`;
7070
7171
exports[`ObjectInspector - state has the expected state when expanding a node 3`] = `
7272
"▼ {}
73-
| ▼ __proto__: {}
74-
| | ▶︎ __proto__: Object { }
73+
| ▼ <prototype>: {}
74+
| | ▶︎ <prototype>: Object { }
7575
▶︎ Proxy { <target>: {}, <handler>: (3) […] }"
7676
`;
7777
@@ -85,14 +85,14 @@ exports[`ObjectInspector - state has the expected state when expanding a proxy n
8585
▼ Proxy
8686
| ▶︎ <target>: Object {}
8787
| ▶︎ <handler>: Array(3) [ … ]
88-
| ▶︎ __proto__: Object { }"
88+
| ▶︎ <prototype>: Object { }"
8989
`;
9090
9191
exports[`ObjectInspector - state has the expected state when expanding a proxy node 3`] = `
9292
"▶︎ Object { p0: \\"0\\", p1: \\"1\\", p2: \\"2\\", p3: \\"3\\", p4: \\"4\\", p5: \\"5\\", p6: \\"6\\", p7: \\"7\\", p8: \\"8\\", p9: \\"9\\", … }
9393
▼ Proxy
9494
| ▶︎ <target>: Object {}
9595
| ▶︎ <handler>: Array(3) [ … ]
96-
| ▼ __proto__: {}
97-
| | ▶︎ __proto__: Object { }"
96+
| ▼ <prototype>: {}
97+
| | ▶︎ <prototype>: Object { }"
9898
`;

packages/devtools-reps/src/object-inspector/tests/component/__snapshots__/proxy.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ exports[`ObjectInspector - Proxy renders Proxy as expected 1`] = `
44
"▼ Proxy
55
| ▶︎ <target>: Object {}
66
| ▶︎ <handler>: Array(3) [ … ]
7-
| __proto__: Object { }"
7+
| <prototype>: Object { }"
88
`;

packages/devtools-reps/src/object-inspector/tests/component/basic.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ describe("ObjectInspector - renders", () => {
200200
NODE_TYPES.DEFAULT_PROPERTIES
201201
);
202202

203-
// The [default properties] node should have the "lessen" class only when collapsed.
203+
// The <default properties> node should have the "lessen" class only when collapsed.
204204
let oi = mount(ObjectInspector(generateDefaults({
205205
roots: [defaultPropertiesNode],
206206
})));
@@ -224,7 +224,7 @@ describe("ObjectInspector - renders", () => {
224224
NODE_TYPES.PROTOTYPE
225225
);
226226

227-
// The __proto__ node should have the "lessen" class only when collapsed.
227+
// The <prototype> node should have the "lessen" class only when collapsed.
228228
oi = mount(ObjectInspector(generateDefaults({
229229
roots: [prototypeNode],
230230
})));

packages/devtools-reps/src/object-inspector/tests/component/entries.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe("ObjectInspector - entries", () => {
5050
},
5151
loadedProperties: new Map([
5252
["root", mapStubs.get("properties")],
53-
["root/__proto__", true]
53+
["root/<prototype>", true]
5454
])
5555
})));
5656

@@ -77,7 +77,7 @@ describe("ObjectInspector - entries", () => {
7777
loadedProperties: new Map([
7878
["root", mapStubs.get("properties")],
7979
[`root/${SAFE_PATH_PREFIX}entries`, mapStubs.get("11-entries")],
80-
["root/__proto__", true]
80+
["root/<prototype>", true]
8181
])
8282
})));
8383

packages/devtools-reps/src/object-inspector/tests/component/expand.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe("ObjectInspector - state", () => {
9090

9191
expect(store.getState().expandedPaths.has("root-1")).toBeTruthy();
9292
expect(store.getState().expandedPaths.has("root-2")).toBeTruthy();
93-
expect(store.getState().expandedPaths.has("root-1/__proto__")).toBeTruthy();
93+
expect(store.getState().expandedPaths.has("root-1/<prototype>")).toBeTruthy();
9494

9595
// The property and symbols have primitive values, and can't be expanded.
9696
expect(store.getState().expandedPaths.size).toBe(3);
@@ -139,7 +139,8 @@ describe("ObjectInspector - state", () => {
139139
// Once all the loading promises are resolved, actors and loadedProperties
140140
// should have the expected values.
141141
expect(formatObjectInspector(wrapper)).toMatchSnapshot();
142-
expect(store.getState().loadedProperties.has("root-1/__proto__")).toBeTruthy();
142+
143+
expect(store.getState().loadedProperties.has("root-1/<prototype>")).toBeTruthy();
143144
expect(store.getState().actors.has(protoStub.prototype.actor)).toBeTruthy();
144145
});
145146

@@ -186,7 +187,7 @@ describe("ObjectInspector - state", () => {
186187
wrapper.update();
187188

188189
expect(formatObjectInspector(wrapper)).toMatchSnapshot();
189-
expect(store.getState().loadedProperties.has("root-2/__proto__")).toBeTruthy();
190+
expect(store.getState().loadedProperties.has("root-2/<prototype>")).toBeTruthy();
190191
expect(store.getState().actors.has(protoStub.prototype.actor)).toBeTruthy();
191192
});
192193

packages/devtools-reps/src/object-inspector/tests/test-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const {WAIT_UNTIL_TYPE} = require("../../shared/redux/middleware/waitUntilServic
1919
* | | ▼ 1 : Symbol(b) → "value-b"
2020
* | | | <key> : Symbol(b)
2121
* | | | <value> : "value-b"
22-
* | ▼ __proto__ : Object { … }
22+
* | ▼ <prototype> : Object { … }
2323
*
2424
*/
2525
function formatObjectInspector(wrapper: Object) {

packages/devtools-reps/src/object-inspector/tests/utils/get-children.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe("getChildren", () => {
104104
["secureConnectionStart", 1500967716401],
105105
["unloadEventEnd", 0],
106106
["unloadEventStart", 0],
107-
["__proto__", stub.prototype]
107+
["<prototype>", stub.prototype]
108108
];
109109
const childrenPaths = childrenEntries.map(([name]) => `rootpath/${name}`);
110110

packages/devtools-reps/src/object-inspector/tests/utils/make-node-for-properties.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ describe("makeNodesForProperties", () => {
4242
const nodes = makeNodesForProperties(objProperties, root);
4343

4444
const names = nodes.map(n => n.name);
45-
expect(names).toEqual(["0", "length", "__proto__"]);
45+
expect(names).toEqual(["0", "length", "<prototype>"]);
4646

4747
const paths = nodes.map(n => n.path);
48-
expect(paths).toEqual(["root/0", "root/length", "root/__proto__"]);
48+
expect(paths).toEqual(["root/0", "root/length", "root/<prototype>"]);
4949
});
5050

5151
it("includes getters and setters", () => {
@@ -80,8 +80,8 @@ describe("makeNodesForProperties", () => {
8080
const names = nodes.map(n => n.name);
8181
const paths = nodes.map(n => n.path);
8282

83-
expect(names).toEqual(["bar", "baz", "foo", "__proto__"]);
84-
expect(paths).toEqual(["root/bar", "root/baz", "root/foo", "root/__proto__"]);
83+
expect(names).toEqual(["bar", "baz", "foo", "<prototype>"]);
84+
expect(paths).toEqual(["root/bar", "root/baz", "root/foo", "root/<prototype>"]);
8585
});
8686

8787
it("does not include unrelevant properties", () => {
@@ -123,14 +123,14 @@ describe("makeNodesForProperties", () => {
123123
const names = nodes.map(n => n.name);
124124
const paths = nodes.map(n => n.path);
125125

126-
expect(names).toEqual(["1", "2", "11", "_bar", "bar", "__proto__"]);
126+
expect(names).toEqual(["1", "2", "11", "_bar", "bar", "<prototype>"]);
127127
expect(paths).toEqual([
128128
"root/1",
129129
"root/2",
130130
"root/11",
131131
"root/_bar",
132132
"root/bar",
133-
"root/__proto__"
133+
"root/<prototype>"
134134
]);
135135
});
136136

@@ -148,8 +148,8 @@ describe("makeNodesForProperties", () => {
148148
const names = nodes.map(n => n.name);
149149
const paths = nodes.map(n => n.path);
150150

151-
expect(names).toEqual(["bar", "__proto__"]);
152-
expect(paths).toEqual(["root/bar", "root/__proto__"]);
151+
expect(names).toEqual(["bar", "<prototype>"]);
152+
expect(paths).toEqual(["root/bar", "root/<prototype>"]);
153153

154154
expect(nodeIsPrototype(nodes[1])).toBe(true);
155155
});
@@ -172,7 +172,7 @@ describe("makeNodesForProperties", () => {
172172
const names = nodes.map(n => n.name);
173173
const paths = nodes.map(n => n.path);
174174

175-
expect(names).toEqual(["bar", "[default properties]"]);
175+
expect(names).toEqual(["bar", "<default properties>"]);
176176
expect(paths).toEqual(["root/bar", "root/##-default"]);
177177

178178
expect(nodeIsDefaultProperties(nodes[1])).toBe(true);
@@ -246,14 +246,14 @@ describe("makeNodesForProperties", () => {
246246
"332217",
247247
'"needs-quotes"',
248248
"unquoted",
249-
"__proto__"
249+
"<prototype>"
250250
]);
251251
expect(paths).toEqual([
252252
"root/",
253253
"root/332217",
254254
"root/needs-quotes",
255255
"root/unquoted",
256-
"root/__proto__"
256+
"root/<prototype>"
257257
]);
258258
});
259259
});

packages/devtools-reps/src/object-inspector/tests/utils/should-load-item-indexed-properties.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe("shouldLoadItemIndexedProperties", () => {
117117
expect(shouldLoadItemIndexedProperties(node)).toBeTruthy();
118118
});
119119

120-
it("returns false for a [default properties] node", () => {
120+
it("returns false for a <default properties> node", () => {
121121
const windowNode = createNode(null, "root", "/", {
122122
value: windowStubs.get("Window")
123123
});

0 commit comments

Comments
 (0)