Bug 1682164 - Update RequestDestination to the latest spec. r=asuth
Stop using `default:` in MapContentPolicyTypeToRequestDestination so that compilers can notice when people forgot adding a new nsContentPolicyType. Differential Revision: https://phabricator.services.mozilla.com/D99604
This commit is contained in:
@@ -191,11 +191,9 @@ void InternalRequest::OverrideContentPolicyType(
|
||||
/* static */
|
||||
RequestDestination InternalRequest::MapContentPolicyTypeToRequestDestination(
|
||||
nsContentPolicyType aContentPolicyType) {
|
||||
RequestDestination destination = RequestDestination::_empty;
|
||||
switch (aContentPolicyType) {
|
||||
case nsIContentPolicy::TYPE_OTHER:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT_PRELOAD:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_MODULE:
|
||||
@@ -205,115 +203,86 @@ RequestDestination InternalRequest::MapContentPolicyTypeToRequestDestination(
|
||||
case nsIContentPolicy::TYPE_INTERNAL_CHROMEUTILS_COMPILED_SCRIPT:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_FRAME_MESSAGEMANAGER_SCRIPT:
|
||||
case nsIContentPolicy::TYPE_SCRIPT:
|
||||
destination = RequestDestination::Script;
|
||||
break;
|
||||
return RequestDestination::Script;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_WORKER:
|
||||
destination = RequestDestination::Worker;
|
||||
break;
|
||||
return RequestDestination::Worker;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER:
|
||||
destination = RequestDestination::Sharedworker;
|
||||
break;
|
||||
return RequestDestination::Sharedworker;
|
||||
case nsIContentPolicy::TYPE_IMAGESET:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_IMAGE:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_IMAGE_FAVICON:
|
||||
case nsIContentPolicy::TYPE_IMAGE:
|
||||
destination = RequestDestination::Image;
|
||||
break;
|
||||
return RequestDestination::Image;
|
||||
case nsIContentPolicy::TYPE_STYLESHEET:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD:
|
||||
destination = RequestDestination::Style;
|
||||
break;
|
||||
return RequestDestination::Style;
|
||||
case nsIContentPolicy::TYPE_OBJECT:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_OBJECT:
|
||||
destination = RequestDestination::Object;
|
||||
break;
|
||||
return RequestDestination::Object;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_EMBED:
|
||||
destination = RequestDestination::Embed;
|
||||
break;
|
||||
return RequestDestination::Embed;
|
||||
case nsIContentPolicy::TYPE_DOCUMENT:
|
||||
return RequestDestination::Document;
|
||||
case nsIContentPolicy::TYPE_SUBDOCUMENT:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_IFRAME:
|
||||
destination = RequestDestination::Document;
|
||||
break;
|
||||
return RequestDestination::Iframe;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_FRAME:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::Frame;
|
||||
case nsIContentPolicy::TYPE_REFRESH:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_PING:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_XMLHTTPREQUEST:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_OBJECT_SUBREQUEST:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_DTD:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_DTD:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_FORCE_ALLOWED_DTD:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_FONT:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_FONT_PRELOAD:
|
||||
destination = RequestDestination::Font;
|
||||
break;
|
||||
return RequestDestination::Font;
|
||||
case nsIContentPolicy::TYPE_MEDIA:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_AUDIO:
|
||||
destination = RequestDestination::Audio;
|
||||
break;
|
||||
return RequestDestination::Audio;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_VIDEO:
|
||||
destination = RequestDestination::Video;
|
||||
break;
|
||||
return RequestDestination::Video;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_TRACK:
|
||||
destination = RequestDestination::Track;
|
||||
break;
|
||||
return RequestDestination::Track;
|
||||
case nsIContentPolicy::TYPE_WEBSOCKET:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_CSP_REPORT:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::Report;
|
||||
case nsIContentPolicy::TYPE_XSLT:
|
||||
destination = RequestDestination::Xslt;
|
||||
break;
|
||||
return RequestDestination::Xslt;
|
||||
case nsIContentPolicy::TYPE_BEACON:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_FETCH:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_FETCH_PRELOAD:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_WEB_MANIFEST:
|
||||
destination = RequestDestination::Manifest;
|
||||
break;
|
||||
return RequestDestination::Manifest;
|
||||
case nsIContentPolicy::TYPE_SAVEAS_DOWNLOAD:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_SPECULATIVE:
|
||||
destination = RequestDestination::_empty;
|
||||
break;
|
||||
return RequestDestination::_empty;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_AUDIOWORKLET:
|
||||
destination = RequestDestination::Audioworklet;
|
||||
break;
|
||||
return RequestDestination::Audioworklet;
|
||||
case nsIContentPolicy::TYPE_INTERNAL_PAINTWORKLET:
|
||||
destination = RequestDestination::Paintworklet;
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(false, "Unhandled nsContentPolicyType value");
|
||||
return RequestDestination::Paintworklet;
|
||||
case nsIContentPolicy::TYPE_INVALID:
|
||||
break;
|
||||
}
|
||||
|
||||
return destination;
|
||||
MOZ_ASSERT(false, "Unhandled nsContentPolicyType value");
|
||||
return RequestDestination::_empty;
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -33,41 +33,42 @@ namespace dom {
|
||||
|
||||
/*
|
||||
* The mapping of RequestDestination and nsContentPolicyType is currently as the
|
||||
* following. Note that this mapping is not perfect yet (see the TODO comments
|
||||
* below for examples).
|
||||
* following.
|
||||
*
|
||||
* RequestDestination| nsContentPolicyType
|
||||
* ------------------+--------------------
|
||||
* audio | TYPE_INTERNAL_AUDIO
|
||||
* audioworklet | TYPE_INTERNAL_AUDIOWORKLET
|
||||
* document | TYPE_DOCUMENT, TYPE_INTERNAL_IFRAME, TYPE_SUBDOCUMENT
|
||||
* embed | TYPE_INTERNAL_EMBED
|
||||
* font | TYPE_FONT, TYPE_INTERNAL_FONT_PRELOAD
|
||||
* image | TYPE_INTERNAL_IMAGE, TYPE_INTERNAL_IMAGE_PRELOAD,
|
||||
* "audio" | TYPE_INTERNAL_AUDIO
|
||||
* "audioworklet" | TYPE_INTERNAL_AUDIOWORKLET
|
||||
* "document" | TYPE_DOCUMENT
|
||||
* "embed" | TYPE_INTERNAL_EMBED
|
||||
* "font" | TYPE_FONT, TYPE_INTERNAL_FONT_PRELOAD
|
||||
* "frame" | TYPE_INTERNAL_FRAME
|
||||
* "iframe" | TYPE_SUBDOCUMENT, TYPE_INTERNAL_IFRAME
|
||||
* "image" | TYPE_INTERNAL_IMAGE, TYPE_INTERNAL_IMAGE_PRELOAD,
|
||||
* | TYPE_IMAGE, TYPE_INTERNAL_IMAGE_FAVICON, TYPE_IMAGESET
|
||||
* manifest | TYPE_WEB_MANIFEST
|
||||
* object | TYPE_INTERNAL_OBJECT, TYPE_OBJECT
|
||||
* "manifest" | TYPE_WEB_MANIFEST
|
||||
* "object" | TYPE_INTERNAL_OBJECT, TYPE_OBJECT
|
||||
* "paintworklet" | TYPE_INTERNAL_PAINTWORKLET
|
||||
* report" | TODO
|
||||
* script | TYPE_INTERNAL_SCRIPT, TYPE_INTERNAL_SCRIPT_PRELOAD,
|
||||
* "report" | TYPE_CSP_REPORT
|
||||
* "script" | TYPE_INTERNAL_SCRIPT, TYPE_INTERNAL_SCRIPT_PRELOAD,
|
||||
* | TYPE_INTERNAL_MODULE, TYPE_INTERNAL_MODULE_PRELOAD,
|
||||
* | TYPE_SCRIPT,
|
||||
* | TYPE_INTERNAL_SERVICE_WORKER,
|
||||
* | TYPE_INTERNAL_WORKER_IMPORT_SCRIPTS,
|
||||
* | TYPE_INTERNAL_CHROMEUTILS_COMPILED_SCRIPT
|
||||
* | TYPE_INTERNAL_FRAME_MESSAGEMANAGER_SCRIPT
|
||||
* sharedworker | TYPE_INTERNAL_SHARED_WORKER
|
||||
* serviceworker | The spec lists this as a valid value for the enum,
|
||||
* "sharedworker" | TYPE_INTERNAL_SHARED_WORKER
|
||||
* "serviceworker" | The spec lists this as a valid value for the enum,
|
||||
* | however it is impossible to observe a request with this
|
||||
* | destination value.
|
||||
* style | TYPE_INTERNAL_STYLESHEET,
|
||||
* "style" | TYPE_INTERNAL_STYLESHEET,
|
||||
* | TYPE_INTERNAL_STYLESHEET_PRELOAD,
|
||||
* | TYPE_STYLESHEET
|
||||
* track | TYPE_INTERNAL_TRACK
|
||||
* video | TYPE_INTERNAL_VIDEO
|
||||
* worker | TYPE_INTERNAL_WORKER
|
||||
* xslt | TYPE_XSLT
|
||||
* _empty | Default for everything else.
|
||||
* "track" | TYPE_INTERNAL_TRACK
|
||||
* "video" | TYPE_INTERNAL_VIDEO
|
||||
* "worker" | TYPE_INTERNAL_WORKER
|
||||
* "xslt" | TYPE_XSLT
|
||||
* "" | Default for everything else.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -69,9 +69,9 @@ dictionary RequestInit {
|
||||
|
||||
enum RequestDestination {
|
||||
"",
|
||||
"audio", "audioworklet", "document", "embed", "font", "image", "manifest", "object",
|
||||
"paintworklet", "report", "script", "sharedworker", "style", "track", "video",
|
||||
"worker", "xslt"
|
||||
"audio", "audioworklet", "document", "embed", "font", "frame", "iframe",
|
||||
"image", "manifest", "object", "paintworklet", "report", "script",
|
||||
"sharedworker", "style", "track", "video", "worker", "xslt"
|
||||
};
|
||||
|
||||
enum RequestMode { "same-origin", "no-cors", "cors", "navigate" };
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
[fetch-destination-frame.https.html]
|
||||
[frame fetches with a "frame" Request.destination]
|
||||
expected: FAIL
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
[fetch-destination-iframe.https.html]
|
||||
[iframe fetches with a "iframe" Request.destination]
|
||||
expected: FAIL
|
||||
|
||||
Reference in New Issue
Block a user