Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / devtools / client / fronts / private-properties-iterator.js
blob6b7bd3c14a8dab317ba6abe2d2d6820047d738b1
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 const {
8 FrontClassWithSpec,
9 registerFront,
10 } = require("resource://devtools/shared/protocol.js");
11 const {
12 privatePropertiesIteratorSpec,
13 } = require("resource://devtools/shared/specs/private-properties-iterator.js");
14 const {
15 getAdHocFrontOrPrimitiveGrip,
16 } = require("resource://devtools/client/fronts/object.js");
18 class PrivatePropertiesIteratorFront extends FrontClassWithSpec(
19 privatePropertiesIteratorSpec
20 ) {
21 form(data) {
22 this.actorID = data.actor;
23 this.count = data.count;
26 async slice(start, count) {
27 const result = await super.slice({ start, count });
28 return this._onResult(result);
31 async all() {
32 const result = await super.all();
33 return this._onResult(result);
36 _onResult(result) {
37 if (!result.privateProperties) {
38 return result;
41 // The result packet can have multiple properties that hold grips which we may need
42 // to turn into fronts.
43 const gripKeys = ["value", "getterValue", "get", "set"];
45 result.privateProperties.forEach((item, i) => {
46 if (item?.descriptor) {
47 for (const gripKey of gripKeys) {
48 if (item.descriptor.hasOwnProperty(gripKey)) {
49 result.privateProperties[i].descriptor[gripKey] =
50 getAdHocFrontOrPrimitiveGrip(item.descriptor[gripKey], this);
54 });
55 return result;
59 exports.PrivatePropertiesIteratorFront = PrivatePropertiesIteratorFront;
60 registerFront(PrivatePropertiesIteratorFront);