mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Fix unsafe "instanceof" negations
https://github.com/MoonchildProductions/Pale-Moon/pull/1173
This commit is contained in:
parent
a073130d31
commit
b56d147095
17 changed files with 19 additions and 28 deletions
|
|
@ -7,6 +7,9 @@ module.exports = {
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"mozilla/import-globals": "warn",
|
"mozilla/import-globals": "warn",
|
||||||
|
|
||||||
|
// No (!foo in bar) or (!object instanceof Class)
|
||||||
|
"no-unsafe-negation": "error",
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"es6": true
|
"es6": true
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ try {
|
||||||
try {
|
try {
|
||||||
m = require(module);
|
m = require(module);
|
||||||
|
|
||||||
if (!setupChild in m) {
|
if (!(setupChild in m)) {
|
||||||
dumpn(`ERROR: module '${module}' does not export '${setupChild}'`);
|
dumpn(`ERROR: module '${module}' does not export '${setupChild}'`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1040,7 +1040,7 @@ var DebuggerServer = {
|
||||||
try {
|
try {
|
||||||
m = require(module);
|
m = require(module);
|
||||||
|
|
||||||
if (!setupParent in m) {
|
if (!(setupParent in m)) {
|
||||||
dumpn(`ERROR: module '${module}' does not export '${setupParent}'`);
|
dumpn(`ERROR: module '${module}' does not export '${setupParent}'`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ var InputWidgetHelper = {
|
||||||
},
|
},
|
||||||
|
|
||||||
hasInputWidget: function(aElement) {
|
hasInputWidget: function(aElement) {
|
||||||
if (!aElement instanceof HTMLInputElement)
|
if (!(aElement instanceof HTMLInputElement))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
let type = aElement.getAttribute('type');
|
let type = aElement.getAttribute('type');
|
||||||
|
|
|
||||||
|
|
@ -131,9 +131,6 @@ module.exports = { // eslint-disable-line no-undef
|
||||||
// No reassigning native JS objects
|
// No reassigning native JS objects
|
||||||
"no-native-reassign": "error",
|
"no-native-reassign": "error",
|
||||||
|
|
||||||
// No (!foo in bar)
|
|
||||||
"no-negated-in-lhs": "error",
|
|
||||||
|
|
||||||
// Nested ternary statements are confusing
|
// Nested ternary statements are confusing
|
||||||
"no-nested-ternary": "error",
|
"no-nested-ternary": "error",
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ this.FxAccountsProfileClient.prototype = {
|
||||||
try {
|
try {
|
||||||
return (yield this._rawRequest(path, method, token));
|
return (yield this._rawRequest(path, method, token));
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
if (!ex instanceof FxAccountsProfileClientError || ex.code != 401) {
|
if (!(ex instanceof FxAccountsProfileClientError) || ex.code != 401) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
// If this object was instantiated with a token then we don't refresh it.
|
// If this object was instantiated with a token then we don't refresh it.
|
||||||
|
|
@ -105,7 +105,7 @@ this.FxAccountsProfileClient.prototype = {
|
||||||
try {
|
try {
|
||||||
return (yield this._rawRequest(path, method, token));
|
return (yield this._rawRequest(path, method, token));
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
if (!ex instanceof FxAccountsProfileClientError || ex.code != 401) {
|
if (!(ex instanceof FxAccountsProfileClientError) || ex.code != 401) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
log.info("Retry fetching the profile still returned a 401 - revoking our token and failing");
|
log.info("Retry fetching the profile still returned a 401 - revoking our token and failing");
|
||||||
|
|
|
||||||
|
|
@ -403,7 +403,7 @@ this.FxAccountsStorageManager.prototype = {
|
||||||
try {
|
try {
|
||||||
yield this.secureStorage.set(this.cachedPlain.uid, toWriteSecure);
|
yield this.secureStorage.set(this.cachedPlain.uid, toWriteSecure);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
if (!ex instanceof this.secureStorage.STORAGE_LOCKED) {
|
if (!(ex instanceof this.secureStorage.STORAGE_LOCKED)) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
// This shouldn't be possible as once it is unlocked it can't be
|
// This shouldn't be possible as once it is unlocked it can't be
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ WBORecord.prototype = {
|
||||||
// Get thyself from your URI, then deserialize.
|
// Get thyself from your URI, then deserialize.
|
||||||
// Set thine 'response' field.
|
// Set thine 'response' field.
|
||||||
fetch: function fetch(resource) {
|
fetch: function fetch(resource) {
|
||||||
if (!resource instanceof Resource) {
|
if (!(resource instanceof Resource)) {
|
||||||
throw new Error("First argument must be a Resource instance.");
|
throw new Error("First argument must be a Resource instance.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ WBORecord.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
upload: function upload(resource) {
|
upload: function upload(resource) {
|
||||||
if (!resource instanceof Resource) {
|
if (!(resource instanceof Resource)) {
|
||||||
throw new Error("First argument must be a Resource instance.");
|
throw new Error("First argument must be a Resource instance.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ Sync11Service.prototype = {
|
||||||
this.clientsEngine = new ClientEngine(this);
|
this.clientsEngine = new ClientEngine(this);
|
||||||
|
|
||||||
for (let name of engines) {
|
for (let name of engines) {
|
||||||
if (!name in ENGINE_MODULES) {
|
if (!(name in ENGINE_MODULES)) {
|
||||||
this._log.info("Do not know about engine: " + name);
|
this._log.info("Do not know about engine: " + name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -978,7 +978,7 @@ function browserAdditions (controller) {
|
||||||
}, "Timeout", timeout, aInterval);
|
}, "Timeout", timeout, aInterval);
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
if (!ex instanceof errors.TimeoutError) {
|
if (!(ex instanceof errors.TimeoutError)) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
timed_out = true;
|
timed_out = true;
|
||||||
|
|
|
||||||
|
|
@ -659,7 +659,7 @@ Expect.prototype.waitFor = function Expect_waitFor(aCallback, aMessage, aTimeout
|
||||||
Assert.prototype.waitFor.apply(this, arguments);
|
Assert.prototype.waitFor.apply(this, arguments);
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
if (!ex instanceof errors.AssertionError) {
|
if (!(ex instanceof errors.AssertionError)) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
message = ex.message;
|
message = ex.message;
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,6 @@ module.exports = {
|
||||||
// No reassigning native JS objects
|
// No reassigning native JS objects
|
||||||
"no-native-reassign": "error",
|
"no-native-reassign": "error",
|
||||||
|
|
||||||
// No (!foo in bar)
|
|
||||||
"no-negated-in-lhs": "error",
|
|
||||||
|
|
||||||
// Nested ternary statements are confusing
|
// Nested ternary statements are confusing
|
||||||
"no-nested-ternary": "error",
|
"no-nested-ternary": "error",
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -838,7 +838,7 @@
|
||||||
* implementation.
|
* implementation.
|
||||||
*/
|
*/
|
||||||
File.DirectoryIterator.Entry.toMsg = function toMsg(value) {
|
File.DirectoryIterator.Entry.toMsg = function toMsg(value) {
|
||||||
if (!value instanceof File.DirectoryIterator.Entry) {
|
if (!(value instanceof File.DirectoryIterator.Entry)) {
|
||||||
throw new TypeError("parameter of " +
|
throw new TypeError("parameter of " +
|
||||||
"File.DirectoryIterator.Entry.toMsg must be a " +
|
"File.DirectoryIterator.Entry.toMsg must be a " +
|
||||||
"File.DirectoryIterator.Entry");
|
"File.DirectoryIterator.Entry");
|
||||||
|
|
@ -905,7 +905,7 @@
|
||||||
* is asymmetric and returns an object with a different implementation.
|
* is asymmetric and returns an object with a different implementation.
|
||||||
*/
|
*/
|
||||||
File.Info.toMsg = function toMsg(stat) {
|
File.Info.toMsg = function toMsg(stat) {
|
||||||
if (!stat instanceof File.Info) {
|
if (!(stat instanceof File.Info)) {
|
||||||
throw new TypeError("parameter of File.Info.toMsg must be a File.Info");
|
throw new TypeError("parameter of File.Info.toMsg must be a File.Info");
|
||||||
}
|
}
|
||||||
let serialized = {};
|
let serialized = {};
|
||||||
|
|
|
||||||
|
|
@ -909,7 +909,7 @@
|
||||||
* implementation.
|
* implementation.
|
||||||
*/
|
*/
|
||||||
File.DirectoryIterator.Entry.toMsg = function toMsg(value) {
|
File.DirectoryIterator.Entry.toMsg = function toMsg(value) {
|
||||||
if (!value instanceof File.DirectoryIterator.Entry) {
|
if (!(value instanceof File.DirectoryIterator.Entry)) {
|
||||||
throw new TypeError("parameter of " +
|
throw new TypeError("parameter of " +
|
||||||
"File.DirectoryIterator.Entry.toMsg must be a " +
|
"File.DirectoryIterator.Entry.toMsg must be a " +
|
||||||
"File.DirectoryIterator.Entry");
|
"File.DirectoryIterator.Entry");
|
||||||
|
|
@ -958,7 +958,7 @@
|
||||||
* is asymmetric and returns an object with a different implementation.
|
* is asymmetric and returns an object with a different implementation.
|
||||||
*/
|
*/
|
||||||
File.Info.toMsg = function toMsg(stat) {
|
File.Info.toMsg = function toMsg(stat) {
|
||||||
if (!stat instanceof File.Info) {
|
if (!(stat instanceof File.Info)) {
|
||||||
throw new TypeError("parameter of File.Info.toMsg must be a File.Info");
|
throw new TypeError("parameter of File.Info.toMsg must be a File.Info");
|
||||||
}
|
}
|
||||||
let serialized = {};
|
let serialized = {};
|
||||||
|
|
|
||||||
|
|
@ -109,9 +109,6 @@ module.exports = {
|
||||||
// No reassigning native JS objects
|
// No reassigning native JS objects
|
||||||
"no-native-reassign": "error",
|
"no-native-reassign": "error",
|
||||||
|
|
||||||
// No (!foo in bar)
|
|
||||||
"no-negated-in-lhs": "error",
|
|
||||||
|
|
||||||
// Nested ternary statements are confusing
|
// Nested ternary statements are confusing
|
||||||
"no-nested-ternary": "error",
|
"no-nested-ternary": "error",
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,9 +173,6 @@ module.exports = { // eslint-disable-line no-undef
|
||||||
// No reassigning native JS objects
|
// No reassigning native JS objects
|
||||||
"no-native-reassign": "error",
|
"no-native-reassign": "error",
|
||||||
|
|
||||||
// No (!foo in bar)
|
|
||||||
"no-negated-in-lhs": "error",
|
|
||||||
|
|
||||||
// Nested ternary statements are confusing
|
// Nested ternary statements are confusing
|
||||||
"no-nested-ternary": "error",
|
"no-nested-ternary": "error",
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -995,7 +995,7 @@ function cloneStorageConnection(options) {
|
||||||
if (!source) {
|
if (!source) {
|
||||||
throw new TypeError("connection not specified in clone options.");
|
throw new TypeError("connection not specified in clone options.");
|
||||||
}
|
}
|
||||||
if (!source instanceof Ci.mozIStorageAsyncConnection) {
|
if (!(source instanceof Ci.mozIStorageAsyncConnection)) {
|
||||||
throw new TypeError("Connection must be a valid Storage connection.");
|
throw new TypeError("Connection must be a valid Storage connection.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue