author | dagasatvik <dagasatvik10@gmail.com> |
Sat, 05 Aug 2017 17:08:36 +0530 | |
changeset 641106 | 9dce791545429b5ca1412af590a241ed4b0571bc |
parent 619157 | 60339c255fd36e5eda813410c406e485712c5247 |
child 724720 | a22fabe181a1427abcff1c63945d9d138632aa2d |
push id | 72434 |
push user | bmo:dagasatvik10@gmail.com |
push date | Sat, 05 Aug 2017 11:39:39 +0000 |
reviewers | standard8, markh |
bugs | 1385820, 1295510 |
milestone | 56.0a1 |
--- a/services/sync/modules/engines.js +++ b/services/sync/modules/engines.js @@ -1004,17 +1004,20 @@ SyncEngine.prototype = { engineData.syncID = this.syncID; // Put the new data back into meta/global and mark for upload engines[this.name] = engineData; metaGlobal.payload.engines = engines; metaGlobal.changed = true; } else if (engineData.version > this.version) { // Don't sync this engine if the server has newer data - let error = String("New data: " + [engineData.version, this.version]); + + // Changes below need to be processed in bug 1295510 that's why eslint is ignored + // eslint-disable-next-line no-new-wrappers + let error = new String("New data: " + [engineData.version, this.version]); error.failureCode = VERSION_OUT_OF_DATE; throw error; } else if (engineData.syncID != this.syncID) { // Changes to syncID mean we'll need to upload everything this._log.debug("Engine syncIDs: " + [engineData.syncID, this.syncID]); this.syncID = engineData.syncID; await this._resetClient(); }
--- a/services/sync/modules/engines/bookmarks.js +++ b/services/sync/modules/engines/bookmarks.js @@ -352,17 +352,20 @@ BookmarksEngine.prototype = { continue; } let parentName = parent.title || ""; if (guidMap[parentName] == null) guidMap[parentName] = {}; // If the entry already exists, remember that there are explicit dupes. - let entry = String(guid); + + // Changes below need to be processed in bug 1295510 that's why eslint is ignored + // eslint-disable-next-line no-new-wrappers + let entry = new String(guid); entry.hasDupe = guidMap[parentName][key] != null; // Remember this item's GUID for its parent-name/key pair. guidMap[parentName][key] = entry; this._log.trace("Mapped: " + [parentName, key, entry, entry.hasDupe]); } return guidMap;
--- a/services/sync/modules/resource.js +++ b/services/sync/modules/resource.js @@ -296,17 +296,19 @@ AsyncResource.prototype = { this._log.warn("The response body's length of: " + data.length + " doesn't match the header's content-length of: " + contentLength + "."); } } catch (ex) { this._log.debug("Caught exception visiting headers in _onComplete", ex); } - let ret = String(data); + // Changes below need to be processed in bug 1295510 that's why eslint is ignored + // eslint-disable-next-line no-new-wrappers + let ret = new String(data); ret.url = channel.URI.spec; ret.status = status; ret.success = success; ret.headers = headers; if (!success) { this._log.warn(`${action} request to ${ret.url} failed with status ${status}`); }
--- a/toolkit/components/contentprefs/tests/unit/test_stringGroups.js +++ b/toolkit/components/contentprefs/tests/unit/test_stringGroups.js @@ -10,17 +10,20 @@ function run_test() { var statement = cps.DBConnection.createStatement("PRAGMA synchronous"); statement.executeStep(); do_check_eq(0, statement.getInt32(0)); // These are the different types of aGroup arguments we'll test. var anObject = {"foo": "bar"}; // a simple object var uri = ContentPrefTest.getURI("http://www.example.com/"); // nsIURI var stringURI = "www.example.com"; // typeof = "string" - var stringObjectURI = String("www.example.com"); // typeof = "object" + + // Test wants to check for a String object + // eslint-disable-next-line no-new-wrappers + var stringObjectURI = new String("www.example.com"); // typeof = "object" // First check that all the methods work or don't work. function simple_test_methods(aGroup, shouldThrow) { var prefName = "test.pref.0"; var prefValue = Math.floor(Math.random() * 100); if (shouldThrow) { do_check_thrown(function() { cps.getPref(aGroup, prefName); });
--- a/toolkit/components/ctypes/tests/unit/test_jsctypes.js +++ b/toolkit/components/ctypes/tests/unit/test_jsctypes.js @@ -404,17 +404,17 @@ function run_Int64_tests() { do_check_eq(int64.toString(), int64.toString(10)); do_check_eq(int64.toString(10), "9223372036854775807"); do_check_eq(int64.toString(16), "7fffffffffffffff"); do_check_eq(int64.toString(2), "111111111111111111111111111111111111111111111111111111111111111"); let vals = [-0x8000000000001000, 0x8000000000000000, ctypes.UInt64("0x8000000000000000"), Infinity, -Infinity, NaN, 0.1, - 5.68e21, null, undefined, "", {}, [], Number(16), + 5.68e21, null, undefined, "", {}, [], 16, {toString() { return 7; }}, {valueOf() { return 7; }}]; for (let i = 0; i < vals.length; i++) do_check_throws(function() { ctypes.Int64(vals[i]); }, TypeError); vals = ["-0x8000000000000001", "0x8000000000000000"]; for (let i = 0; i < vals.length; i++) do_check_throws(function() { ctypes.Int64(vals[i]); }, RangeError); @@ -554,17 +554,17 @@ function run_UInt64_tests() { uint64 = ctypes.UInt64(ctypes.Int64("0x7fffffffffffffff")); do_check_eq(uint64.toString(), uint64.toString(10)); do_check_eq(uint64.toString(10), "9223372036854775807"); do_check_eq(uint64.toString(16), "7fffffffffffffff"); do_check_eq(uint64.toString(2), "111111111111111111111111111111111111111111111111111111111111111"); let vals = [-1, 0x10000000000000000, "-1", "-0x1", ctypes.Int64("-1"), Infinity, -Infinity, NaN, 0.1, - 5.68e21, null, undefined, "", {}, [], Number(16), + 5.68e21, null, undefined, "", {}, [], 16, {toString() { return 7; }}, {valueOf() { return 7; }}]; for (let i = 0; i < vals.length; i++) do_check_throws(function() { ctypes.UInt64(vals[i]); }, TypeError); vals = ["0x10000000000000000"]; for (let i = 0; i < vals.length; i++) do_check_throws(function() { ctypes.UInt64(vals[i]); }, RangeError); @@ -768,17 +768,17 @@ function run_bool_tests(library) { d.value = true; do_check_eq(d.value, 1); d = new t(1); do_check_eq(d.value, 1); // don't convert anything else let vals = [-1, 2, Infinity, -Infinity, NaN, 0.1, ctypes.Int64(0), ctypes.UInt64(0), - null, undefined, "", "0", {}, [], Number(16), + null, undefined, "", "0", {}, [], 16, {toString() { return 7; }}, {valueOf() { return 7; }}]; for (let i = 0; i < vals.length; i++) do_check_throws(function() { d.value = vals[i]; }, TypeError); do_check_true(d.address().constructor === t.ptr); do_check_eq(d.address().contents, d.value); do_check_eq(d.toSource(), "ctypes." + name + "(" + d.value + ")"); @@ -848,17 +848,17 @@ function run_integer_tests(library, t, n do_check_eq(1 / d.value, 1 / 0); d.value = false; do_check_eq(d.value, 0); d.value = true; do_check_eq(d.value, 1); // don't convert anything else let vals = [limits[0] - 1, limits[1] + 1, Infinity, -Infinity, NaN, 0.1, - null, undefined, "", "0", {}, [], Number(16), + null, undefined, "", "0", {}, [], 16, {toString() { return 7; }}, {valueOf() { return 7; }}]; for (let i = 0; i < vals.length; i++) do_check_throws(function() { d.value = vals[i]; }, TypeError); do_check_true(d.address().constructor === t.ptr); do_check_eq(d.address().contents, d.value); do_check_eq(d.toSource(), "ctypes." + name + "(" + d.value + ")"); @@ -935,17 +935,17 @@ function run_float_tests(library, t, nam d.value = NaN; do_check_true(isNaN(d.value)); d.value = 0; do_check_eq(d.value, 0); d.value = -0; do_check_eq(1 / d.value, 1 / -0); // don't convert anything else - let vals = [true, false, null, undefined, "", "0", {}, [], Number(16), + let vals = [true, false, null, undefined, "", "0", {}, [], 16, {toString() { return 7; }}, {valueOf() { return 7; }}]; for (let i = 0; i < vals.length; i++) do_check_throws(function() { d.value = vals[i]; }, TypeError); // Check that values roundtrip through toSource() correctly. function test_roundtrip(tFn, val) { let f1 = tFn(val); @@ -1035,17 +1035,17 @@ function run_wrapped_integer_tests(libra do_check_eq(1 / d.value, 1 / 0); d.value = false; do_check_eq(d.value, 0); d.value = true; do_check_eq(d.value, 1); // don't convert anything else let vals = [limits[2], limits[3], Infinity, -Infinity, NaN, 0.1, - null, undefined, "", "0", {}, [], Number(16), + null, undefined, "", "0", {}, [], 16, {toString() { return 7; }}, {valueOf() { return 7; }}]; for (let i = 0; i < vals.length; i++) do_check_throws(function() { d.value = vals[i]; }, TypeError); do_check_true(d.address().constructor === t.ptr); do_check_eq(d.address().contents.toString(), d.value.toString()); do_check_eq(d.toSource(), "ctypes." + name + "(" + wname + "(\"" + d.value + "\"))"); @@ -1118,17 +1118,17 @@ function run_char_tests(library, t, name do_check_eq(d.value, 0); d.value = true; do_check_eq(d.value, 1); do_check_throws(function() { d.value = "5"; }, TypeError); // don't convert anything else let vals = [limits[0] - 1, limits[1] + 1, Infinity, -Infinity, NaN, 0.1, - null, undefined, "", "aa", {}, [], Number(16), + null, undefined, "", "aa", {}, [], 16, {toString() { return 7; }}, {valueOf() { return 7; }}]; for (let i = 0; i < vals.length; i++) do_check_throws(function() { d.value = vals[i]; }, TypeError); do_check_true(d.address().constructor === t.ptr); do_check_eq(d.address().contents, 1); do_check_eq(d.toSource(), "ctypes." + name + "(" + d.value + ")"); @@ -1210,17 +1210,17 @@ function run_char16_tests(library, t, na d.value = "\0"; do_check_eq(toprimitive(d.value), 0); d.value = "a"; do_check_eq(d.value, "a"); // don't convert anything else let vals = [limits[0] - 1, limits[1] + 1, Infinity, -Infinity, NaN, 0.1, - null, undefined, "", "aa", {}, [], Number(16), + null, undefined, "", "aa", {}, [], 16, {toString() { return 7; }}, {valueOf() { return 7; }}]; for (let i = 0; i < vals.length; i++) do_check_throws(function() { d.value = vals[i]; }, TypeError); do_check_true(d.address().constructor === t.ptr); do_check_eq(d.address().contents, "a"); do_check_eq(d.toSource(), "ctypes." + name + "(\"" + d.value + "\")");
--- a/toolkit/components/jsdownloads/test/unit/test_Downloads.js +++ b/toolkit/components/jsdownloads/test/unit/test_Downloads.js @@ -106,18 +106,18 @@ add_task(async function test_fetch_objec * Tests "fetch" with string arguments. */ add_task(async function test_fetch_string_arguments() { let targetPath = getTempFile(TEST_TARGET_FILE_NAME).path; await Downloads.fetch(httpUrl("source.txt"), targetPath); await promiseVerifyContents(targetPath, TEST_DATA_SHORT); targetPath = getTempFile(TEST_TARGET_FILE_NAME).path; - await Downloads.fetch(String(httpUrl("source.txt")), - String(targetPath)); + await Downloads.fetch(httpUrl("source.txt"), + targetPath); await promiseVerifyContents(targetPath, TEST_DATA_SHORT); }); /** * Tests that the getList function returns the same list when called multiple * times with the same argument, but returns different lists when called with * different arguments. More detailed tests are implemented separately for the * DownloadList module.
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm +++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm @@ -264,17 +264,17 @@ const PREF_CHANGED_TOPIC = "nsPref:chang * @param aValue The input value. * @return {Boolean|Object} If aValue is a boolean or a number, returns its truthfulness * value. Otherwise, return null. */ function enforceBoolean(aValue) { if (typeof(aValue) !== "number" && typeof(aValue) !== "boolean") { return null; } - return (Boolean(aValue)).valueOf(); + return Boolean(aValue); } /** * Get the current browser locale. * @return a string with the locale or null on failure. */ function getBrowserLocale() { try {
--- a/toolkit/modules/PropertyListUtils.jsm +++ b/toolkit/modules/PropertyListUtils.jsm @@ -198,17 +198,20 @@ this.PropertyListUtils = Object.freeze({ * a number in the form of either a primitive string or a primitive number. * @return a String wrapper around aNumberStr that can later be identified * as holding 64-bit number using getObjectType. */ wrapInt64: function PLU_wrapInt64(aPrimitive) { if (typeof(aPrimitive) != "string" && typeof(aPrimitive) != "number") throw new Error("aPrimitive should be a string primitive"); - let wrapped = String(aPrimitive); + // The function converts string or number to object + // So eslint rule is disabled + // eslint-disable-next-line no-new-wrappers + let wrapped = new String(aPrimitive); Object.defineProperty(wrapped, "__INT_64_WRAPPER__", { value: true }); return wrapped; } }); /** * Here's the base structure of binary-format property lists. * 1) Header - magic number
--- a/toolkit/modules/tests/xpcshell/test_Log.js +++ b/toolkit/modules/tests/xpcshell/test_Log.js @@ -411,17 +411,17 @@ add_task(async function log_message_with do_check_eq(formatMessage("All params internal", {_level: 20, _message: "froo", _time: 123456, _namespace: "here.there"}), "All params internal"); // Format params with null and undefined values. do_check_eq(formatMessage("Null ${n} undefined ${u}", {n: null, u: undefined}), "Null null undefined undefined"); - // Format params with number, bool, and Object/String type. + // Format params with number, bool, and String type. do_check_eq(formatMessage("number ${n} boolean ${b} boxed Boolean ${bx} String ${s}", {n: 45, b: false, bx: Boolean(true), s: String("whatevs")}), "number 45 boolean false boxed Boolean true String whatevs"); /* * Check that errors get special formatting if they're formatted directly as * a named param or they're the only param, but not if they're a field in a * larger structure. @@ -436,18 +436,18 @@ add_task(async function log_message_with do_check_true(str.includes('Exception is [Exception... "test exception"')); str = formatMessage("Exception is", {_error: err}); do_print(str); // Exceptions buried inside objects are formatted badly. do_check_true(str.includes('Exception is: {"_error":{}')); // If the message text is null, the message contains only the formatted params object. str = formatMessage(null, err); do_check_true(str.startsWith('[Exception... "test exception"')); - // If the text is null and 'params' is a String object, the message is exactly that string. - str = formatMessage(null, String("String in place of params")); + // If the text is null and 'params' is a string, the message is exactly that string. + str = formatMessage(null, "String in place of params"); do_check_eq(str, "String in place of params"); // We use object.valueOf() internally; make sure a broken valueOf() method // doesn't cause the logger to fail. /* eslint-disable object-shorthand */ let vOf = {a: 1, valueOf: function() {throw "oh noes valueOf"}}; do_check_eq(formatMessage("Broken valueOf ${}", vOf), 'Broken valueOf ({a:1, valueOf:(function() {throw "oh noes valueOf"})})');