Skip to content

Commit

Permalink
Bug 1403956 - Enable ESLint from chrome/ directory. r=standard8
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: LHSMjEKeNAe
  • Loading branch information
Mithilan16 committed Oct 26, 2017
1 parent 92510c4 commit 03c7243
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 115 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ obj*/**
# We ignore all these directories by default, until we get them enabled.
# If you are enabling a directory, please add directory specific exclusions
# below.
chrome/**
docshell/**
editor/**
extensions/cookie/**
Expand Down
7 changes: 7 additions & 0 deletions chrome/test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

module.exports = {
"extends": [
"plugin:mozilla/xpcshell-test"
]
};
3 changes: 1 addition & 2 deletions chrome/test/unit/head_crtestutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ var Ci = Components.interfaces;
var Cr = Components.results;


function registerManifests(manifests)
{
function registerManifests(manifests) {
var reg = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
for (var manifest of manifests)
reg.autoRegister(manifest);
Expand Down
3 changes: 1 addition & 2 deletions chrome/test/unit/test_abi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ function is_registered(name) {
try {
var d = catman.getCategoryEntry("abitest", name);
return d == "found";
}
catch (e) {
} catch (e) {
return false;
}
}
Expand Down
6 changes: 2 additions & 4 deletions chrome/test/unit/test_bug292789.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ registerManifests(MANIFESTS);
var gIOS;
var gCR;

function check_accessibility(spec, desired)
{
function check_accessibility(spec, desired) {
var uri = gIOS.newURI(spec);
var actual = gCR.allowContentToAccess(uri);
do_check_eq(desired, actual);
}

function run_test()
{
function run_test() {
gIOS = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
gCR = Cc["@mozilla.org/chrome/chrome-registry;1"].
Expand Down
17 changes: 6 additions & 11 deletions chrome/test/unit/test_bug380398.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,26 @@ chromeReg.checkForNewChrome();
var target = gIOS.newFileURI(do_get_file("data"));
target = target.spec + "test/test.xul";

function test_succeeded_mapping(namespace)
{
function test_succeeded_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
try {
var result = chromeReg.convertChromeURL(uri);
do_check_eq(result.spec, target);
}
catch (ex) {
} catch (ex) {
do_throw(namespace);
}
}

function test_failed_mapping(namespace)
{
function test_failed_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
try {
var result = chromeReg.convertChromeURL(uri);
chromeReg.convertChromeURL(uri);
do_throw(namespace);
}
catch (ex) {
} catch (ex) {
}
}

function run_test()
{
function run_test() {
test_succeeded_mapping("test1");
test_succeeded_mapping("test2");
test_succeeded_mapping("test3");
Expand Down
17 changes: 6 additions & 11 deletions chrome/test/unit/test_bug397073.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,26 @@ chromeReg.checkForNewChrome();
var target = gIOS.newFileURI(do_get_file("data"));
target = target.spec + "test/test.xul";

function test_succeeded_mapping(namespace)
{
function test_succeeded_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
try {
var result = chromeReg.convertChromeURL(uri);
do_check_eq(result.spec, target);
}
catch (ex) {
} catch (ex) {
do_throw(namespace);
}
}

function test_failed_mapping(namespace)
{
function test_failed_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
try {
var result = chromeReg.convertChromeURL(uri);
chromeReg.convertChromeURL(uri);
do_throw(namespace);
}
catch (ex) {
} catch (ex) {
}
}

function run_test()
{
function run_test() {
test_succeeded_mapping("test1");
test_succeeded_mapping("test2");

Expand Down
17 changes: 6 additions & 11 deletions chrome/test/unit/test_bug399707.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,26 @@ chromeReg.checkForNewChrome();
var target = gIOS.newFileURI(do_get_file("data"));
target = target.spec + "test/test.xul";

function test_succeeded_mapping(namespace)
{
function test_succeeded_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
try {
var result = chromeReg.convertChromeURL(uri);
do_check_eq(result.spec, target);
}
catch (ex) {
} catch (ex) {
do_throw(namespace);
}
}

function test_failed_mapping(namespace)
{
function test_failed_mapping(namespace) {
var uri = gIOS.newURI("chrome://" + namespace + "/content/test.xul");
try {
var result = chromeReg.convertChromeURL(uri);
chromeReg.convertChromeURL(uri);
do_throw(namespace);
}
catch (ex) {
} catch (ex) {
}
}

function run_test()
{
function run_test() {
test_succeeded_mapping("test1");
test_succeeded_mapping("test2");
test_succeeded_mapping("test3");
Expand Down
12 changes: 4 additions & 8 deletions chrome/test/unit/test_bug401153.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,23 @@ chromeReg.checkForNewChrome();
var rph = gIOS.getProtocolHandler("resource")
.QueryInterface(Ci.nsIResProtocolHandler);

function test_succeeded_mapping(namespace, target)
{
function test_succeeded_mapping(namespace, target) {
try {
do_check_true(rph.hasSubstitution(namespace));
var uri = gIOS.newURI("resource://" + namespace);
dump("### checking for " + target + ", getting " + rph.resolveURI(uri) + "\n");
do_check_eq(rph.resolveURI(uri), target);
}
catch (ex) {
} catch (ex) {
dump(ex + "\n");
do_throw(namespace);
}
}

function test_failed_mapping(namespace)
{
function test_failed_mapping(namespace) {
do_check_false(rph.hasSubstitution(namespace));
}

function run_test()
{
function run_test() {
var data = gIOS.newFileURI(do_get_file("data")).spec;
test_succeeded_mapping("test1", data + "test1/");
test_succeeded_mapping("test3", "jar:" + data + "test3.jar!/resources/");
Expand Down
11 changes: 4 additions & 7 deletions chrome/test/unit/test_bug415367.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
var gIOS = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);

function test_uri(obj)
{
function test_uri(obj) {
var uri = null;
var failed = false;
var message = "";
Expand All @@ -17,8 +16,7 @@ function test_uri(obj)
failed = true;
message = obj.uri + " should not be accepted as a valid URI";
}
}
catch (ex) {
} catch (ex) {
if (obj.result) {
failed = true;
message = obj.uri + " should be accepted as a valid URI";
Expand All @@ -32,8 +30,7 @@ function test_uri(obj)
}
}

function run_test()
{
function run_test() {
var tests = [
{uri: "chrome://blah/content/blah.xul", result: true},
{uri: "chrome://blah/content/:/blah/blah.xul", result: false},
Expand All @@ -43,6 +40,6 @@ function run_test()
{uri: "chrome://blah/content/blah.xul?param=:/blah/", result: true},
{uri: "chrome://blah/content/blah.xul?param=%252e%252e/blah/", result: true},
];
for (var i = 0; i < tests.length; ++ i)
for (var i = 0; i < tests.length; ++i)
test_uri(tests[i]);
}
15 changes: 5 additions & 10 deletions chrome/test/unit/test_bug564667.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ function test_mapping(chromeURL, target) {
try {
var result = gCR.convertChromeURL(uri);
do_check_eq(result.spec, target);
}
catch (ex) {
} catch (ex) {
do_throw(chromeURL + " not Registered");
}
}
Expand All @@ -34,10 +33,9 @@ function test_mapping(chromeURL, target) {
function test_removed_mapping(chromeURL, target) {
var uri = gIOS.newURI(chromeURL);
try {
var result = gCR.convertChromeURL(uri);
gCR.convertChromeURL(uri);
do_throw(chromeURL + " not removed");
}
catch (ex) {
} catch (ex) {
// This should throw
}
}
Expand All @@ -48,11 +46,8 @@ function test_removed_mapping(chromeURL, target) {
*
* @param type The type of overlay: overlay|style
*/
function test_no_overlays(chromeURL, target, type) {
var type = type || "overlay";
function test_no_overlays(chromeURL, target, type = "overlay") {
var uri = gIOS.newURI(chromeURL);
var present = false, elem;

var overlays = (type == "overlay") ?
gCR.getXULOverlays(uri) : gCR.getStyleOverlays(uri);

Expand Down Expand Up @@ -84,7 +79,7 @@ function testManifest(manifestPath, baseURI) {
test_mapping("chrome://test2/locale", baseURI + "test/test2.dtd");

// Test Adding Override
test_mapping("chrome://testOverride/content", 'file:///test1/override')
test_mapping("chrome://testOverride/content", "file:///test1/override")

// Test Not-Adding Overlays
test_no_overlays("chrome://test1/content/overlay.xul",
Expand Down
4 changes: 2 additions & 2 deletions chrome/test/unit/test_bug848297.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ function run_test() {
do_check_eq(chromeReg.getSelectedLocale("basepack"), "en-US");
do_check_eq(chromeReg.getSelectedLocale("overpack"), "de");
do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")),
['en-US', 'fr']);
["en-US", "fr"]);

// with override
prefService.setCharPref("chrome.override_package.basepack", "overpack");
do_check_eq(chromeReg.getSelectedLocale("basepack"), "de");
do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")),
['de', 'en-US']);
["de", "en-US"]);

}
5 changes: 2 additions & 3 deletions chrome/test/unit/test_crlf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
registerManifests([do_get_file("data/test_crlf.manifest")]);

