root.js (2976B)
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 "use strict"; 5 6 const { 7 types, 8 generateActorSpec, 9 RetVal, 10 Arg, 11 Option, 12 } = require("resource://devtools/shared/protocol.js"); 13 14 types.addDictType("root.listWorkers", { 15 workers: "array:workerDescriptor", 16 }); 17 types.addDictType("root.listServiceWorkerRegistrations", { 18 registrations: "array:serviceWorkerRegistration", 19 }); 20 21 const rootSpecPrototype = { 22 typeName: "root", 23 24 methods: { 25 connect: { 26 request: { 27 // Added in Fx 133 28 frontendVersion: Option(0, "string"), 29 }, 30 response: {}, 31 }, 32 33 getRoot: { 34 request: {}, 35 response: RetVal("json"), 36 }, 37 38 listTabs: { 39 request: {}, 40 response: { 41 tabs: RetVal("array:tabDescriptor"), 42 }, 43 }, 44 45 getTab: { 46 request: { 47 browserId: Option(0, "number"), 48 }, 49 response: { 50 tab: RetVal("tabDescriptor"), 51 }, 52 }, 53 54 listAddons: { 55 request: { 56 iconDataURL: Option(0, "boolean"), 57 }, 58 response: { 59 addons: RetVal("array:webExtensionDescriptor"), 60 }, 61 }, 62 63 listWorkers: { 64 request: {}, 65 response: RetVal("root.listWorkers"), 66 }, 67 68 listServiceWorkerRegistrations: { 69 request: {}, 70 response: RetVal("root.listServiceWorkerRegistrations"), 71 }, 72 73 listProcesses: { 74 request: {}, 75 response: { 76 processes: RetVal("array:processDescriptor"), 77 }, 78 }, 79 80 getProcess: { 81 request: { 82 id: Arg(0, "number"), 83 }, 84 response: { 85 processDescriptor: RetVal("processDescriptor"), 86 }, 87 }, 88 89 watchResources: { 90 request: { 91 resourceTypes: Arg(0, "array:string"), 92 }, 93 response: {}, 94 }, 95 96 unwatchResources: { 97 request: { 98 resourceTypes: Arg(0, "array:string"), 99 }, 100 oneway: true, 101 }, 102 103 clearResources: { 104 request: { 105 resourceTypes: Arg(0, "array:string"), 106 }, 107 oneway: true, 108 }, 109 110 requestTypes: { 111 request: {}, 112 response: RetVal("json"), 113 }, 114 }, 115 116 events: { 117 tabListChanged: { 118 type: "tabListChanged", 119 }, 120 workerListChanged: { 121 type: "workerListChanged", 122 }, 123 addonListChanged: { 124 type: "addonListChanged", 125 }, 126 serviceWorkerRegistrationListChanged: { 127 type: "serviceWorkerRegistrationListChanged", 128 }, 129 processListChanged: { 130 type: "processListChanged", 131 }, 132 133 "resources-available-array": { 134 type: "resources-available-array", 135 array: Arg(0, "array:json"), 136 }, 137 "resources-destroyed-array": { 138 type: "resources-destroyed-array", 139 array: Arg(0, "array:json"), 140 }, 141 }, 142 }; 143 144 const rootSpec = generateActorSpec(rootSpecPrototype); 145 146 exports.rootSpecPrototype = rootSpecPrototype; 147 exports.rootSpec = rootSpec;