1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# -*- Mode:Python; tab-width:8; indent-tabs-mode:nil -*- */
# vim: set ts=8 sts=4 et sw=4 tw=80: */
# 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/.
# WebExtension WebIDL API Bindings Configuration, used by the script
# `dom/extensions-webidl/GenerateWebIDLBindingsFromJSONSchema.py`
# to customize the WebIDL generated based on the WebExtensions API JSON Schemas.
#
# Generating the WebIDL definitions for some of the WebExtensions API does require
# some special handling, there are corresponding entries in the configuration tables
# below.
#
# Mapping table between the JSON Schema types (represented as keys of the map)
# and the related WebIDL type (represented by the value in the map).
# Any mapping missing from this table will fallback to use the "any" webidl type
# (See GenerateWebIDLBindings.py WebIDLHelpers.webidl_type_from_mapping method).
#
# NOTE: Please keep this table in alphabetic order (upper and lower case in two
# separate alphabetic orders, group of the upcase ones first).
WEBEXT_TYPES_MAPPING = {
"ExpectedError": "any", # Only used in test.assertThrows/assertRejects
"Port": "ExtensionPort",
"Promise": "Promise<any>",
"StreamFilter": "ExtensionStreamFilter",
"any": "any",
"boolean": "boolean",
"number": "float",
"function": "Function",
"integer": "long",
"object": "any", # TODO: as a follow up we may look into generating webidl dictionaries to achieve a more precise mapping
"runtime.Port": "ExtensionPort",
"string": "DOMString",
"types.Setting": "ExtensionSetting",
}
# Set of the types from the WEBEXT_TYPES_MAPPING that will be threated as primitive
# types (e.g. used to omit optional attribute in the WebIDL methods type signatures).
#
# NOTE: Please keep this table in alphabetic order (upper and lower case in two
# separate alphabetic orders, group of the update ones first).
WEBIDL_PRIMITIVE_TYPES = set([
"DOMString",
"boolean",
"float"
"long",
])
# Mapping table for some APIs that do require special handling and a
# specific stub method should be set in the generated webidl extended
# attribute `WebExtensionStub`.
#
# The key in this map represent the API method name (including the
# API namespace that is part of), the value is the value to set on the
# `WebExtensionStub` webidl extended attribute:
#
# "namespace.methodName": "WebExtensionStubName",
#
# NOTE: Please keep this table in alphabetic order.
WEBEXT_STUBS_MAPPING = {
"dns.resolve": "AsyncAmbiguous",
"runtime.connect": "ReturnsPort",
"runtime.connectNative": "ReturnsPort",
"runtime.getURL": "ReturnsString",
# TODO: Bug 1782690 - This method accepts functions/args so we'll need to
# serialize them.
"scripting.executeScript": "NotImplementedAsync",
"scripting.getRegisteredContentScripts": "AsyncAmbiguous",
"scripting.unregisterContentScripts": "AsyncAmbiguous",
"test.assertEq": "AssertEq",
"test.assertRejects": False, # No WebExtensionStub attribute.
"test.assertThrows": False, # No WebExtensionStub attribute.
"test.withHandlingUserInput": "NotImplementedNoReturn",
}
WEBEXT_WORKER_HIDDEN_SET = set([
"runtime.getFrameId",
"runtime.getBackgroundPage",
])
# Mapping table for the directories where the JSON API schema will be loaded
# from.
WEBEXT_SCHEMADIRS_MAPPING = {
"toolkit": ["toolkit", "components", "extensions", "schemas"],
"browser": ["browser", "components", "extensions", "schemas"],
"mobile": ["mobile", "android", "components", "extensions", "schemas"],
}
# List of toolkit-level WebExtensions API namespaces that are not included
# in android builds.
#
# NOTE: keep this list in sync with the API namespaces excluded in
# - toolkit/components/extensions/jar.mn
# - toolkit/components/extensions/schemas/jar.mn
WEBEXT_ANDROID_EXCLUDED = [
"captivePortal",
"geckoProfiler",
"identity"
]
|