| Index: lib/contentPolicy.js |
| =================================================================== |
| --- a/lib/contentPolicy.js |
| +++ b/lib/contentPolicy.js |
| @@ -48,6 +48,22 @@ |
| ]), |
| /** |
| + * |
| + */ |
| + contentTypesMap: new Map([ |
| + // Treat navigator.sendBeacon() the same as <a ping>, |
| + // it's essentially the same concept - merely generalized. |
| + ["BEACON", "PING"], |
| + |
| + // Treat <img srcset> and <picture> the same as other images. |
| + ["IMAGESET", "IMAGE"], |
| + |
| + // Treat fetch() the same as XMLHttpRequest, |
| + // it's essentially the same - merely a more modern API. |
| + ["FETCH", "XMLHTTPREQUEST"] |
| + ]), |
| + |
| + /** |
| * Set of content types that aren't associated with a visual document area |
| * @type Set.<string> |
| */ |
| @@ -67,6 +83,9 @@ |
| */ |
| 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); |
| @@ -125,14 +144,8 @@ |
| if (!this.isBlockableScheme(location)) |
| return response(true, false); |
| - // Treat navigator.sendBeacon() the same as <a ping>, it's essentially the |
| - // same concept - merely generalized. |
| - if (contentType == "BEACON") |
| - contentType = "PING"; |
| - |
| // Interpret unknown types as "other" |
| - if (!this.contentTypes.has(contentType)) |
| - contentType = "OTHER"; |
| + contentType = this.contentTypesMap.get(contentType) || "OTHER"; |
| let wndLocation = frames[0].location; |
| let docDomain = getHostname(wndLocation); |