tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

object.js (5163B)


      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/. */
      4 
      5 "use strict";
      6 
      7 const {
      8  generateActorSpec,
      9  Arg,
     10  RetVal,
     11  types,
     12 } = require("resource://devtools/shared/protocol.js");
     13 
     14 types.addDictType("object.descriptor", {
     15  configurable: "boolean",
     16  enumerable: "boolean",
     17  // Can be null if there is a getter for the property.
     18  value: "nullable:json",
     19  // Only set `value` exists.
     20  writable: "nullable:boolean",
     21  // Only set when `value` does not exist and there is a getter for the property.
     22  get: "nullable:json",
     23  // Only set when `value` does not exist and there is a setter for the property.
     24  set: "nullable:json",
     25 });
     26 
     27 types.addDictType("object.completion", {
     28  return: "nullable:json",
     29  throw: "nullable:json",
     30 });
     31 
     32 types.addDictType("object.prototypeproperties", {
     33  prototype: "object.descriptor",
     34  ownProperties: "nullable:json",
     35  ownSymbols: "nullable:array:object.descriptor",
     36  safeGetterValues: "nullable:json",
     37 });
     38 
     39 types.addDictType("object.prototype", {
     40  prototype: "object.descriptor",
     41 });
     42 
     43 types.addDictType("object.property", {
     44  descriptor: "nullable:object.descriptor",
     45 });
     46 
     47 types.addDictType("object.propertyValue", {
     48  value: "nullable:object.completion",
     49 });
     50 
     51 types.addDictType("object.apply", {
     52  value: "nullable:object.completion",
     53 });
     54 
     55 types.addDictType("object.bindings", {
     56  arguments: "array:json",
     57  variables: "json",
     58 });
     59 
     60 types.addDictType("object.enumProperties.Options", {
     61  enumEntries: "nullable:boolean",
     62  ignoreNonIndexedProperties: "nullable:boolean",
     63  ignoreIndexedProperties: "nullable:boolean",
     64  query: "nullable:string",
     65  sort: "nullable:boolean",
     66 });
     67 
     68 types.addDictType("object.dependentPromises", {
     69  promises: "array:object.descriptor",
     70 });
     71 
     72 types.addDictType("object.originalSourceLocation", {
     73  source: "source",
     74  line: "number",
     75  column: "number",
     76  functionDisplayName: "string",
     77 });
     78 
     79 types.addDictType("object.promiseState", {
     80  state: "string",
     81  value: "nullable:object.descriptor",
     82  reason: "nullable:object.descriptor",
     83  creationTimestamp: "number",
     84  timeToSettle: "nullable:number",
     85 });
     86 
     87 types.addDictType("object.proxySlots", {
     88  proxyTarget: "object.descriptor",
     89  proxyHandler: "object.descriptor",
     90 });
     91 
     92 types.addDictType("object.customFormatterBody", {
     93  customFormatterBody: "json",
     94 });
     95 
     96 const objectSpec = generateActorSpec({
     97  typeName: "obj",
     98  methods: {
     99    allocationStack: {
    100      request: {},
    101      response: {
    102        allocationStack: RetVal("array:object.originalSourceLocation"),
    103      },
    104    },
    105    dependentPromises: {
    106      request: {},
    107      response: RetVal("object.dependentPromises"),
    108    },
    109    enumEntries: {
    110      request: {},
    111      response: {
    112        iterator: RetVal("propertyIterator"),
    113      },
    114    },
    115    enumProperties: {
    116      request: {
    117        options: Arg(0, "nullable:object.enumProperties.Options"),
    118      },
    119      response: {
    120        iterator: RetVal("propertyIterator"),
    121      },
    122    },
    123    enumPrivateProperties: {
    124      request: {},
    125      response: {
    126        iterator: RetVal("privatePropertiesIterator"),
    127      },
    128    },
    129    enumSymbols: {
    130      request: {},
    131      response: {
    132        iterator: RetVal("symbolIterator"),
    133      },
    134    },
    135    fulfillmentStack: {
    136      request: {},
    137      response: {
    138        fulfillmentStack: RetVal("array:object.originalSourceLocation"),
    139      },
    140    },
    141    prototypeAndProperties: {
    142      request: {},
    143      response: RetVal("object.prototypeproperties"),
    144    },
    145    prototype: {
    146      request: {},
    147      response: RetVal("object.prototype"),
    148    },
    149    property: {
    150      request: {
    151        name: Arg(0, "string"),
    152      },
    153      response: RetVal("object.property"),
    154    },
    155    propertyValue: {
    156      request: {
    157        name: Arg(0, "string"),
    158        receiverId: Arg(1, "nullable:string"),
    159      },
    160      response: RetVal("object.propertyValue"),
    161    },
    162    apply: {
    163      request: {
    164        context: Arg(0, "nullable:json"),
    165        arguments: Arg(1, "nullable:array:json"),
    166      },
    167      response: RetVal("object.apply"),
    168    },
    169    rejectionStack: {
    170      request: {},
    171      response: {
    172        rejectionStack: RetVal("array:object.originalSourceLocation"),
    173      },
    174    },
    175    promiseState: {
    176      request: {},
    177      response: RetVal("object.promiseState"),
    178    },
    179    proxySlots: {
    180      request: {},
    181      response: RetVal("object.proxySlots"),
    182    },
    183    customFormatterBody: {
    184      request: {},
    185      response: RetVal("object.customFormatterBody"),
    186    },
    187    addWatchpoint: {
    188      request: {
    189        property: Arg(0, "string"),
    190        label: Arg(1, "string"),
    191        watchpointType: Arg(2, "string"),
    192      },
    193      oneway: true,
    194    },
    195    removeWatchpoint: {
    196      request: {
    197        property: Arg(0, "string"),
    198      },
    199      oneway: true,
    200    },
    201    removeWatchpoints: {
    202      request: {},
    203      oneway: true,
    204    },
    205    release: { release: true },
    206    // Needed for the PauseScopedObjectActor which extends the ObjectActor.
    207    threadGrip: {
    208      request: {},
    209      response: {},
    210    },
    211  },
    212 });
    213 
    214 exports.objectSpec = objectSpec;