Merge pull request #9434 from Snuffleupagus/upstream-bug-1339461
Upstream the changes from: Bug 1339461 - Convert foo.indexOf(...) == -1 to foo.includes() and implement an eslint rule to enforce this
This commit is contained in:
commit
7fbeeebbff
@ -243,7 +243,7 @@ var PdfJs = {
|
|||||||
types = stringTypes.split(",");
|
types = stringTypes.split(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (types.indexOf(PDF_CONTENT_TYPE) === -1) {
|
if (!types.includes(PDF_CONTENT_TYPE)) {
|
||||||
types.push(PDF_CONTENT_TYPE);
|
types.push(PDF_CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(","));
|
prefs.setCharPref(PREF_DISABLED_PLUGIN_TYPES, types.join(","));
|
||||||
@ -271,7 +271,7 @@ var PdfJs = {
|
|||||||
if (Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) {
|
if (Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES)) {
|
||||||
let disabledPluginTypes =
|
let disabledPluginTypes =
|
||||||
Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES).split(",");
|
Services.prefs.getCharPref(PREF_DISABLED_PLUGIN_TYPES).split(",");
|
||||||
if (disabledPluginTypes.indexOf(PDF_CONTENT_TYPE) >= 0) {
|
if (disabledPluginTypes.includes(PDF_CONTENT_TYPE)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -930,12 +930,12 @@ PdfStreamConverter.prototype = {
|
|||||||
aRequest.contentLength >= 0 &&
|
aRequest.contentLength >= 0 &&
|
||||||
!getBoolPref(PREF_PREFIX + ".disableRange", false) &&
|
!getBoolPref(PREF_PREFIX + ".disableRange", false) &&
|
||||||
(!isPDFBugEnabled ||
|
(!isPDFBugEnabled ||
|
||||||
hash.toLowerCase().indexOf("disablerange=true") < 0);
|
!hash.toLowerCase().includes("disablerange=true"));
|
||||||
streamRequest = contentEncoding === "identity" &&
|
streamRequest = contentEncoding === "identity" &&
|
||||||
aRequest.contentLength >= 0 &&
|
aRequest.contentLength >= 0 &&
|
||||||
!getBoolPref(PREF_PREFIX + ".disableStream", false) &&
|
!getBoolPref(PREF_PREFIX + ".disableStream", false) &&
|
||||||
(!isPDFBugEnabled ||
|
(!isPDFBugEnabled ||
|
||||||
hash.toLowerCase().indexOf("disablestream=true") < 0);
|
!hash.toLowerCase().includes("disablestream=true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
aRequest.QueryInterface(Ci.nsIChannel);
|
aRequest.QueryInterface(Ci.nsIChannel);
|
||||||
|
@ -258,7 +258,7 @@ var PdfjsChromeUtils = {
|
|||||||
_ensurePreferenceAllowed(aPrefName) {
|
_ensurePreferenceAllowed(aPrefName) {
|
||||||
let unPrefixedName = aPrefName.split(PREF_PREFIX + ".");
|
let unPrefixedName = aPrefName.split(PREF_PREFIX + ".");
|
||||||
if (unPrefixedName[0] !== "" ||
|
if (unPrefixedName[0] !== "" ||
|
||||||
this._allowedPrefNames.indexOf(unPrefixedName[1]) === -1) {
|
!this._allowedPrefNames.includes(unPrefixedName[1])) {
|
||||||
let msg = "\"" + aPrefName + "\" " +
|
let msg = "\"" + aPrefName + "\" " +
|
||||||
"can't be accessed from content. See PdfjsChromeUtils.";
|
"can't be accessed from content. See PdfjsChromeUtils.";
|
||||||
throw new Error(msg);
|
throw new Error(msg);
|
||||||
|
@ -411,7 +411,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
|||||||
var beginChunk = this.getBeginChunk(ranges[i].begin);
|
var beginChunk = this.getBeginChunk(ranges[i].begin);
|
||||||
var endChunk = this.getEndChunk(ranges[i].end);
|
var endChunk = this.getEndChunk(ranges[i].end);
|
||||||
for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
|
for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
|
||||||
if (chunksToRequest.indexOf(chunk) < 0) {
|
if (!chunksToRequest.includes(chunk)) {
|
||||||
chunksToRequest.push(chunk);
|
chunksToRequest.push(chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -942,7 +942,7 @@ var CMapFactory = (function CMapFactoryClosure() {
|
|||||||
} else if (name === 'Identity-V') {
|
} else if (name === 'Identity-V') {
|
||||||
return Promise.resolve(new IdentityCMap(true, 2));
|
return Promise.resolve(new IdentityCMap(true, 2));
|
||||||
}
|
}
|
||||||
if (BUILT_IN_CMAPS.indexOf(name) === -1) {
|
if (!BUILT_IN_CMAPS.includes(name)) {
|
||||||
return Promise.reject(new Error('Unknown CMap name: ' + name));
|
return Promise.reject(new Error('Unknown CMap name: ' + name));
|
||||||
}
|
}
|
||||||
if (!fetchBuiltInCMap) {
|
if (!fetchBuiltInCMap) {
|
||||||
|
@ -1316,7 +1316,7 @@ var Font = (function FontClosure() {
|
|||||||
|
|
||||||
for (let i = 0; i < numTables; i++) {
|
for (let i = 0; i < numTables; i++) {
|
||||||
let table = readTableEntry(font);
|
let table = readTableEntry(font);
|
||||||
if (VALID_TABLES.indexOf(table.tag) < 0) {
|
if (!VALID_TABLES.includes(table.tag)) {
|
||||||
continue; // skipping table if it's not a required or optional table
|
continue; // skipping table if it's not a required or optional table
|
||||||
}
|
}
|
||||||
if (table.length === 0) {
|
if (table.length === 0) {
|
||||||
@ -2113,7 +2113,7 @@ var Font = (function FontClosure() {
|
|||||||
if (funcId in ttContext.functionsStackDeltas) {
|
if (funcId in ttContext.functionsStackDeltas) {
|
||||||
stack.length += ttContext.functionsStackDeltas[funcId];
|
stack.length += ttContext.functionsStackDeltas[funcId];
|
||||||
} else if (funcId in ttContext.functionsDefined &&
|
} else if (funcId in ttContext.functionsDefined &&
|
||||||
functionsCalled.indexOf(funcId) < 0) {
|
!functionsCalled.includes(funcId)) {
|
||||||
callstack.push({ data, i, stackTop: stack.length - 1, });
|
callstack.push({ data, i, stackTop: stack.length - 1, });
|
||||||
functionsCalled.push(funcId);
|
functionsCalled.push(funcId);
|
||||||
pc = ttContext.functionsDefined[funcId];
|
pc = ttContext.functionsDefined[funcId];
|
||||||
|
@ -596,7 +596,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
optionElement.textContent = option.displayValue;
|
optionElement.textContent = option.displayValue;
|
||||||
optionElement.value = option.exportValue;
|
optionElement.value = option.exportValue;
|
||||||
|
|
||||||
if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
|
if (this.data.fieldValue.includes(option.displayValue)) {
|
||||||
optionElement.setAttribute('selected', true);
|
optionElement.setAttribute('selected', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,7 +628,7 @@ class PopupAnnotationElement extends AnnotationElement {
|
|||||||
|
|
||||||
this.container.className = 'popupAnnotation';
|
this.container.className = 'popupAnnotation';
|
||||||
|
|
||||||
if (IGNORE_TYPES.indexOf(this.data.parentType) >= 0) {
|
if (IGNORE_TYPES.includes(this.data.parentType)) {
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1131,7 +1131,7 @@ class LoopbackPort {
|
|||||||
var buffer;
|
var buffer;
|
||||||
if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
|
if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
|
||||||
// We found object with ArrayBuffer (typed array).
|
// We found object with ArrayBuffer (typed array).
|
||||||
var transferable = transfers && transfers.indexOf(buffer) >= 0;
|
var transferable = transfers && transfers.includes(buffer);
|
||||||
if (value === buffer) {
|
if (value === buffer) {
|
||||||
// Special case when we are faking typed arrays in compatibility.js.
|
// Special case when we are faking typed arrays in compatibility.js.
|
||||||
result = value;
|
result = value;
|
||||||
|
@ -229,7 +229,7 @@ class SimpleXMLParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_decodeXML(text) {
|
_decodeXML(text) {
|
||||||
if (text.indexOf('&') < 0) {
|
if (!text.includes('&')) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +157,15 @@ PDFJS.compatibilityChecked = true;
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// Provides support for String.prototype.includes in legacy browsers.
|
||||||
|
// Support: IE, Chrome<41
|
||||||
|
(function checkStringIncludes() {
|
||||||
|
if (String.prototype.includes) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String.prototype.includes = require('core-js/fn/string/includes');
|
||||||
|
})();
|
||||||
|
|
||||||
// Provides support for Array.prototype.includes in legacy browsers.
|
// Provides support for Array.prototype.includes in legacy browsers.
|
||||||
// Support: IE, Chrome<47
|
// Support: IE, Chrome<47
|
||||||
(function checkArrayIncludes() {
|
(function checkArrayIncludes() {
|
||||||
|
Loading…
Reference in New Issue
Block a user