mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1264063 - 2 - Make the CPOW rule log errors and ignore ContentTask.spawn; r=Mossop
MozReview-Commit-ID: KN2MAgAvX2c --HG-- extra : rebase_source : 099489c97f2b0fcae3903cbdd06d43b84e4113b1
This commit is contained in:
parent
5574624f3f
commit
f469bf022f
@ -33,7 +33,7 @@
|
|||||||
// Rules from the mozilla plugin
|
// Rules from the mozilla plugin
|
||||||
"mozilla/mark-test-function-used": 1,
|
"mozilla/mark-test-function-used": 1,
|
||||||
"mozilla/no-aArgs": 1,
|
"mozilla/no-aArgs": 1,
|
||||||
"mozilla/no-cpows-in-tests": 1,
|
"mozilla/no-cpows-in-tests": 2,
|
||||||
// See bug 1224289.
|
// See bug 1224289.
|
||||||
"mozilla/reject-importGlobalProperties": 1,
|
"mozilla/reject-importGlobalProperties": 1,
|
||||||
"mozilla/var-only-at-top-level": 1,
|
"mozilla/var-only-at-top-level": 1,
|
||||||
|
@ -24,7 +24,7 @@ addRDMTask(TEST_URL, function* ({ ui }) {
|
|||||||
// Browser's location should match original tab
|
// Browser's location should match original tab
|
||||||
yield waitForFrameLoad(ui, TEST_URL);
|
yield waitForFrameLoad(ui, TEST_URL);
|
||||||
let location = yield spawnViewportTask(ui, {}, function* () {
|
let location = yield spawnViewportTask(ui, {}, function* () {
|
||||||
return content.location.href;
|
return content.location.href; // eslint-disable-line
|
||||||
});
|
});
|
||||||
is(location, TEST_URL, "Viewport location matches");
|
is(location, TEST_URL, "Viewport location matches");
|
||||||
});
|
});
|
||||||
|
@ -22,12 +22,18 @@ var cpows = [
|
|||||||
/^window\.content/
|
/^window\.content/
|
||||||
];
|
];
|
||||||
|
|
||||||
|
var isInContentTask = false;
|
||||||
|
|
||||||
module.exports = function(context) {
|
module.exports = function(context) {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Helpers
|
// Helpers
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function showError(node, identifier) {
|
function showError(node, identifier) {
|
||||||
|
if (isInContentTask) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
context.report({
|
context.report({
|
||||||
node: node,
|
node: node,
|
||||||
message: identifier +
|
message: identifier +
|
||||||
@ -35,11 +41,32 @@ module.exports = function(context) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isContentTask(node) {
|
||||||
|
return node &&
|
||||||
|
node.type === "MemberExpression" &&
|
||||||
|
node.property.type === "Identifier" &&
|
||||||
|
node.property.name === "spawn" &&
|
||||||
|
node.object.type === "Identifier" &&
|
||||||
|
node.object.name === "ContentTask";
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Public
|
// Public
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
CallExpression: function(node) {
|
||||||
|
if (isContentTask(node.callee)) {
|
||||||
|
isInContentTask = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"CallExpression:exit": function(node) {
|
||||||
|
if (isContentTask(node.callee)) {
|
||||||
|
isInContentTask = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
MemberExpression: function(node) {
|
MemberExpression: function(node) {
|
||||||
if (!helpers.getIsBrowserMochitest(this)) {
|
if (!helpers.getIsBrowserMochitest(this)) {
|
||||||
return;
|
return;
|
||||||
@ -77,7 +104,6 @@ module.exports = function(context) {
|
|||||||
node.parent.object.name != "content") {
|
node.parent.object.name != "content") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
showError(node, expression);
|
showError(node, expression);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user