Bug 1402784 - Introduce nsIContentPolicy::TYPE_INTERNAL_AUDIOWORKLET and nsIContentPolicy::TYPE_INTERNAL_PAINTWORKLET, r=ckerschb

Differential Revision: https://phabricator.services.mozilla.com/D67105

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2020-03-17 11:29:33 +00:00
Родитель b503a043c8
Коммит 96d0e4f828
10 изменённых файлов: 45 добавлений и 4 удалений

Просмотреть файл

@ -139,6 +139,8 @@ inline const char* NS_CP_ContentTypeName(uint32_t contentType) {
CASE_RETURN(TYPE_INTERNAL_MODULE_PRELOAD); CASE_RETURN(TYPE_INTERNAL_MODULE_PRELOAD);
CASE_RETURN(TYPE_INTERNAL_DTD); CASE_RETURN(TYPE_INTERNAL_DTD);
CASE_RETURN(TYPE_INTERNAL_FORCE_ALLOWED_DTD); CASE_RETURN(TYPE_INTERNAL_FORCE_ALLOWED_DTD);
CASE_RETURN(TYPE_INTERNAL_AUDIOWORKLET);
CASE_RETURN(TYPE_INTERNAL_PAINTWORKLET);
default: default:
return "<Unknown Type>"; return "<Unknown Type>";
} }

Просмотреть файл

