Bug 1348215. Fix the SIMPLE_WORKER_PREF setup to not mishandle pref names that start with the worker pref name. r=ehsan
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 17 Mar 2017 14:10:40 -0400
changeset 500827 5491d388cdf43fae200369d886e063b779f68c00
parent 500826 1143fd4a40f5c1d4fd08a0680d986070c2e9b6e1
child 500858 5800d1391c10dcd268421a374bde6a514f8dcd10
push id49816
push userbmo:tchiovoloni@mozilla.com
push dateFri, 17 Mar 2017 20:44:02 +0000
reviewersehsan
bugs1348215
milestone55.0a1
Bug 1348215. Fix the SIMPLE_WORKER_PREF setup to not mishandle pref names that start with the worker pref name. r=ehsan Without this change, we will call WorkerPrefChanged if a pref whose name just _starts_ with the name of one of our WORKER_SIMPLE_PREF prefs changes. Then in WorkerPrefChanged we will get the value of the pref that changed, and store it under the key identified by the closure, thus writing the value of an incorrect pref in there. MozReview-Commit-ID: JTsvvtC5P1o
dom/workers/RuntimeService.cpp
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -2047,22 +2047,24 @@ RuntimeService::Init()
                                              PREF_JS_OPTIONS_PREFIX PREF_GCZEAL,
                                              nullptr)) ||
 #endif
 
 #define WORKER_SIMPLE_PREF(name, getter, NAME)                                \
       NS_FAILED(Preferences::RegisterCallbackAndCall(                         \
                   WorkerPrefChanged,                                          \
                   name,                                                       \
-                  reinterpret_cast<void*>(WORKERPREF_##NAME))) ||
+                  reinterpret_cast<void*>(WORKERPREF_##NAME),                 \
+                  Preferences::ExactMatch)) ||
 #define WORKER_PREF(name, callback)                                           \
       NS_FAILED(Preferences::RegisterCallbackAndCall(                         \
                   callback,                                                   \
                   name,                                                       \
-                  nullptr)) ||
+                  nullptr,                                                    \
+                  Preferences::ExactMatch)) ||
 #include "WorkerPrefs.h"
 #undef WORKER_SIMPLE_PREF
 #undef WORKER_PREF
 
       NS_FAILED(Preferences::RegisterCallbackAndCall(
                                                    LoadContextOptions,
                                                    PREF_WORKERS_OPTIONS_PREFIX,
                                                    nullptr)) ||