From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- devtools/shared/specs/addon/addons.js | 19 ++++ devtools/shared/specs/addon/moz.build | 10 ++ .../specs/addon/webextension-inspected-window.js | 119 +++++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 devtools/shared/specs/addon/addons.js create mode 100644 devtools/shared/specs/addon/moz.build create mode 100644 devtools/shared/specs/addon/webextension-inspected-window.js (limited to 'devtools/shared/specs/addon') diff --git a/devtools/shared/specs/addon/addons.js b/devtools/shared/specs/addon/addons.js new file mode 100644 index 0000000000..2f955a30ce --- /dev/null +++ b/devtools/shared/specs/addon/addons.js @@ -0,0 +1,19 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + +const { Arg, RetVal, generateActorSpec } = require("devtools/shared/protocol"); + +const addonsSpec = generateActorSpec({ + typeName: "addons", + + methods: { + installTemporaryAddon: { + request: { addonPath: Arg(0, "string") }, + response: { addon: RetVal("json") }, + }, + }, +}); + +exports.addonsSpec = addonsSpec; diff --git a/devtools/shared/specs/addon/moz.build b/devtools/shared/specs/addon/moz.build new file mode 100644 index 0000000000..e382173641 --- /dev/null +++ b/devtools/shared/specs/addon/moz.build @@ -0,0 +1,10 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DevToolsModules( + "addons.js", + "webextension-inspected-window.js", +) diff --git a/devtools/shared/specs/addon/webextension-inspected-window.js b/devtools/shared/specs/addon/webextension-inspected-window.js new file mode 100644 index 0000000000..23abf076c5 --- /dev/null +++ b/devtools/shared/specs/addon/webextension-inspected-window.js @@ -0,0 +1,119 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const { + Arg, + RetVal, + generateActorSpec, + types, +} = require("devtools/shared/protocol"); + +/** + * Sent with the eval and reload requests, used to inform the + * webExtensionInspectedWindowActor about the caller information + * to be able to evaluate code as being executed from the caller + * WebExtension sources, or log errors with information that can + * help the addon developer to more easily identify the affected + * lines in his own addon code. + */ +types.addDictType("webExtensionCallerInfo", { + // Information related to the line of code that has originated + // the request. + url: "string", + lineNumber: "nullable:number", + + // The called addonId. + addonId: "string", +}); + +/** + * RDP type related to the inspectedWindow.eval method request. + */ +types.addDictType("webExtensionEvalOptions", { + frameURL: "nullable:string", + contextSecurityOrigin: "nullable:string", + useContentScriptContext: "nullable:boolean", + + // Return the evalResult as a grip (used by the WebExtensions + // devtools inspector's sidebar.setExpression API method). + evalResultAsGrip: "nullable:boolean", + + // The actor ID of the node selected in the inspector if any, + // used to provide the '$0' binding. + toolboxSelectedNodeActorID: "nullable:string", + + // The actor ID of the console actor, + // used to provide the 'inspect' binding. + toolboxConsoleActorID: "nullable:string", +}); + +/** + * RDP type related to the inspectedWindow.eval method result errors. + * + * This type has been modelled on the same data format + * used in the corresponding chrome API method. + */ +types.addDictType("webExtensionEvalExceptionInfo", { + // The following properties are set if the error has not occurred + // in the evaluated JS code. + isError: "nullable:boolean", + code: "nullable:string", + description: "nullable:string", + details: "nullable:array:json", + + // The following properties are set if the error has occurred + // in the evaluated JS code. + isException: "nullable:string", + value: "nullable:string", +}); + +/** + * RDP type related to the inspectedWindow.eval method result. + */ +types.addDictType("webExtensionEvalResult", { + // The following properties are set if the evaluation has been + // completed successfully. + value: "nullable:json", + valueGrip: "nullable:json", + // The following properties are set if the evalutation has been + // completed with errors. + exceptionInfo: "nullable:webExtensionEvalExceptionInfo", +}); + +/** + * RDP type related to the inspectedWindow.reload method request. + */ +types.addDictType("webExtensionReloadOptions", { + ignoreCache: "nullable:boolean", + userAgent: "nullable:string", + injectedScript: "nullable:string", +}); + +const webExtensionInspectedWindowSpec = generateActorSpec({ + typeName: "webExtensionInspectedWindow", + + methods: { + reload: { + request: { + webExtensionCallerInfo: Arg(0, "webExtensionCallerInfo"), + options: Arg(1, "webExtensionReloadOptions"), + }, + }, + eval: { + request: { + webExtensionCallerInfo: Arg(0, "webExtensionCallerInfo"), + expression: Arg(1, "string"), + options: Arg(2, "webExtensionEvalOptions"), + }, + + response: { + evalResult: RetVal("webExtensionEvalResult"), + }, + }, + }, +}); + +exports.webExtensionInspectedWindowSpec = webExtensionInspectedWindowSpec; -- cgit v1.2.3