From 9a1b56a899575d71e07eb3466e5fbf16d5a18571 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 1 May 2017 00:15:51 +0100 Subject: FF - Fix updates from the exclusions popup This stops |Exclusions| from holding a reference to the |value| parameter passed to |Settings.set|. In Firefox, this object is garbage collected when the owning context (the exclusions popup) is closed. The fix for all such cases in the future is to switch to using |Settings.get|, which implicitly does |JSON.parse JSON.stringify value| and thus returns an object in the same context as |Settings|. We could fix this generally by doing this for the |Settings.performPostUpdateHook| call in |Settings.set| instead. However, I'm not convinced that it warrants the overhead of a |JSON.parse| for every |Settings.set| call. --- lib/settings.coffee | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/settings.coffee b/lib/settings.coffee index 9fa27c5f..08986723 100644 --- a/lib/settings.coffee +++ b/lib/settings.coffee @@ -89,6 +89,9 @@ Settings = # Remove options installed by the "copyNonDefaultsToChromeStorage-20150717" migration; see below. @log " chrome.storage.local.remove(#{key})" chrome.storage.local.remove key + # NOTE(mrmr1993): In FF, |value| will be garbage collected when the page owning it is unloaded. + # Any postUpdateHooks that can be called from the options page/exclusions popup should be careful not to + # use |value| asynchronously, or else it may refer to a |DeadObject| and accesses will throw an error. @performPostUpdateHook key, value clear: (key) -> -- cgit v1.2.3