Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 696cf3b

Browse files
committed
Bug 1588997 - Convert ObjectClient to protocol.js front. r=nchevobbe.
- Converted the ObjectClient into an protocoljs Front - Converted the SymbolIteratorClient into a protocoljs Front and moved it to devtools/shared/fronts - Converted the PropertyIteratorClient into a protocoljs Front and moved it to devtools/shared/fronts - Converted the EnvironmentClient into a protocoljs Front and moved it to devtools/shared/fronts - Modified calls to `DebuggerClient.release()` so that it tries to call the ObjectFront's release method first, and falls back on `DebuggerClient.release()` if there's no object front - Changed reps so that it instantiates only one ObjectClient per grip - Changed tests so that they expect what the Front's request method resolves to where applicable (i.e. ObjectFront.allocationStack resolves to allocationStack, not a packet object with an allocationStack property) - Changed callbacks provided to ObjectClient methods to be chained to the ObjectFront methods (e.g. ObjectClient.getScope(callback) changed to ObjectFront.getScope().callback()) - Changed tests to use async/await (test_framebindings-x.js, test_functiongrips-x.js, test_objectgrips-x.js) - Changed tests to expect protocoljs to throw an error string instead of an error object (test_objectgrips-fn-apply-03.js, test_threadlifetime-02.js, test_pauselifetime-03.js) Differential Revision: https://phabricator.services.mozilla.com/D48182 --HG-- rename : devtools/shared/client/environment-client.js => devtools/shared/fronts/environment.js rename : devtools/shared/client/property-iterator-client.js => devtools/shared/fronts/property-iterator.js rename : devtools/shared/client/symbol-iterator-client.js => devtools/shared/fronts/symbol-iterator.js extra : moz-landing-system : lando
1 parent 8fdca46 commit 696cf3b

61 files changed

Lines changed: 718 additions & 899 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

browser/components/extensions/parent/ext-devtools-panels.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,18 @@ class ParentDevToolsInspectorSidebar extends BaseDevToolsPanel {
561561

562562
const oldActor = _lastObjectValueGrip && _lastObjectValueGrip.actor;
563563
const newActor = newObjectValueGrip && newObjectValueGrip.actor;
564+
const client = this.toolbox.target.client;
564565

565566
// Release the previously active actor on the remote debugging server.
566567
if (oldActor && oldActor !== newActor) {
567-
this.toolbox.target.client.release(oldActor);
568+
const objFront = client.getFrontByID(oldActor);
569+
if (objFront) {
570+
objFront.release();
571+
return;
572+
}
573+
574+
// In case there's no object front, use the client's release method.
575+
client.release(oldActor).catch(() => {});
568576
}
569577
}
570578
}

devtools/client/debugger/packages/devtools-reps/src/launchpad/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@ function onConnect(connection) {
3434
return connection.tabConnection.tabTarget.activeConsole.longString(grip);
3535
},
3636
releaseActor: function(actor) {
37-
return connection.tabConnection.debuggerClient.release(actor);
37+
const debuggerClient = connection.tabConnection.debuggerClient;
38+
const objFront = debuggerClient.getFrontByID(actor);
39+
40+
if (objFront) {
41+
return objFront.release();
42+
}
43+
44+
// In case there's no object front, use the client's release method.
45+
return debuggerClient.release(actor).catch(() => {});
3846
},
3947
};
4048

