Bug 1442559 part 2 - Use a separate whitelist for prop names. r=Gijs

MozReview-Commit-ID: LT50Q5xFydH

--HG--
extra : rebase_source : dbd74c080e28393f14d2567051b8007c77bbff8b
This commit is contained in:
Xidorn Quan 2018-03-03 11:55:42 +11:00
parent 4fcb2e8136
commit 69475f1af2

View File

@ -69,7 +69,28 @@ let whitelist = [
intermittent: true,
errorMessage: /Property contained reference to invalid variable.*color/i,
isFromDevTools: true},
];
if (!Services.prefs.getBoolPref("full-screen-api.unprefix.enabled")) {
whitelist.push({
sourceName: /(?:res|gre-resources)\/(ua|html)\.css$/i,
errorMessage: /Unknown pseudo-class .*\bfullscreen\b/i,
isFromDevTools: false
});
}
// Platform can be "linux", "macosx" or "win". If omitted, the exception applies to all platforms.
let allowedImageReferences = [
// Bug 1302691
{file: "chrome://devtools/skin/images/dock-bottom-minimize@2x.png",
from: "chrome://devtools/skin/toolbox.css",
isFromDevTools: true},
{file: "chrome://devtools/skin/images/dock-bottom-maximize@2x.png",
from: "chrome://devtools/skin/toolbox.css",
isFromDevTools: true},
];
let propNameWhitelist = [
// These are CSS custom properties that we found a definition of but
// no reference to.
// Bug 1441837
@ -131,25 +152,6 @@ let whitelist = [
isFromDevTools: true},
];
if (!Services.prefs.getBoolPref("full-screen-api.unprefix.enabled")) {
whitelist.push({
sourceName: /(?:res|gre-resources)\/(ua|html)\.css$/i,
errorMessage: /Unknown pseudo-class .*\bfullscreen\b/i,
isFromDevTools: false
});
}
// Platform can be "linux", "macosx" or "win". If omitted, the exception applies to all platforms.
let allowedImageReferences = [
// Bug 1302691
{file: "chrome://devtools/skin/images/dock-bottom-minimize@2x.png",
from: "chrome://devtools/skin/toolbox.css",
isFromDevTools: true},
{file: "chrome://devtools/skin/images/dock-bottom-maximize@2x.png",
from: "chrome://devtools/skin/toolbox.css",
isFromDevTools: true},
];
// Add suffix to stylesheets' URI so that we always load them here and
// have them parsed. Add a random number so that even if we run this
// test multiple times, it would be unlikely to affect each other.
@ -438,7 +440,7 @@ add_task(async function checkAllTheCSS() {
for (let [prop, refCount] of customPropsToReferencesMap) {
if (!refCount) {
let ignored = false;
for (let item of whitelist) {
for (let item of propNameWhitelist) {
if (item.propName == prop &&
isDevtools == item.isFromDevTools) {
item.used = true;
@ -461,24 +463,18 @@ add_task(async function checkAllTheCSS() {
is(errors.length, 0, "All the styles (" + allPromises.length + ") loaded without errors.");
// Confirm that all whitelist rules have been used.
for (let item of whitelist) {
if (!item.used &&
(!item.platforms || item.platforms.includes(AppConstants.platform)) &&
isDevtools == item.isFromDevTools &&
!item.intermittent) {
ok(false, "Unused whitelist item. " + dumpWhitelistItem(item));
}
}
// Confirm that all file whitelist rules have been used.
for (let item of allowedImageReferences) {
if (!item.used && isDevtools == item.isFromDevTools &&
(!item.platforms || item.platforms.includes(AppConstants.platform))) {
ok(false, "Unused file whitelist item. " +
" file: " + item.file +
" from: " + item.from);
function checkWhitelist(list) {
for (let item of list) {
if (!item.used && isDevtools == item.isFromDevTools &&
(!item.platforms || item.platforms.includes(AppConstants.platform)) &&
!item.intermittent) {
ok(false, "Unused whitelist item: " + dumpWhitelistItem(item));
}
}
}
checkWhitelist(whitelist);
checkWhitelist(allowedImageReferences);
checkWhitelist(propNameWhitelist);
// Clean up to avoid leaks:
iframe.remove();