feat: Import Firefox 128 and 129 API schema data (#5387)
* chore: Updated mobile schema path in download-import-schema-from-gecko-dev script * chore: Removed from manifestjson parser remaining logic and test coverage for the deprecated siteperm manifest.json file * feat: Imported Firefox 128 and 129 API schema data
This commit is contained in:
Родитель
23dfbf1c70
Коммит
85af0c5938
|
@ -19,7 +19,7 @@ const GIT_CONFIG = {
|
||||||
'browser/config/version_display.txt',
|
'browser/config/version_display.txt',
|
||||||
'toolkit/components/extensions/schemas',
|
'toolkit/components/extensions/schemas',
|
||||||
'browser/components/extensions/schemas',
|
'browser/components/extensions/schemas',
|
||||||
'mobile/android/components/extensions/schemas',
|
'mobile/shared/components/extensions/schemas',
|
||||||
],
|
],
|
||||||
partialCloneOptions: '--depth 1 --filter=blob:none --no-checkout',
|
partialCloneOptions: '--depth 1 --filter=blob:none --no-checkout',
|
||||||
tmpDir: tmp.dirSync({
|
tmpDir: tmp.dirSync({
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
validateAddon,
|
validateAddon,
|
||||||
validateDictionary,
|
validateDictionary,
|
||||||
validateLangPack,
|
validateLangPack,
|
||||||
validateSitePermission,
|
|
||||||
validateStaticTheme,
|
validateStaticTheme,
|
||||||
} from 'schema/validator';
|
} from 'schema/validator';
|
||||||
import {
|
import {
|
||||||
|
@ -125,7 +124,6 @@ export default class ManifestJSONParser extends JSONParser {
|
||||||
this.isStaticTheme = false;
|
this.isStaticTheme = false;
|
||||||
this.isLanguagePack = false;
|
this.isLanguagePack = false;
|
||||||
this.isDictionary = false;
|
this.isDictionary = false;
|
||||||
this.isSitePermission = false;
|
|
||||||
|
|
||||||
// Keep the addon type detection in sync with the most updated logic
|
// Keep the addon type detection in sync with the most updated logic
|
||||||
// used on the Firefox side, as defined in ExtensionData parseManifest
|
// used on the Firefox side, as defined in ExtensionData parseManifest
|
||||||
|
@ -136,8 +134,6 @@ export default class ManifestJSONParser extends JSONParser {
|
||||||
this.isLanguagePack = true;
|
this.isLanguagePack = true;
|
||||||
} else if (hasManifestKey('dictionaries')) {
|
} else if (hasManifestKey('dictionaries')) {
|
||||||
this.isDictionary = true;
|
this.isDictionary = true;
|
||||||
} else if (hasManifestKey('site_permissions')) {
|
|
||||||
this.isSitePermission = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.io = io;
|
this.io = io;
|
||||||
|
@ -461,8 +457,6 @@ export default class ManifestJSONParser extends JSONParser {
|
||||||
validate = validateLangPack;
|
validate = validateLangPack;
|
||||||
} else if (this.isDictionary) {
|
} else if (this.isDictionary) {
|
||||||
validate = validateDictionary;
|
validate = validateDictionary;
|
||||||
} else if (this.isSitePermission) {
|
|
||||||
validate = validateSitePermission;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isValid = validate(this.parsedJSON, this.schemaValidatorOptions);
|
this.isValid = validate(this.parsedJSON, this.schemaValidatorOptions);
|
||||||
|
|
|
@ -105,7 +105,8 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "url",
|
"format": "url",
|
||||||
"pattern": "^(https://|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])(:\\d*)?(/|$)).*$",
|
"pattern": "^(https://|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])(:\\d*)?(/|$)).*$",
|
||||||
"preprocess": "localize"
|
"preprocess": "localize",
|
||||||
|
"deprecated": "Unsupported on Firefox at this time."
|
||||||
},
|
},
|
||||||
"alternate_urls": {
|
"alternate_urls": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
{
|
{
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"$ref": "tags#/types/Tab"
|
"$ref": "tabs#/types/Tab"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tab",
|
"name": "tab",
|
||||||
|
|
|
@ -74,7 +74,11 @@
|
||||||
},
|
},
|
||||||
"matchAboutBlank": {
|
"matchAboutBlank": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is <code>false</code>."
|
"description": "If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Ignored if matchOriginAsFallback is specified. By default it is <code>false</code>."
|
||||||
|
},
|
||||||
|
"matchOriginAsFallback": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "If matchOriginAsFallback is true, then the code is also injected in about:, data:, blob: when their origin matches the pattern in 'matches', even if the actual document origin is opaque (due to the use of CSP sandbox or iframe sandbox). Match patterns in 'matches' must specify a wildcard path glob. By default it is <code>false</code>."
|
||||||
},
|
},
|
||||||
"runAt": {
|
"runAt": {
|
||||||
"allOf": [
|
"allOf": [
|
||||||
|
@ -86,6 +90,16 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"world": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "extensionTypes#/types/ExecutionWorld"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "The JavaScript world for a script to execute within. Defaults to \"ISOLATED\"."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"cookieStoreId": {
|
"cookieStoreId": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
{
|
{
|
||||||
"name": "updateEnabledRulesets",
|
"name": "updateEnabledRulesets",
|
||||||
"type": "function",
|
"type": "function",
|
||||||
"description": "Returns the ids for the current set of enabled static rulesets.",
|
"description": "Modifies the static rulesets enabled/disabled state.",
|
||||||
"async": "callback",
|
"async": "callback",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
|
@ -128,6 +128,45 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "updateStaticRules",
|
||||||
|
"type": "function",
|
||||||
|
"description": "Modified individual static rules enabled/disabled state. Changes to rules belonging to a disabled ruleset will take effect when the ruleset becomes enabled.",
|
||||||
|
"async": "callback",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "options",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"rulesetId": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"disableRuleIds": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"default": []
|
||||||
|
},
|
||||||
|
"enableRuleIds": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"default": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"rulesetId"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "callback",
|
||||||
|
"type": "function",
|
||||||
|
"parameters": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "getAvailableStaticRuleCount",
|
"name": "getAvailableStaticRuleCount",
|
||||||
"type": "function",
|
"type": "function",
|
||||||
|
@ -146,6 +185,39 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "getDisabledRuleIds",
|
||||||
|
"type": "function",
|
||||||
|
"description": "Returns the list of individual disabled static rules from a given static ruleset id.",
|
||||||
|
"async": "callback",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "options",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"rulesetId": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"rulesetId"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "callback",
|
||||||
|
"type": "function",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "disabledRuleIds",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "getDynamicRules",
|
"name": "getDynamicRules",
|
||||||
"type": "function",
|
"type": "function",
|
||||||
|
@ -371,13 +443,25 @@
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"description": "The maximum number of static Rulesets an extension can specify as part of the rule_resources manifest key."
|
"description": "The maximum number of static Rulesets an extension can specify as part of the rule_resources manifest key."
|
||||||
},
|
},
|
||||||
|
"MAX_NUMBER_OF_DISABLED_STATIC_RULES": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "The maximum number of static rules that can be disabled on each static ruleset."
|
||||||
|
},
|
||||||
"MAX_NUMBER_OF_ENABLED_STATIC_RULESETS": {
|
"MAX_NUMBER_OF_ENABLED_STATIC_RULESETS": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"description": "The maximum number of static Rulesets an extension can enable at any one time."
|
"description": "The maximum number of static Rulesets an extension can enable at any one time."
|
||||||
},
|
},
|
||||||
"MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES": {
|
"MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"description": "The maximum number of dynamic and session rules an extension can add. NOTE: in the Firefox we are enforcing this limit to the session and dynamic rules count separately, instead of enforcing it to the rules count for both combined as the Chrome implementation does."
|
"description": "Deprecated property returning the maximum number of dynamic and session rules an extension can add, replaced by MAX_NUMBER_OF_DYNAMIC_RULES/MAX_NUMBER_OF_SESSION_RULES."
|
||||||
|
},
|
||||||
|
"MAX_NUMBER_OF_DYNAMIC_RULES": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "The maximum number of dynamic session rules an extension can add."
|
||||||
|
},
|
||||||
|
"MAX_NUMBER_OF_SESSION_RULES": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "The maximum number of dynamic session rules an extension can add."
|
||||||
},
|
},
|
||||||
"MAX_NUMBER_OF_REGEX_RULES": {
|
"MAX_NUMBER_OF_REGEX_RULES": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
|
|
|
@ -75,6 +75,14 @@
|
||||||
],
|
],
|
||||||
"description": "The soonest that the JavaScript or CSS will be injected into the tab."
|
"description": "The soonest that the JavaScript or CSS will be injected into the tab."
|
||||||
},
|
},
|
||||||
|
"ExecutionWorld": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"ISOLATED",
|
||||||
|
"MAIN"
|
||||||
|
],
|
||||||
|
"description": "The JavaScript world for a script to execute within. <code>ISOLATED</code> is the default execution environment of content scripts, <code>MAIN</code> is the web page's execution environment."
|
||||||
|
},
|
||||||
"CSSOrigin": {
|
"CSSOrigin": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
|
|
|
@ -314,6 +314,21 @@
|
||||||
},
|
},
|
||||||
"default": []
|
"default": []
|
||||||
},
|
},
|
||||||
|
"optional_host_permissions": {
|
||||||
|
"min_manifest_version": 3,
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/types/MatchPattern"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"onError": "warn"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"default": []
|
||||||
|
},
|
||||||
"optional_permissions": {
|
"optional_permissions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
|
@ -567,39 +582,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"WebExtensionSitePermissionsManifest": {
|
|
||||||
"$merge": {
|
|
||||||
"source": {
|
|
||||||
"$ref": "manifest#/types/ManifestBase"
|
|
||||||
},
|
|
||||||
"with": {
|
|
||||||
"type": "object",
|
|
||||||
"description": "Represents a WebExtension site permissions manifest.json file",
|
|
||||||
"properties": {
|
|
||||||
"site_permissions": {
|
|
||||||
"type": "array",
|
|
||||||
"minItems": 1,
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/types/SitePermission"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"install_origins": {
|
|
||||||
"type": "array",
|
|
||||||
"minItems": 1,
|
|
||||||
"maxItems": 1,
|
|
||||||
"items": {
|
|
||||||
"type": "string",
|
|
||||||
"format": "origin"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"site_permissions",
|
|
||||||
"install_origins"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ThemeIcons": {
|
"ThemeIcons": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -835,17 +817,6 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"SitePermission": {
|
|
||||||
"anyOf": [
|
|
||||||
{
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"midi",
|
|
||||||
"midi-sysex"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"HttpURL": {
|
"HttpURL": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "url",
|
"format": "url",
|
||||||
|
@ -901,8 +872,7 @@
|
||||||
"pattern": "^[0-9]{1,3}(\\.[a-z0-9*]+)+$"
|
"pattern": "^[0-9]{1,3}(\\.[a-z0-9*]+)+$"
|
||||||
},
|
},
|
||||||
"admin_install_only": {
|
"admin_install_only": {
|
||||||
"type": "boolean",
|
"type": "boolean"
|
||||||
"optional": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -919,8 +889,7 @@
|
||||||
"description": "Maximum version of Gecko to support.",
|
"description": "Maximum version of Gecko to support.",
|
||||||
"pattern": "^[0-9]{1,3}(\\.[a-z0-9*]+)+$"
|
"pattern": "^[0-9]{1,3}(\\.[a-z0-9*]+)+$"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"additionalProperties": {}
|
|
||||||
},
|
},
|
||||||
"DeprecatedApplications": {
|
"DeprecatedApplications": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -1041,7 +1010,11 @@
|
||||||
},
|
},
|
||||||
"match_about_blank": {
|
"match_about_blank": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "If matchAboutBlank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Code cannot be inserted in top-level about:-frames. By default it is <code>false</code>."
|
"description": "If match_about_blank is true, then the code is also injected in about:blank and about:srcdoc frames if your extension has access to its parent document. Ignored if match_origin_as_fallback is specified. By default it is <code>false</code>."
|
||||||
|
},
|
||||||
|
"match_origin_as_fallback": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "If match_origin_as_fallback is true, then the code is also injected in about:, data:, blob: when their origin matches the pattern in 'matches', even if the actual document origin is opaque (due to the use of CSP sandbox or iframe sandbox). Match patterns in 'matches' must specify a wildcard path glob. By default it is <code>false</code>."
|
||||||
},
|
},
|
||||||
"run_at": {
|
"run_at": {
|
||||||
"allOf": [
|
"allOf": [
|
||||||
|
@ -1053,6 +1026,17 @@
|
||||||
"description": "The soonest that the JavaScript or CSS will be injected into the tab. Defaults to \"document_idle\"."
|
"description": "The soonest that the JavaScript or CSS will be injected into the tab. Defaults to \"document_idle\"."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"world": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "extensionTypes#/types/ExecutionWorld"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "ISOLATED",
|
||||||
|
"description": "The JavaScript world for a script to execute within. Defaults to \"ISOLATED\"."
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
|
|
@ -236,7 +236,7 @@
|
||||||
},
|
},
|
||||||
"proxyDNS": {
|
"proxyDNS": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Proxy DNS when using SOCKS v5."
|
"description": "Proxy DNS when using SOCKS. DNS queries get leaked to the network when set to false. True by default for SOCKS v5. False by default for SOCKS v4."
|
||||||
},
|
},
|
||||||
"respectBeConservative": {
|
"respectBeConservative": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
|
@ -364,9 +364,10 @@
|
||||||
"ExecutionWorld": {
|
"ExecutionWorld": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
"ISOLATED"
|
"ISOLATED",
|
||||||
|
"MAIN"
|
||||||
],
|
],
|
||||||
"description": "The JavaScript world for a script to execute within. We currently only support the <code>'ISOLATED'</code> world."
|
"description": "The JavaScript world for a script to execute within. <code>ISOLATED</code> is the default execution environment of content scripts, <code>MAIN</code> is the web page's execution environment."
|
||||||
},
|
},
|
||||||
"RegisteredContentScript": {
|
"RegisteredContentScript": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -400,6 +401,10 @@
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"matchOriginAsFallback": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "If matchOriginAsFallback is true, then the code is also injected in about:, data:, blob: when their origin matches the pattern in 'matches', even if the actual document origin is opaque (due to the use of CSP sandbox or iframe sandbox). Match patterns in 'matches' must specify a wildcard path glob. By default it is <code>false</code>."
|
||||||
|
},
|
||||||
"runAt": {
|
"runAt": {
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
|
@ -410,6 +415,16 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"world": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/types/ExecutionWorld"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "The JavaScript world for a script to execute within. Defaults to \"ISOLATED\"."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"persistAcrossSessions": {
|
"persistAcrossSessions": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
|
|
|
@ -769,7 +769,7 @@
|
||||||
{
|
{
|
||||||
"type": "function",
|
"type": "function",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"name": "callback",
|
"name": "asyncCallback",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"allOf": [
|
"allOf": [
|
||||||
|
@ -800,6 +800,7 @@
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"name": "extraInfoSpec",
|
"name": "extraInfoSpec",
|
||||||
|
"postprocess": "mutuallyExclusiveBlockingOrAsyncBlocking",
|
||||||
"description": "Array of extra information that should be passed to the listener function.",
|
"description": "Array of extra information that should be passed to the listener function.",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/types/OnAuthRequiredOptions"
|
"$ref": "#/types/OnAuthRequiredOptions"
|
||||||
|
|
|
@ -388,34 +388,6 @@ export class SchemaValidator {
|
||||||
return this._localeValidator;
|
return this._localeValidator;
|
||||||
}
|
}
|
||||||
|
|
||||||
get validateSitePermission() {
|
|
||||||
this._lazyInit();
|
|
||||||
|
|
||||||
if (!this._sitepermissionValidator) {
|
|
||||||
// Like with langpacks, we don't want additional properties in dictionaries,
|
|
||||||
// and there is no separate schema file.
|
|
||||||
// Uses ``deepPatch`` (instead of deepmerge) because we're patching a
|
|
||||||
// complicated schema instead of simply merging them together.
|
|
||||||
this._sitepermissionValidator = this._validator.compile({
|
|
||||||
...deepPatch(this.schemaObject, {
|
|
||||||
types: {
|
|
||||||
WebExtensionSitePermissionsManifest: {
|
|
||||||
$merge: {
|
|
||||||
with: {
|
|
||||||
additionalProperties: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
$id: 'sitepermission-manifest',
|
|
||||||
$ref: '#/types/WebExtensionSitePermissionsManifest',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return this._sitepermissionValidator;
|
|
||||||
}
|
|
||||||
|
|
||||||
_compileAddonValidator(validator) {
|
_compileAddonValidator(validator) {
|
||||||
const { minimum, maximum } = this.allowedManifestVersionsRange;
|
const { minimum, maximum } = this.allowedManifestVersionsRange;
|
||||||
const manifestVersion = this.addonManifestVersion;
|
const manifestVersion = this.addonManifestVersion;
|
||||||
|
@ -808,15 +780,6 @@ export const validateDictionary = (manifestData, validatorOptions = {}) => {
|
||||||
return isValid;
|
return isValid;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const validateSitePermission = (manifestData, validatorOptions = {}) => {
|
|
||||||
const validator = getValidator(validatorOptions);
|
|
||||||
let isValid = validator.validateSitePermission(manifestData);
|
|
||||||
const errors = filterErrors(validator.validateSitePermission.errors);
|
|
||||||
isValid = errors?.length > 0 ? isValid : true;
|
|
||||||
validateSitePermission.errors = errors;
|
|
||||||
return isValid;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const validateLocaleMessages = (
|
export const validateLocaleMessages = (
|
||||||
localeMessagesData,
|
localeMessagesData,
|
||||||
validatorOptions = {}
|
validatorOptions = {}
|
||||||
|
|
|
@ -209,22 +209,6 @@ export function validLocaleMessagesJSON() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validSitePermissionManifestJSON(extra) {
|
|
||||||
return JSON.stringify({
|
|
||||||
manifest_version: 2,
|
|
||||||
name: 'My SitePermission Addon',
|
|
||||||
version: '1.0a1',
|
|
||||||
site_permissions: ['midi'],
|
|
||||||
install_origins: ['http://mozilla.org'],
|
|
||||||
browser_specific_settings: {
|
|
||||||
gecko: {
|
|
||||||
id: '@my-exaple-sitepermission',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
...extra,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function isMatch(target, expected) {
|
function isMatch(target, expected) {
|
||||||
return isMatchWith(target, expected, (tVal, eVal) => {
|
return isMatchWith(target, expected, (tVal, eVal) => {
|
||||||
if (eVal instanceof RegExp) {
|
if (eVal instanceof RegExp) {
|
||||||
|
|
|
@ -17,7 +17,6 @@ import {
|
||||||
validManifestJSON,
|
validManifestJSON,
|
||||||
validDictionaryManifestJSON,
|
validDictionaryManifestJSON,
|
||||||
validLangpackManifestJSON,
|
validLangpackManifestJSON,
|
||||||
validSitePermissionManifestJSON,
|
|
||||||
validStaticThemeManifestJSON,
|
validStaticThemeManifestJSON,
|
||||||
getStreamableIO,
|
getStreamableIO,
|
||||||
EMPTY_PNG,
|
EMPTY_PNG,
|
||||||
|
@ -4231,52 +4230,6 @@ describe('ManifestJSONParser', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('sitepermission', () => {
|
|
||||||
it('supports simple valid sitepermission', () => {
|
|
||||||
const linter = new Linter({ _: ['bar'] });
|
|
||||||
const json = validSitePermissionManifestJSON();
|
|
||||||
const manifestJSONParser = new ManifestJSONParser(json, linter.collector);
|
|
||||||
expect(manifestJSONParser.isValid).toEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('detects invalid sitepermission (more than one install_origin)', () => {
|
|
||||||
const linter = new Linter({ _: ['bar'] });
|
|
||||||
const json = validSitePermissionManifestJSON({
|
|
||||||
install_origins: ['https://website1.com', 'https://website2.com'],
|
|
||||||
});
|
|
||||||
const manifestJSONParser = new ManifestJSONParser(json, linter.collector);
|
|
||||||
expect(linter.collector.errors).toEqual(
|
|
||||||
expect.arrayContaining([
|
|
||||||
expect.objectContaining({
|
|
||||||
code: messages.JSON_INVALID.code,
|
|
||||||
message: '"/install_origins" must NOT have more than 1 items',
|
|
||||||
instancePath: '/install_origins',
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
expect(manifestJSONParser.isValid).toEqual(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('detects invalid sitepermission (invalid site_permissions value)', () => {
|
|
||||||
const linter = new Linter({ _: ['bar'] });
|
|
||||||
const json = validSitePermissionManifestJSON({
|
|
||||||
site_permissions: ['midi', 'not_a_valid_webapi_name'],
|
|
||||||
});
|
|
||||||
const manifestJSONParser = new ManifestJSONParser(json, linter.collector);
|
|
||||||
expect(linter.collector.errors).toEqual(
|
|
||||||
expect.arrayContaining([
|
|
||||||
expect.objectContaining({
|
|
||||||
code: messages.JSON_INVALID.code,
|
|
||||||
message:
|
|
||||||
'"/site_permissions/1" is not a valid key or has invalid extra properties',
|
|
||||||
instancePath: '/site_permissions/1',
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
);
|
|
||||||
expect(manifestJSONParser.isValid).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('homepage_url', () => {
|
describe('homepage_url', () => {
|
||||||
function testHomepageUrl(homepage_url, expectValid) {
|
function testHomepageUrl(homepage_url, expectValid) {
|
||||||
const addonLinter = new Linter({ _: ['bar'] });
|
const addonLinter = new Linter({ _: ['bar'] });
|
||||||
|
|
Загрузка…
Ссылка в новой задаче