devtools/client/debugger/src/client/firefox/commands.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ function createObjectClient(grip: Grip) {
7070

7171
async function loadObjectProperties(root: Node) {
7272
const utils = Reps.objectInspector.utils;
73-
const properties = await utils.loadProperties.loadItemProperties(root, {
74-
createObjectClient,
75-
});
73+
const properties = await utils.loadProperties.loadItemProperties(
74+
root,
75+
debuggerClient
76+
);
7677
return utils.node.getChildren({
7778
item: root,
7879
loadedProperties: new Map([[root.path, properties]]),
@@ -84,7 +85,11 @@ function releaseActor(actor: String) {
8485
return;
8586
}
8687

87-
return debuggerClient.release(actor);
88+
const objFront = debuggerClient.getFrontByID(actor);
89+
90+
if (objFront) {
91+
return objFront.release().catch(() => {});
92+
}
8893
}
8994

9095
function sendPacket(packet: Object) {
@@ -536,6 +541,10 @@ async function getSourceActorBreakableLines({
536541
return actorLines;
537542
}
538543

544+
function getFrontByID(actorID: String) {
545+
return debuggerClient.getFrontByID(actorID);
546+
}
547+
539548
const clientCommands = {
540549
autocomplete,
541550
blackBox,
@@ -582,6 +591,7 @@ const clientCommands = {
582591
getEventListenerBreakpointTypes,
583592
detachWorkers,
584593
lookupTarget,
594+
getFrontByID,
585595
};
586596

587597
export { setupCommands, clientCommands };

devtools/client/debugger/src/client/firefox/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ export type DebuggerClient = {
263263
attachConsole: (actor: String, listeners: Array<*>) => Promise<*>,
264264
createObjectClient: (grip: Grip) => ObjectClient,
265265
release: (actor: String) => {},
266+
getFrontByID: (actor: String) => { release: () => Promise<*> },
266267
};
267268

268269
type ProcessDescriptor = Object;

devtools/client/debugger/test/mochitest/browser_dbg-scopes-mutations.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ add_task(async function() {
2626
invokeInTab("mutate");
2727
await onPaused;
2828
await waitForSelectedSource(dbg, "script-mutate");
29+
await waitForDispatch(dbg, "ADD_INLINE_PREVIEW");
2930

3031
is(
3132
getScopeNodeLabel(dbg, 2),
@@ -74,6 +75,7 @@ add_task(async function() {
7475

7576
await resume(dbg);
7677
await waitForPaused(dbg);
78+
await waitForDispatch(dbg, "ADD_INLINE_PREVIEW");
7779

7880
is(
7981
getScopeNodeLabel(dbg, 2),

devtools/client/debugger/test/mochitest/browser_dbg-sourcemaps-reloading.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ add_task(async function() {
3838
await waitForDispatch(dbg, "LOAD_SOURCE_TEXT");
3939

4040
await waitForPaused(dbg);
41+
await waitForDispatch(dbg, "ADD_INLINE_PREVIEW");
4142
assertPausedLocation(dbg);
4243

4344
await waitForBreakpointCount(dbg, 2);

devtools/client/inspector/inspector.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,14 @@ function Inspector(toolbox) {
158158
if (!actor) {
159159
return;
160160
}
161-
toolbox.target.client.release(actor);
161+
const objFront = toolbox.target.client.getFrontByID(actor);
162+
if (objFront) {
163+
objFront.release();
164+
return;
165+
}
166+
167+
// In case there's no object front, use the client's release method.
168+
toolbox.target.client.release(actor).catch(() => {});
162169
},
163170
});
164171

devtools/client/scratchpad/scratchpad.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ loader.lazyRequireGetter(
121121
);
122122
loader.lazyRequireGetter(
123123
this,
124-
"EnvironmentClient",
125-
"devtools/shared/client/environment-client"
124+
"EnvironmentFront",
125+
"devtools/shared/fronts/environment"
126126
);
127127
loader.lazyRequireGetter(
128128
this,
@@ -2333,8 +2333,8 @@ ScratchpadSidebar.prototype = {
23332333
});
23342334

23352335
VariablesViewController.attach(this.variablesView, {
2336-
getEnvironmentClient: grip => {
2337-
return new EnvironmentClient(
2336+
getEnvironmentFront: grip => {
2337+
return new EnvironmentFront(
23382338
this._scratchpad.debuggerClient,
23392339
grip
23402340
);
@@ -2346,8 +2346,13 @@ ScratchpadSidebar.prototype = {
23462346
return this._scratchpad.webConsoleFront.longString(actor);
23472347
},
23482348
releaseActor: actor => {
2349+
const objFront = this._scratchpad.debuggerClient.getFrontByID(
2350+
actor
2351+
);
23492352
// Ignore release failure, since the object actor may have been already GC.
2350-
this._scratchpad.debuggerClient.release(actor).catch(() => {});
2353+
if (objFront) {
2354+
objFront.release().catch(() => {});
2355+
}
23512356
},
23522357
});
23532358
}

devtools/client/shared/components/reps/reps.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3957,40 +3957,51 @@ const {
39573957
function loadItemProperties(item, client, loadedProperties) {
39583958
const gripItem = getClosestGripNode(item);
39593959
const value = getValue(gripItem);
3960+
39603961
const [start, end] = item.meta ? [item.meta.startIndex, item.meta.endIndex] : [];
39613962
const promises = [];
39623963
let objectClient;
3964+
3965+
if (value && client && client.getFrontByID) {
3966+
objectClient = client.getFrontByID(value.actor);
3967+
}
39633968

3964-
const getObjectClient = () => objectClient || client.createObjectClient(value);
3969+
const getObjectClient = function() {
3970+
if (!objectClient) {
3971+
objectClient = client.createObjectClient(value);
3972+
}
3973+
3974+
return objectClient;
3975+
}
39653976

39663977
if (shouldLoadItemIndexedProperties(item, loadedProperties)) {
39673978
promises.push(enumIndexedProperties(getObjectClient(), start, end));
39683979
}
3969-
3980+
39703981
if (shouldLoadItemNonIndexedProperties(item, loadedProperties)) {
39713982
promises.push(enumNonIndexedProperties(getObjectClient(), start, end));
39723983
}
3973-
3984+
39743985
if (shouldLoadItemEntries(item, loadedProperties)) {
39753986
promises.push(enumEntries(getObjectClient(), start, end));
39763987
}
3977-
3988+
39783989
if (shouldLoadItemPrototype(item, loadedProperties)) {
39793990
promises.push(getPrototype(getObjectClient()));
39803991
}
3981-
3992+
39823993
if (shouldLoadItemSymbols(item, loadedProperties)) {
39833994
promises.push(enumSymbols(getObjectClient(), start, end));
39843995
}
3985-
3996+
39863997
if (shouldLoadItemFullText(item, loadedProperties)) {
39873998
promises.push(getFullText(client.createLongStringClient(value), item));
39883999
}
3989-
4000+
39904001
if (shouldLoadItemProxySlots(item, loadedProperties)) {
39914002
promises.push(getProxySlots(getObjectClient()));
39924003
}
3993-
4004+
39944005
return Promise.all(promises).then(mergeResponses);
39954006
}
39964007

@@ -4090,9 +4101,7 @@ const {
40904101

40914102
async function enumIndexedProperties(objectClient, start, end) {
40924103
try {
4093-
const {
4094-
iterator
4095-
} = await objectClient.enumProperties({
4104+
const iterator = await objectClient.enumProperties({
40964105
ignoreNonIndexedProperties: true
40974106
});
40984107
const response = await iteratorSlice(iterator, start, end);
@@ -4105,9 +4114,7 @@ async function enumIndexedProperties(objectClient, start, end) {
41054114

41064115
async function enumNonIndexedProperties(objectClient, start, end) {
41074116
try {
4108-
const {
4109-
iterator
4110-
} = await objectClient.enumProperties({
4117+
const iterator = await objectClient.enumProperties({
41114118
ignoreIndexedProperties: true
41124119
});
41134120
const response = await iteratorSlice(iterator, start, end);
@@ -4120,9 +4127,7 @@ async function enumNonIndexedProperties(objectClient, start, end) {
41204127

41214128
async function enumEntries(objectClient, start, end) {
41224129
try {
4123-
const {
4124-
iterator
4125-
} = await objectClient.enumEntries();
4130+
const iterator = await objectClient.enumEntries();
41264131
const response = await iteratorSlice(iterator, start, end);
41274132
return response;
41284133
} catch (e) {
@@ -4133,9 +4138,7 @@ async function enumEntries(objectClient, start, end) {
41334138

41344139
async function enumSymbols(objectClient, start, end) {
41354140
try {
4136-
const {
4137-
iterator
4138-
} = await objectClient.enumSymbols();
4141+
const iterator = await objectClient.enumSymbols();
41394142
const response = await iteratorSlice(iterator, start, end);
41404143
return response;
41414144
} catch (e) {
@@ -8549,4 +8552,4 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
85498552
/***/ })
85508553

85518554
/******/ });
8552-
});
8555+
});

0 commit comments

Comments
 (0)