Index: lib/contentPolicy.js |
=================================================================== |
--- a/lib/contentPolicy.js |
+++ b/lib/contentPolicy.js |
@@ -38,32 +38,30 @@ |
var Policy = exports.Policy = |
{ |
/** |
- * Set of explicitly supported content types |
- * @type Set.<string> |
- */ |
- contentTypes: new Set([ |
- "OTHER", "SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", "SUBDOCUMENT", "DOCUMENT", |
- "XMLHTTPREQUEST", "OBJECT_SUBREQUEST", "FONT", "MEDIA", "PING", "ELEMHIDE", |
- "POPUP", "GENERICHIDE", "GENERICBLOCK" |
- ]), |
- |
- /** |
* Map of content types reported by Firefox to the respecitve content types |
* used by Adblock Plus. Other content types are simply mapped to OTHER. |
* @type Map.<string,string> |
*/ |
- contentTypesMap: new Map([ |
+ contentTypes: new Map(function* () |
+ { |
// Treat navigator.sendBeacon() the same as <a ping>, |
// it's essentially the same concept - merely generalized. |
- ["BEACON", "PING"], |
+ yield ["BEACON", "PING"]; |
// Treat <img srcset> and <picture> the same as other images. |
- ["IMAGESET", "IMAGE"], |
+ yield ["IMAGESET", "IMAGE"]; |
// Treat fetch() the same as XMLHttpRequest, |
// it's essentially the same - merely a more modern API. |
- ["FETCH", "XMLHTTPREQUEST"] |
- ]), |
+ yield ["FETCH", "XMLHTTPREQUEST"]; |
+ |
+ // Everything else is mapped to itself |
+ for (let contentType of ["OTHER", "SCRIPT", "IMAGE", "STYLESHEET", "OBJECT", |
+ "SUBDOCUMENT", "DOCUMENT", "XMLHTTPREQUEST", |
+ "OBJECT_SUBREQUEST", "FONT", "MEDIA", "PING", |
+ "ELEMHIDE", "POPUP", "GENERICHIDE", "GENERICBLOCK"]) |
+ yield [contentType, contentType]; |
+ }()), |
/** |
* Set of content types that aren't associated with a visual document area |
@@ -85,9 +83,6 @@ |
*/ |
init: function() |
{ |
- for (let contentType of this.contentTypes) |
- this.contentTypesMap.set(contentType, contentType); |
- |
// whitelisted URL schemes |
for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) |
this.whitelistSchemes.add(scheme); |
@@ -147,7 +142,7 @@ |
return response(true, false); |
// Interpret unknown types as "other" |
- contentType = this.contentTypesMap.get(contentType) || "OTHER"; |
+ contentType = this.contentTypes.get(contentType) || "OTHER"; |
let wndLocation = frames[0].location; |
let docDomain = getHostname(wndLocation); |