@ -3387,6 +3387,8 @@ nsContentUtils::InternalContentPolicyTypeToExternal(nsContentPolicyType aType) {
case nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER: case nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER:
case nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER: case nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER:
case nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS: case nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS:
case nsIContentPolicy::TYPE_INTERNAL_AUDIOWORKLET:
case nsIContentPolicy::TYPE_INTERNAL_PAINTWORKLET:
return nsIContentPolicy::TYPE_SCRIPT; return nsIContentPolicy::TYPE_SCRIPT;
case nsIContentPolicy::TYPE_INTERNAL_EMBED: case nsIContentPolicy::TYPE_INTERNAL_EMBED:

Просмотреть файл

@ -376,6 +376,24 @@ interface nsIContentPolicy : nsISupports
*/ */
const nsContentPolicyType TYPE_INTERNAL_FORCE_ALLOWED_DTD = 48; const nsContentPolicyType TYPE_INTERNAL_FORCE_ALLOWED_DTD = 48;
/**
* Indicates an internal constant for scripts loaded through an
* audioWorklet.
*
* This will be mapped to TYPE_SCRIPT before being passed to content policy
* implementations.
*/
const nsContentPolicyType TYPE_INTERNAL_AUDIOWORKLET = 49;
/**
* Indicates an internal constant for scripts loaded through an
* paintWorklet.
*
* This will be mapped to TYPE_SCRIPT before being passed to content policy
* implementations.
*/
const nsContentPolicyType TYPE_INTERNAL_PAINTWORKLET = 50;
/* When adding new content types, please update /* When adding new content types, please update
* NS_CP_ContentTypeName, nsCSPContext, CSP_ContentTypeToDirective, * NS_CP_ContentTypeName, nsCSPContext, CSP_ContentTypeToDirective,
* DoContentSecurityChecks, all nsIContentPolicy implementations, the * DoContentSecurityChecks, all nsIContentPolicy implementations, the

4
dom/cache/DBSchema.cpp поставляемый
Просмотреть файл

@ -334,7 +334,9 @@ static_assert(nsIContentPolicy::TYPE_INVALID == 0 &&
nsIContentPolicy::TYPE_INTERNAL_MODULE == 45 && nsIContentPolicy::TYPE_INTERNAL_MODULE == 45 &&
nsIContentPolicy::TYPE_INTERNAL_MODULE_PRELOAD == 46 && nsIContentPolicy::TYPE_INTERNAL_MODULE_PRELOAD == 46 &&
nsIContentPolicy::TYPE_INTERNAL_DTD == 47 && nsIContentPolicy::TYPE_INTERNAL_DTD == 47 &&
nsIContentPolicy::TYPE_INTERNAL_FORCE_ALLOWED_DTD == 48, nsIContentPolicy::TYPE_INTERNAL_FORCE_ALLOWED_DTD == 48 &&
nsIContentPolicy::TYPE_INTERNAL_AUDIOWORKLET == 49 &&
nsIContentPolicy::TYPE_INTERNAL_PAINTWORKLET == 50,
"nsContentPolicyType values are as expected"); "nsContentPolicyType values are as expected");
namespace { namespace {

Просмотреть файл

@ -330,6 +330,12 @@ RequestDestination InternalRequest::MapContentPolicyTypeToRequestDestination(
case nsIContentPolicy::TYPE_SPECULATIVE: case nsIContentPolicy::TYPE_SPECULATIVE:
destination = RequestDestination::_empty; destination = RequestDestination::_empty;
break; break;
case nsIContentPolicy::TYPE_INTERNAL_AUDIOWORKLET:
destination = RequestDestination::Audioworklet;
break;
case nsIContentPolicy::TYPE_INTERNAL_PAINTWORKLET:
destination = RequestDestination::Paintworklet;
break;
default: default:
MOZ_ASSERT(false, "Unhandled nsContentPolicyType value"); MOZ_ASSERT(false, "Unhandled nsContentPolicyType value");
break; break;

Просмотреть файл

@ -38,7 +38,7 @@ namespace dom {
* RequestDestination| nsContentPolicyType * RequestDestination| nsContentPolicyType
* ------------------+-------------------- * ------------------+--------------------
* audio | TYPE_INTERNAL_AUDIO * audio | TYPE_INTERNAL_AUDIO
* audioworklet | TODO * audioworklet | TYPE_INTERNAL_AUDIOWORKLET
* document | TYPE_DOCUMENT, TYPE_INTERNAL_IFRAME, TYPE_SUBDOCUMENT * document | TYPE_DOCUMENT, TYPE_INTERNAL_IFRAME, TYPE_SUBDOCUMENT
* embed | TYPE_INTERNAL_EMBED * embed | TYPE_INTERNAL_EMBED
* font | TYPE_FONT * font | TYPE_FONT
@ -46,7 +46,7 @@ namespace dom {
* | TYPE_IMAGE, TYPE_INTERNAL_IMAGE_FAVICON, TYPE_IMAGESET * | TYPE_IMAGE, TYPE_INTERNAL_IMAGE_FAVICON, TYPE_IMAGESET
* manifest | TYPE_WEB_MANIFEST * manifest | TYPE_WEB_MANIFEST
* object | TYPE_INTERNAL_OBJECT, TYPE_OBJECT * object | TYPE_INTERNAL_OBJECT, TYPE_OBJECT
* "paintworklet" | TODO * "paintworklet" | TYPE_INTERNAL_PAINTWORKLET
* report" | TODO * report" | TODO
* script | TYPE_INTERNAL_SCRIPT, TYPE_INTERNAL_SCRIPT_PRELOAD, * script | TYPE_INTERNAL_SCRIPT, TYPE_INTERNAL_SCRIPT_PRELOAD,
* | TYPE_INTERNAL_MODULE, TYPE_INTERNAL_MODULE_PRELOAD, * | TYPE_INTERNAL_MODULE, TYPE_INTERNAL_MODULE_PRELOAD,

Просмотреть файл

@ -31,6 +31,10 @@ nsCString MapInternalContentPolicyTypeToDest(nsContentPolicyType aType) {
return NS_LITERAL_CSTRING("sharedworker"); return NS_LITERAL_CSTRING("sharedworker");
case nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER: case nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER:
return NS_LITERAL_CSTRING("serviceworker"); return NS_LITERAL_CSTRING("serviceworker");
case nsIContentPolicy::TYPE_INTERNAL_AUDIOWORKLET:
return NS_LITERAL_CSTRING("audioworklet");
case nsIContentPolicy::TYPE_INTERNAL_PAINTWORKLET:
return NS_LITERAL_CSTRING("paintworklet");
case nsIContentPolicy::TYPE_IMAGESET: case nsIContentPolicy::TYPE_IMAGESET:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE: case nsIContentPolicy::TYPE_INTERNAL_IMAGE:
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD: case nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD:

Просмотреть файл

@ -263,6 +263,8 @@ CSPDirective CSP_ContentTypeToDirective(nsContentPolicyType aType) {
case nsIContentPolicy::TYPE_INTERNAL_MODULE: case nsIContentPolicy::TYPE_INTERNAL_MODULE:
case nsIContentPolicy::TYPE_INTERNAL_MODULE_PRELOAD: case nsIContentPolicy::TYPE_INTERNAL_MODULE_PRELOAD:
case nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS: case nsIContentPolicy::TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS:
case nsIContentPolicy::TYPE_INTERNAL_AUDIOWORKLET:
case nsIContentPolicy::TYPE_INTERNAL_PAINTWORKLET:
return nsIContentSecurityPolicy::SCRIPT_SRC_DIRECTIVE; return nsIContentSecurityPolicy::SCRIPT_SRC_DIRECTIVE;
case nsIContentPolicy::TYPE_STYLESHEET: case nsIContentPolicy::TYPE_STYLESHEET:

Просмотреть файл

@ -1599,6 +1599,11 @@ nsresult EnsureMIMEOfScript(nsHttpChannel* aChannel, nsIURI* aURI,
AccumulateCategorical( AccumulateCategorical(
Telemetry::LABELS_SCRIPT_BLOCK_INCORRECT_MIME_3::importScript_load); Telemetry::LABELS_SCRIPT_BLOCK_INCORRECT_MIME_3::importScript_load);
break; break;
case nsIContentPolicy::TYPE_INTERNAL_AUDIOWORKLET:
case nsIContentPolicy::TYPE_INTERNAL_PAINTWORKLET:
AccumulateCategorical(
Telemetry::LABELS_SCRIPT_BLOCK_INCORRECT_MIME_3::worklet_load);
break;
default: default:
MOZ_ASSERT_UNREACHABLE("unexpected script type"); MOZ_ASSERT_UNREACHABLE("unexpected script type");
break; break;

Просмотреть файл

@ -8844,7 +8844,7 @@
"bug_numbers": [1288361, 1299267, 1399990, 1510225, 1581559], "bug_numbers": [1288361, 1299267, 1399990, 1510225, 1581559],
"expires_in_version": "never", "expires_in_version": "never",
"kind": "categorical", "kind": "categorical",
"labels": ["unknown","javaScript","image", "audio", "video","text_plain","text_csv","text_xml","app_octet_stream","app_xml","app_json","text_json","text_html","empty","serviceworker_load","worker_load","importScript_load","script_load","same_origin","CORS_origin","cross_origin"], "labels": ["unknown","javaScript","image", "audio", "video","text_plain","text_csv","text_xml","app_octet_stream","app_xml","app_json","text_json","text_html","empty","serviceworker_load","worker_load","importScript_load","script_load","same_origin","CORS_origin","cross_origin", "worklet_load"],
"description": "Whether the script load has a MIME type of ...? (unknown, javaScript, image, audio, video, text_plain, text_csv, text_xml, app_octet_stream, app_xml, app_json, text_json, text_html, empty). Whether the script load is from ...? (serviceworker_load, worker_load, importSript_load, script_load). Whether the script load is of ...? (same_origin, CORS_origin, cross_origin)" "description": "Whether the script load has a MIME type of ...? (unknown, javaScript, image, audio, video, text_plain, text_csv, text_xml, app_octet_stream, app_xml, app_json, text_json, text_html, empty). Whether the script load is from ...? (serviceworker_load, worker_load, importSript_load, script_load). Whether the script load is of ...? (same_origin, CORS_origin, cross_origin)"
}, },
"NEWTAB_PAGE_ENABLED": { "NEWTAB_PAGE_ENABLED": {