Index: lib/contentPolicy.js |
=================================================================== |
--- a/lib/contentPolicy.js |
+++ b/lib/contentPolicy.js |
@@ -48,6 +48,24 @@ |
]), |
Wladimir Palant
2015/12/29 23:19:48
This member becomes unnecessary with your change,
Sebastian Noack
2015/12/30 15:54:58
Note that chrome/content/ui/sidebar.js and chrome/
Wladimir Palant
2016/01/06 12:46:00
You are right but that's not a reason to duplicate
Sebastian Noack
2016/01/06 13:29:50
There you go: https://codereview.adblockplus.org/2
|
/** |
+ * 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([ |
+ // 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 +85,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 +146,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); |