Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1556840 - Enable more ESLint rules for image/. r=Standard8,aosmond
Browse files Browse the repository at this point in the history
  • Loading branch information
kanurag94 committed Aug 29, 2019
1 parent 2733ddb commit fcb1b9e
Show file tree
Hide file tree
Showing 32 changed files with 90 additions and 103 deletions.
17 changes: 0 additions & 17 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,6 @@ module.exports = {
"no-redeclare": "off",
"no-global-assign": "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",
}
}, {
"files": [
"netwerk/cookie/test/browser/**",
Expand Down
13 changes: 4 additions & 9 deletions image/test/browser/browser_bug666317.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
waitForExplicitFinish();
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");

var pageSource =
"<html><body>" +
Expand All @@ -8,9 +9,7 @@ var pageSource =
"</body></html>";

var oldDiscardingPref, oldTab, newTab;
var prefBranch = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService)
.getBranch("image.mem.");
var prefBranch = Services.prefs.getBranch("image.mem.");

var gWaitingForDiscard = false;
var gScriptedObserver;
Expand Down Expand Up @@ -42,9 +41,7 @@ function currentRequest() {

function isImgDecoded() {
let request = currentRequest();
return request.imageStatus & Ci.imgIRequest.STATUS_DECODE_COMPLETE
? true
: false;
return !!(request.imageStatus & Ci.imgIRequest.STATUS_DECODE_COMPLETE);
}

// Ensure that the image is decoded by drawing it to a canvas.
Expand Down Expand Up @@ -122,9 +119,7 @@ function step3() {
function step4() {
gWaitingForDiscard = true;

var os = Cc["@mozilla.org/observer-service;1"].getService(
Ci.nsIObserverService
);
var os = Services.obs;
os.notifyObservers(null, "memory-pressure", "heap-minimize");

// The DISCARD notification is delivered asynchronously. ImageObserver will
Expand Down
1 change: 1 addition & 0 deletions image/test/browser/browser_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var gTimer;

// Browsing to a new URL - pushing us into the bfcache - should cause
// animations to stop, and resume when we return
/* global yield */
function testBFCache() {
function theTest() {
var abort = false;
Expand Down
12 changes: 7 additions & 5 deletions image/test/mochitest/animationPolling.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// This file expects imgutils.js to be loaded as well.
/* import-globals-from imgutils.js */
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
var currentTest;
var gIsRefImageLoaded = false;
Expand All @@ -7,7 +9,7 @@ function pollForSuccess() {
if (!currentTest.isTestFinished) {
if (
!currentTest.reusingReferenceImage ||
(currentTest.reusingReferenceImage && gRefImageLoaded)
(currentTest.reusingReferenceImage && gIsRefImageLoaded)
) {
currentTest.checkImage();
}
Expand Down Expand Up @@ -301,7 +303,7 @@ AnimationTest.prototype.takeReferenceSnapshot = function() {

this.referenceSnapshot = snapshotWindow(window, false);

var snapResult = compareSnapshots(
let snapResult = compareSnapshots(
this.cleanSnapshot,
this.referenceSnapshot,
false
Expand All @@ -328,7 +330,7 @@ AnimationTest.prototype.takeReferenceSnapshot = function() {
"Reference snapshot shouldn't match clean (non-image) snapshot"
);

var dataString = "Reference Snapshot #" + this.numRefsTaken;
let dataString = "Reference Snapshot #" + this.numRefsTaken;
this.outputDebugInfo(
dataString,
"refSnapId",
Expand All @@ -343,7 +345,7 @@ AnimationTest.prototype.takeReferenceSnapshot = function() {
this.enableDisplay(referenceDiv);

this.referenceSnapshot = snapshotWindow(window, false);
var snapResult = compareSnapshots(
let snapResult = compareSnapshots(
this.cleanSnapshot,
this.referenceSnapshot,
false
Expand All @@ -370,7 +372,7 @@ AnimationTest.prototype.takeReferenceSnapshot = function() {
"Reference snapshot shouldn't match clean (non-image) snapshot"
);

var dataString = "Reference Snapshot #" + this.numRefsTaken;
let dataString = "Reference Snapshot #" + this.numRefsTaken;
this.outputDebugInfo(
dataString,
"refSnapId",
Expand Down
20 changes: 8 additions & 12 deletions image/test/mochitest/imgutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ function clearImageCache() {

// Helper function to determine if the frame is decoded for a given image id
function isFrameDecoded(id) {
return getImageStatus(id) & SpecialPowers.Ci.imgIRequest.STATUS_FRAME_COMPLETE
? true
: false;
return !!(
getImageStatus(id) & SpecialPowers.Ci.imgIRequest.STATUS_FRAME_COMPLETE
);
}

// Helper function to determine if the image is loaded for a given image id
function isImageLoaded(id) {
return getImageStatus(id) & SpecialPowers.Ci.imgIRequest.STATUS_LOAD_COMPLETE
? true
: false;
return !!(
getImageStatus(id) & SpecialPowers.Ci.imgIRequest.STATUS_LOAD_COMPLETE
);
}

// Helper function to get the status flags of an image
Expand Down Expand Up @@ -89,9 +89,7 @@ const DISCARD_TIMEOUT_PREF = {
};

function setImagePref(pref, val) {
var prefService = SpecialPowers.Cc[
"@mozilla.org/preferences-service;1"
].getService(SpecialPowers.Ci.nsIPrefService);
var prefService = SpecialPowers.Services.prefs;
var branch = prefService.getBranch(pref.branch);
if (val != null) {
switch (pref.type) {
Expand All @@ -110,9 +108,7 @@ function setImagePref(pref, val) {
}

function getImagePref(pref) {
var prefService = SpecialPowers.Cc[
"@mozilla.org/preferences-service;1"
].getService(SpecialPowers.Ci.nsIPrefService);
var prefService = SpecialPowers.Services.prefs;
var branch = prefService.getBranch(pref.branch);
if (branch.prefHasUserValue(pref.name)) {
switch (pref.type) {
Expand Down
3 changes: 2 additions & 1 deletion image/test/mochitest/test_animSVGImage.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@
loadNextImageAndPoll();
}
}
else
else {
setTimeout(myPoll, 20);
}
}

function failTest() {
Expand Down
2 changes: 1 addition & 1 deletion image/test/mochitest/test_animSVGImage2.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
takeReferenceSnapshot();

// Create, customize & attach decoder observer
observer = new ImageDecoderObserverStub();
var observer = new ImageDecoderObserverStub();
observer.frameUpdate = myOnFrameUpdate;
gMyDecoderObserver =
Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
Expand Down
4 changes: 2 additions & 2 deletions image/test/mochitest/test_animation_operators.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@

function passes(op, shot1, shot2)
{
var [correct, s1, s2] = compareSnapshots(shot1, shot2, op == "==");
return correct;
var values = compareSnapshots(shot1, shot2, op == "==");
return values[0];
}

function startTest(i)
Expand Down
2 changes: 1 addition & 1 deletion image/test/mochitest/test_bug399925.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/** Test for Bug 399925. **/
var triggerDiscardingManually = false;
var pngResults = new Array();
var pngResults = [];
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");

Expand Down
6 changes: 3 additions & 3 deletions image/test/mochitest/test_bug415761.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

// First, obtain the file URI to the ourselves:
var chromeURI = location.href;
var io = Cc['@mozilla.org/network/io-service;1']
.getService(Ci.nsIIOService);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var io = Services.io;
chromeURI = io.newURI(chromeURI);
var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry);
fileURI = chromeReg.convertChromeURL(chromeURI);
var fileURI = chromeReg.convertChromeURL(chromeURI);
fileURI.QueryInterface(Ci.nsIFileURL);
var self = fileURI.file;

Expand Down
8 changes: 6 additions & 2 deletions image/test/mochitest/test_bug435296.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@
image.style.display = "inline";

// Wait for the image to decode
setTimeout("tryToFinish();", 500);
setTimeout(function() {
tryToFinish();
}, 500);
}

function tryToFinish()
{
// If it hasn't happened yet, wait longer. If it never happens, this test
// will timeout after 300 seconds...
if (!isFrameDecoded("testimage")) {
setTimeout("tryToFinish();", 500);
setTimeout(function() {
tryToFinish();
}, 500);
return;
}

Expand Down
4 changes: 3 additions & 1 deletion image/test/mochitest/test_bug478398.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
ok(isFrameDecoded("testimage"), "image should be decoded");

// Wait 1.5 seconds, then finish the test
setTimeout("finishTest();", 1500);
setTimeout(function() {
finishTest();;
}, 1500);

}

Expand Down
2 changes: 1 addition & 1 deletion image/test/mochitest/test_bug490949.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var canvas = document.getElementById('canvas');
var first, second, third;

RemoteCanvas = function() {
var RemoteCanvas = function() {
this.url = "bug490949-iframe.html";
};

Expand Down
2 changes: 1 addition & 1 deletion image/test/mochitest/test_bug496292.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var canvas = document.getElementById('canvas');
var first, second, third, ref;

RemoteCanvas = function(url) {
var RemoteCanvas = function(url) {
this.url = url;
};

Expand Down
4 changes: 2 additions & 2 deletions image/test/mochitest/test_bug552605-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
ctx.drawImage(testimage, 0, 0);

// Check that the images are the same, since they're in the same document.
[correct, val1, val2] = compareSnapshots(first, second, true);
ok(correct, "Image should be the same for all loads.");
var values = compareSnapshots(first, second, true);
ok(values[0], "Image should be the same for all loads.");

SimpleTest.finish();
}
Expand Down
4 changes: 2 additions & 2 deletions image/test/mochitest/test_bug552605-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
ctx.drawImage(image2, 0, 0);

// Check that the images are the same, since they're in the same document.
[correct, val1, val2] = compareSnapshots(first, second, true);
ok(correct, "Image should be the same for all loads.");
var values = compareSnapshots(first, second, true);
ok(values[0], "Image should be the same for all loads.");

SimpleTest.finish();
}
Expand Down
2 changes: 2 additions & 0 deletions image/test/mochitest/test_bug89419-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
first = snapshotWindow(iframeelem.contentWindow, false);

iframeelem.onload = checkSecond;
// eslint-disable-next-line no-self-assign
iframeelem.contentWindow.location.href = iframeelem.contentWindow.location.href;
}

Expand All @@ -40,6 +41,7 @@
ok(correct, "Image should have changed after the first reload.");

iframeelem.onload = checkThird;
// eslint-disable-next-line no-self-assign
iframeelem.contentWindow.location.href = iframeelem.contentWindow.location.href;
}

Expand Down
4 changes: 2 additions & 2 deletions image/test/mochitest/test_discardAnimatedImage.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@

function step2() {
// Draw the images to canvas to force them to be decoded.
for (var i = 0; i < gImgs.length; i++) {
for (let i = 0; i < gImgs.length; i++) {
drawCanvas(document.getElementById(gImgs[i]));
}

for (var i = 0; i < gImgs.length; i++) {
for (let i = 0; i < gImgs.length; i++) {
addCallbacks(document.getElementById(gImgs[i]), i);
}

Expand Down
10 changes: 5 additions & 5 deletions image/test/mochitest/test_discardFramesAnimatedImage.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@

function step3() {
// Draw the images to canvas to force them to be decoded.
for (var i = 0; i < gImgs.length; i++) {
for (let i = 0; i < gImgs.length; i++) {
drawCanvas(document.getElementById(gImgs[i]));
}

for (var i = 0; i < gImgs.length; i++) {
for (let i = 0; i < gImgs.length; i++) {
addCallbacks(document.getElementById(gImgs[i]), i);
}

Expand Down Expand Up @@ -147,13 +147,13 @@
function resetState() {
gFinished = false;
gCountingFrameUpdates = false;
for (var i = 0; i < gNumFrameUpdates.length; ++i) {
for (let i = 0; i < gNumFrameUpdates.length; ++i) {
gNumFrameUpdates[i] = 0;
}
for (var i = 0; i < gNumSnapShotChanges.length; ++i) {
for (let i = 0; i < gNumSnapShotChanges.length; ++i) {
gNumSnapShotChanges[i] = 0;
}
for (var i = 0; i < gLastSnapShot.length; ++i) {
for (let i = 0; i < gLastSnapShot.length; ++i) {
gLastSnapShot[i] = null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion image/test/mochitest/test_has_transparency.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
gImg.onerror = onError;

// Create, customize & attach decoder observer.
observer = new ImageDecoderObserverStub();
var observer = new ImageDecoderObserverStub();
observer.hasTransparency = onHasTransparency;
observer.decodeComplete = onDecodeComplete;
gMyDecoderObserver =
Expand Down
1 change: 1 addition & 0 deletions image/test/mochitest/test_image_crossorigin_data_url.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<div id="someuniqueidhere"></div>
<img id="testimg" crossorigin src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR42mP4z8AAAAMBAQD3A0FDAAAAAElFTkSuQmCC">
<script>
/* global async_test, assert_equals */
var t = async_test("img@crossorigin with data: src");
window.addEventListener("load", t.step_func_done(function() {
var img = document.getElementById("testimg");
Expand Down
1 change: 1 addition & 0 deletions image/test/mochitest/test_net_failedtoprocess.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
obs = obs.QueryInterface(Ci.nsIObserverService);

var observer = {
/* eslint-disable-next-line mozilla/use-chromeutils-generateqi */
QueryInterface (aIID) {
if (aIID.equals(Ci.nsISupports) ||
aIID.equals(Ci.nsIObserver))
Expand Down
2 changes: 1 addition & 1 deletion image/test/mochitest/test_removal_ondecode.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
gImg.onerror = onNotification;

// Create, customize & attach decoder observer
observer = new ImageDecoderObserverStub();
var observer = new ImageDecoderObserverStub();
observer.sizeAvailable = onSizeAvailable;
observer.loadComplete = onLoadComplete;
observer.decodeComplete = onDecodeComplete;
Expand Down
2 changes: 1 addition & 1 deletion image/test/mochitest/test_removal_onload.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
gImg.onerror = onNotification;

// Create, customize & attach decoder observer
observer = new ImageDecoderObserverStub();
var observer = new ImageDecoderObserverStub();
observer.sizeAvailable = onSizeAvailable;
observer.loadComplete = onLoadComplete;
observer.decodeComplete = onDecodeComplete;
Expand Down
Loading

0 comments on commit fcb1b9e

Please sign in to comment.