Bug 1291049 - allow non devtools prefs to be loaded in webpack prefs loader;r=tromey
MozReview-Commit-ID: B6eJcqt7XLK
--- a/devtools/client/inspector/webpack/prefs-loader.js
+++ b/devtools/client/inspector/webpack/prefs-loader.js
@@ -1,17 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Rewrite devtools.js or all.js, leaving just the relevant pref() calls.
"use strict";
-const PREF_RX = new RegExp("^ *pref\\(\"devtools");
+const PREF_WHITELIST = [
+ "devtools",
+ "layout.css.grid.enabled"
+];
+
+const acceptLine = function (line) {
+ let matches = line.match(/^ *pref\("([^"]+)"/);
+ if (!matches || !matches[1]) {
+ return false;
+ }
+
+ let [, prefName] = matches;
+ return PREF_WHITELIST.some(filter => prefName.startsWith(filter));
+};
module.exports = function (content) {
this.cacheable && this.cacheable();
// If we're reading devtools.js we have to do some reprocessing.
// If we're reading all.js we just assume we can dump all the
// conditionals.
let isDevtools = this.request.endsWith("/devtools.js");
@@ -42,17 +55,17 @@ module.exports = function (content) {
throw new Error("missing line in ifMap: " + line);
}
ignoring = !ifMap[line];
} else if (line.startsWith("#else")) {
ignoring = !ignoring;
}
}
- if (continuation || (!ignoring && PREF_RX.test(line))) {
+ if (continuation || (!ignoring && acceptLine(line))) {
newLines.push(line);
// The call to pref(...); might span more than one line.
continuation = !/\);/.test(line);
}
}
return newLines.join("\n");
};