function run_test()
{
function run_test() {
let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIChromeRegistry);

Expand All @@ -10,6 +9,6 @@ function run_test()
let sourceURI = ios.newURI("chrome://test_crlf/content/");
// this throws for packages that are not registered
let file = cr.convertChromeURL(sourceURI).QueryInterface(Ci.nsIFileURL).file;

do_check_true(file.equals(do_get_file("data/test_crlf.xul", true)));
}
18 changes: 7 additions & 11 deletions chrome/test/unit/test_data_protocol_registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ var manifests = [
];
registerManifests(manifests);

function run_test()
{
function run_test() {
const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);

Components.utils.import("resource://testing-common/AppInfo.jsm", this);
let newAppInfo = Components.utils.import("resource://testing-common/AppInfo.jsm", {}).newAppInfo;
let XULAppInfo = newAppInfo({
name: "XPCShell",
ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
Expand All @@ -26,7 +25,7 @@ function run_test()
CID: uuidGenerator.generateUUID(),
scheme: "XULAppInfo",
contractID: XULAPPINFO_CONTRACTID,
createInstance: function (outer, iid) {
createInstance(outer, iid) {
if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
return XULAppInfo.QueryInterface(iid);
Expand Down Expand Up @@ -58,17 +57,15 @@ function run_test()
});
old_factories_inds.push(true);
registrar.unregisterFactory(old_factories[i].CID, old_factories[i].factory);
}
else {
} else {
dump(factory.scheme + " has never been registered. Registering...")
old_factories.push({CID: "", factory: null});
old_factories_inds.push(false);
}

registrar.registerFactory(factory.CID, "test-" + factory.scheme, factory.contractID, factory);
}
else {
do_throw("CID " + factory.CID + " has already been registered!");
} else {
do_throw("CID " + factory.CID + " has already been registered!");
}
}

Expand All @@ -88,8 +85,7 @@ function run_test()
let uri = cr.convertChromeURL(sourceURI).spec;

do_check_eq(expectedURI, uri);
}
catch (e) {
} catch (e) {
dump(e + "\n");
do_throw("Should have registered our URI!");
}
Expand Down
Loading

0 comments on commit 03c7243

Please sign in to comment.