Bug 1321509 - allow non devtools prefs to be loaded in webpack prefs loader;r=tromey

MozReview-Commit-ID: IVWK16kvWzw

--HG--
extra : rebase_source : ef864848933984cac0677f0b7a3f9a10c3a875be
This commit is contained in:
Julian Descottes 2016-11-22 16:47:15 +01:00
parent 3f0ff25997
commit 54c3ef166c

View File

@ -6,7 +6,20 @@
"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();
@ -47,7 +60,7 @@ module.exports = function (content) {
}
}
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.