Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/elemHideFF.js

Issue 29352634: Issue 4198 - Don't send Map objects in messages when using Firefox 40 and below (Closed) Base URL: https://hg.adblockplus.org/adblockplus
Patch Set: Created Sept. 12, 2016, 9:11 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHideFF.js
===================================================================
--- a/lib/elemHideFF.js
+++ b/lib/elemHideFF.js
@@ -12,16 +12,18 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
+let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
+
let {port} = require("messaging");
let {ElemHide} = require("elemHide");
let {FilterNotifier} = require("filterNotifier");
let {FilterStorage} = require("filterStorage");
let {Prefs} = require("prefs");
let {Policy} = require("contentPolicy");
let {Utils} = require("utils");
@@ -34,17 +36,37 @@ FilterNotifier.on("elemhideupdate", () =
isDirty = true;
Utils.runAsync(() => {
isDirty = false;
port.emit("elemhideupdate")
});
}
});
-port.on("getSelectors", () => ElemHide.getSelectors());
+let translateMap = map => map;
+if (Services.vc.compare(Utils.platformVersion, "40.0") <= 0)
+{
+ translateMap = map =>
+ {
+ // We cannot send Map objects with Gecko 40 and below, "translate" them
+ // into nested arrays. This isn't very efficient but that should be ok as
+ // long as only outdated Firefox versions are affected.
+ let translated = [];
+ for (let [key, value] of map)
+ {
+ if (value instanceof Map)
+ translated.push([key, translateMap(value)]);
+ else
+ translated.push([key, value]);
+ }
+ return translated;
+ };
+}
+
+port.on("getSelectors", () => translateMap(ElemHide.getSelectors()));
port.on("elemhideEnabled", ({frames, isPrivate}) =>
{
if (!Prefs.enabled)
return {enabled: false};
let hit = Policy.isFrameWhitelisted(frames, true);
if (hit)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld