Bug 1554142 - Enable most ESLint rules for image/. r=aosmond

Depends on D32450

Differential Revision: https://phabricator.services.mozilla.com/D32493

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2019-05-24 17:34:09 +00:00
parent 6971980f49
commit 99101f0542
11 changed files with 52 additions and 23 deletions

View file

@ -14,7 +14,6 @@ obj*/**
# We ignore all these directories by default, until we get them enabled. # We ignore all these directories by default, until we get them enabled.
# If you are enabling a directory, please add directory specific exclusions # If you are enabling a directory, please add directory specific exclusions
# below. # below.
image/**
layout/** layout/**
netwerk/cookie/test/browser/** netwerk/cookie/test/browser/**
netwerk/test/browser/** netwerk/test/browser/**

View file

@ -158,8 +158,40 @@ module.exports = {
"quotes": "off", "quotes": "off",
"semi": "off", "semi": "off",
"space-infix-ops": "off", "space-infix-ops": "off",
}
}, {
"files": [
"image/**",
],
"rules": {
"mozilla/consistent-if-bracing": "off",
"mozilla/use-chromeutils-generateqi": "off",
"mozilla/use-services": "off",
"no-array-constructor": "off",
"no-implied-eval": "off",
"no-redeclare": "off",
"no-self-assign": "off",
"no-throw-literal": "off",
"no-undef": "off",
"no-unneeded-ternary": "off",
"no-unused-vars": "off",
// Not enabling the rules below for now pending prettier roll-out.
"brace-style": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"key-spacing": "off",
"keyword-spacing": "off",
"no-extra-semi": "off",
"no-tabs": "off",
"no-mixed-spaces-and-tabs": "off",
"no-multi-spaces": "off",
"no-trailing-spaces": "off",
"padded-blocks": "off",
"quotes": "off",
"semi": "off",
"space-before-function-paren": "off",
"space-infix-ops": "off",
} }
}] }]
}; };

View file

@ -229,14 +229,12 @@ AnimationTest.prototype.setupPolledImage = function ()
this.cleanUpAndFinish(); this.cleanUpAndFinish();
} }
} else { } else if (!gIsRefImageLoaded) {
if (!gIsRefImageLoaded) {
this.myImage = new Image(); this.myImage = new Image();
this.myImage.onload = reuseImageCallback; this.myImage.onload = reuseImageCallback;
document.getElementById(this.imageElementId).setAttribute('src', document.getElementById(this.imageElementId).setAttribute('src',
this.referenceElementId); this.referenceElementId);
} }
}
} }
AnimationTest.prototype.checkImage = function () AnimationTest.prototype.checkImage = function ()

View file

@ -138,7 +138,7 @@ function startTest(i)
testData.op + " " + testData.test + " " + testData.reference); testData.op + " " + testData.test + " " + testData.reference);
RemoveFinishDependency(); RemoveFinishDependency();
} }
var iframe = { element: element, loaded: false }; var iframe = { element, loaded: false };
return iframe; return iframe;
} }

View file

@ -44,7 +44,7 @@ RemoteCanvas.prototype.load = function(cb) {
// Here is where the magic happens... add a listener to the // Here is where the magic happens... add a listener to the
// frame's onload event - it will call handleEvent // frame's onload event - it will call handleEvent
iframe.addEventListener("load", this, true); iframe.addEventListener("load", this, true);
//append to the end of the page // append to the end of the page
window.document.body.appendChild(iframe); window.document.body.appendChild(iframe);
}; };
@ -60,7 +60,7 @@ RemoteCanvas.prototype.handleEvent = function() {
// SpecialPowers.snapshotRect method // SpecialPowers.snapshotRect method
var remoteWindow = ldrFrame.contentWindow; var remoteWindow = ldrFrame.contentWindow;
//Draw canvas // Draw canvas
canvas.style.width = RemoteCanvas.CANVAS_WIDTH + "px"; canvas.style.width = RemoteCanvas.CANVAS_WIDTH + "px";
canvas.style.height = RemoteCanvas.CANVAS_HEIGHT + "px"; canvas.style.height = RemoteCanvas.CANVAS_HEIGHT + "px";
canvas.width = RemoteCanvas.CANVAS_WIDTH; canvas.width = RemoteCanvas.CANVAS_WIDTH;

View file

@ -44,7 +44,7 @@ RemoteCanvas.prototype.load = function(cb) {
// Here is where the magic happens... add a listener to the // Here is where the magic happens... add a listener to the
// frame's onload event - it will call handleEvent // frame's onload event - it will call handleEvent
iframe.addEventListener("load", this, true); iframe.addEventListener("load", this, true);
//append to the end of the page // append to the end of the page
window.document.body.appendChild(iframe); window.document.body.appendChild(iframe);
}; };
@ -60,7 +60,7 @@ RemoteCanvas.prototype.handleEvent = function() {
// SpecialPowers.snapshotRect method // SpecialPowers.snapshotRect method
var remoteWindow = ldrFrame.contentWindow; var remoteWindow = ldrFrame.contentWindow;
//Draw canvas // Draw canvas
canvas.style.width = RemoteCanvas.CANVAS_WIDTH + "px"; canvas.style.width = RemoteCanvas.CANVAS_WIDTH + "px";
canvas.style.height = RemoteCanvas.CANVAS_HEIGHT + "px"; canvas.style.height = RemoteCanvas.CANVAS_HEIGHT + "px";
canvas.width = RemoteCanvas.CANVAS_WIDTH; canvas.width = RemoteCanvas.CANVAS_WIDTH;

View file

@ -23,14 +23,14 @@ var obs = Cc["@mozilla.org/observer-service;1"].getService();
obs = obs.QueryInterface(Ci.nsIObserverService); obs = obs.QueryInterface(Ci.nsIObserverService);
var observer = { var observer = {
QueryInterface: function (aIID) { QueryInterface (aIID) {
if (aIID.equals(Ci.nsISupports) || if (aIID.equals(Ci.nsISupports) ||
aIID.equals(Ci.nsIObserver)) aIID.equals(Ci.nsIObserver))
return this; return this;
throw Cr.NS_ERROR_NO_INTERFACE; throw Cr.NS_ERROR_NO_INTERFACE;
}, },
observe: function(subject, topic, data) { observe(subject, topic, data) {
ok(topic == "net:failed-to-process-uri-content", "wrong topic"); ok(topic == "net:failed-to-process-uri-content", "wrong topic");
subject = subject.QueryInterface(Ci.nsIURI); subject = subject.QueryInterface(Ci.nsIURI);
is(subject.asciiSpec, "http://mochi.test:8888/tests/image/test/mochitest/invalid.jpg", "wrong subject"); is(subject.asciiSpec, "http://mochi.test:8888/tests/image/test/mochitest/invalid.jpg", "wrong subject");

View file

@ -40,7 +40,7 @@ function checkClone(other_listener, aRequest)
do_test_pending(); do_test_pending();
// For as long as clone notification is synchronous, we can't test the clone state reliably. // For as long as clone notification is synchronous, we can't test the clone state reliably.
var listener = new ImageListener(null, function(foo, bar) { do_test_finished(); } /*getCloneStopCallback(other_listener)*/); var listener = new ImageListener(null, function(foo, bar) { do_test_finished(); } /* getCloneStopCallback(other_listener)*/);
listener.synchronous = false; listener.synchronous = false;
var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools) var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
.createScriptedObserver(listener); .createScriptedObserver(listener);
@ -123,7 +123,7 @@ function getChannelLoadImageStopCallback(streamlistener, next)
function checkSecondChannelLoad() function checkSecondChannelLoad()
{ {
do_test_pending(); do_test_pending();
var channel = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true}); var channel = NetUtil.newChannel({uri, loadUsingSystemPrincipal: true});
var channellistener = new ChannelListener(); var channellistener = new ChannelListener();
channel.asyncOpen(channellistener); channel.asyncOpen(channellistener);
@ -148,7 +148,7 @@ function run_loadImageWithChannel_tests()
gCurrentLoader = Cc["@mozilla.org/image/loader;1"].createInstance(Ci.imgILoader); gCurrentLoader = Cc["@mozilla.org/image/loader;1"].createInstance(Ci.imgILoader);
do_test_pending(); do_test_pending();
var channel = NetUtil.newChannel({uri: uri, loadUsingSystemPrincipal: true}); var channel = NetUtil.newChannel({uri, loadUsingSystemPrincipal: true});
var channellistener = new ChannelListener(); var channellistener = new ChannelListener();
channel.asyncOpen(channellistener); channel.asyncOpen(channellistener);

View file

@ -193,7 +193,7 @@ function makeDataURLFromAsync(encoder, mimetype, expected) {
var asyncReader = var asyncReader =
{ {
onInputStreamReady: function(stream) onInputStreamReady(stream)
{ {
binarystream.setInputStream(stream); binarystream.setInputStream(stream);
var available = 0; var available = 0;

View file

@ -646,18 +646,18 @@ var testData =
for(var i=0; i<testData.length; ++i) { for(var i=0; i<testData.length; ++i) {
var dict = testData[i]; var dict = testData[i];
var imgFile = do_get_file(dict["refImage"]); var imgFile = do_get_file(dict.refImage);
var istream = getFileInputStream(imgFile); var istream = getFileInputStream(imgFile);
var refBytes = streamToArray(istream); var refBytes = streamToArray(istream);
imgFile = do_get_file(dict["preImage"]); imgFile = do_get_file(dict.preImage);
istream = getFileInputStream(imgFile); istream = getFileInputStream(imgFile);
var buffer = NetUtil.readInputStreamToString(istream, istream.available()); var buffer = NetUtil.readInputStreamToString(istream, istream.available());
var container = imgTools.decodeImageFromBuffer(buffer, buffer.length, var container = imgTools.decodeImageFromBuffer(buffer, buffer.length,
dict["preImageMimeType"]); dict.preImageMimeType);
istream = imgTools.encodeImage(container, dict["refImageMimeType"]); istream = imgTools.encodeImage(container, dict.refImageMimeType);
var sstream = Cc["@mozilla.org/storagestream;1"]. var sstream = Cc["@mozilla.org/storagestream;1"].
createInstance(Ci.nsIStorageStream); createInstance(Ci.nsIStorageStream);
@ -666,7 +666,7 @@ for(var i=0; i<testData.length; ++i) {
var bostream = Cc["@mozilla.org/network/buffered-output-stream;1"]. var bostream = Cc["@mozilla.org/network/buffered-output-stream;1"].
createInstance(Ci.nsIBufferedOutputStream); createInstance(Ci.nsIBufferedOutputStream);
//use a tiny buffer to make sure the image data doesn't fully fit in it // use a tiny buffer to make sure the image data doesn't fully fit in it
bostream.init(ostream, 8); bostream.init(ostream, 8);
bostream.writeFrom(istream, istream.available()); bostream.writeFrom(istream, istream.available());

View file

@ -37,8 +37,8 @@ function setup_chan(path, isPrivate, callback) {
var securityFlags = Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL; var securityFlags = Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;
var principal = Services.scriptSecurityManager var principal = Services.scriptSecurityManager
.createCodebasePrincipal(uri, {privateBrowsingId: isPrivate ? 1 : 0}); .createCodebasePrincipal(uri, {privateBrowsingId: isPrivate ? 1 : 0});
var chan = NetUtil.newChannel({uri: uri, loadingPrincipal: principal, var chan = NetUtil.newChannel({uri, loadingPrincipal: principal,
securityFlags: securityFlags, securityFlags,
contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE}); contentPolicyType: Ci.nsIContentPolicy.TYPE_INTERNAL_IMAGE});
chan.notificationCallbacks = isPrivate ? privateLoadContext chan.notificationCallbacks = isPrivate ? privateLoadContext
: nonPrivateLoadContext; : nonPrivateLoadContext;