# HG changeset patch # User Florian Queze # Date 1517514322 -3600 # Node ID d5a5ad1dbbf2c53a80386e7397ba6b32153b2b8e # Parent c9ef7cf0d10b9e315f4cf031ae16e0a30231795a Bug 1339461 - script-generated patch to convert foo.indexOf(...) == -1 to foo.includes(), r=Mossop. diff --git a/browser/base/content/test/permissions/browser_reservedkey.js b/browser/base/content/test/permissions/browser_reservedkey.js --- a/browser/base/content/test/permissions/browser_reservedkey.js +++ b/browser/base/content/test/permissions/browser_reservedkey.js @@ -39,17 +39,17 @@ add_task(async function test_reserved_sh is(document.getElementById("kt_reserveddefault").getAttribute("count"), "1", "default reserved with preference on"); document.documentElement.removeChild(container); await BrowserTestUtils.removeTab(tab); }); // This test checks that Alt+ and F10 cannot be blocked when the preference is set. -if (navigator.platform.indexOf("Mac") == -1) { +if (!navigator.platform.includes("Mac")) { add_task(async function test_accesskeys_menus() { await new Promise(resolve => { SpecialPowers.pushPrefEnv({"set": [["permissions.default.shortcuts", 2]]}, resolve); }); const uri = "data:text/html,"; let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, uri); @@ -71,17 +71,17 @@ if (navigator.platform.indexOf("Mac") == // pressing Down will open the file menu. let menubar = document.getElementById("main-menubar"); let menubarActive = BrowserTestUtils.waitForEvent(menubar, "DOMMenuBarActive"); EventUtils.sendKey("F10"); await menubarActive; let filePopup = document.getElementById("menu_FilePopup"); popupShown = BrowserTestUtils.waitForEvent(filePopup, "popupshown"); - if (navigator.platform.indexOf("Win") >= 0) { + if (navigator.platform.includes("Win")) { EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" }); } await popupShown; ok(true, "File menu opened"); popupHidden = BrowserTestUtils.waitForEvent(filePopup, "popuphidden"); filePopup.hidePopup(); diff --git a/browser/base/content/test/permissions/browser_reservedkey.js.1339461-1.later b/browser/base/content/test/permissions/browser_reservedkey.js.1339461-1.later deleted file mode 100644 --- a/browser/base/content/test/permissions/browser_reservedkey.js.1339461-1.later +++ /dev/null @@ -1,40 +0,0 @@ ---- browser_reservedkey.js -+++ browser_reservedkey.js -@@ -39,17 +39,17 @@ add_task(async function test_reserved_sh - is(document.getElementById("kt_reserveddefault").getAttribute("count"), "1", "default reserved with preference on"); - - document.documentElement.removeChild(container); - - await BrowserTestUtils.removeTab(tab); - }); - - // This test checks that Alt+ and F10 cannot be blocked when the preference is set. --if (navigator.platform.indexOf("Mac") == -1) { -+if (!navigator.platform.includes("Mac")) { - add_task(async function test_accesskeys_menus() { - await new Promise(resolve => { - SpecialPowers.pushPrefEnv({"set": [["permissions.default.shortcuts", 2]]}, resolve); - }); - - const uri = "data:text/html,"; - let tab1 = await BrowserTestUtils.openNewForegroundTab(gBrowser, uri); - -@@ -71,17 +71,17 @@ if (navigator.platform.indexOf("Mac") == - // pressing Down will open the file menu. - let menubar = document.getElementById("main-menubar"); - let menubarActive = BrowserTestUtils.waitForEvent(menubar, "DOMMenuBarActive"); - EventUtils.sendKey("F10"); - await menubarActive; - - let filePopup = document.getElementById("menu_FilePopup"); - popupShown = BrowserTestUtils.waitForEvent(filePopup, "popupshown"); -- if (navigator.platform.indexOf("Win") >= 0) { -+ if (navigator.platform.includes("Win")) { - EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" }); - } - await popupShown; - - ok(true, "File menu opened"); - - popupHidden = BrowserTestUtils.waitForEvent(filePopup, "popuphidden"); - filePopup.hidePopup(); diff --git a/browser/components/preferences/in-content-new/findInPage.js b/browser/components/preferences/in-content-new/findInPage.js --- a/browser/components/preferences/in-content-new/findInPage.js +++ b/browser/components/preferences/in-content-new/findInPage.js @@ -208,17 +208,17 @@ var gSearchResultsPane = { * to search for filted query in */ async searchFunction(event) { let query = event.target.value.trim().toLowerCase(); if (this.query == query) { return; } - let subQuery = this.query && query.indexOf(this.query) !== -1; + let subQuery = this.query && query.includes(this.query); this.query = query; this.getFindSelection(window).removeAllRanges(); this.removeAllSearchTooltips(); this.removeAllSearchMenuitemIndicators(); // Clear telemetry request if user types very frequently. if (this.telemetryTimer) { diff --git a/browser/components/preferences/in-content/findInPage.js.1339461-1.later b/browser/components/preferences/in-content/findInPage.js.1339461-1.later deleted file mode 100644 --- a/browser/components/preferences/in-content/findInPage.js.1339461-1.later +++ /dev/null @@ -1,21 +0,0 @@ ---- findInPage.js -+++ findInPage.js -@@ -208,17 +208,17 @@ var gSearchResultsPane = { - * to search for filted query in - */ - async searchFunction(event) { - let query = event.target.value.trim().toLowerCase(); - if (this.query == query) { - return; - } - -- let subQuery = this.query && query.indexOf(this.query) !== -1; -+ let subQuery = this.query && query.includes(this.query); - this.query = query; - - this.getFindSelection(window).removeAllRanges(); - this.removeAllSearchTooltips(); - this.removeAllSearchMenuitemIndicators(); - - // Clear telemetry request if user types very frequently. - if (this.telemetryTimer) { diff --git a/devtools/client/commandline/test/browser_cmd_inject.js.1339461-1.later b/devtools/client/commandline/test/browser_cmd_inject.js.1339461-1.later deleted file mode 100644 --- a/devtools/client/commandline/test/browser_cmd_inject.js.1339461-1.later +++ /dev/null @@ -1,21 +0,0 @@ ---- browser_cmd_inject.js -+++ browser_cmd_inject.js -@@ -73,17 +73,17 @@ function test() { - markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV", - hints: "", - status: "VALID", - args: { - library: { - value: function (library) { - is(library.type, "url", "inject type name"); - is(library.url.origin, "https://example.com", "inject url hostname"); -- ok(library.url.pathname.indexOf("_inject.js") != -1, "inject url path"); -+ ok(library.url.pathname.includes("_inject.js"), "inject url path"); - }, - status: "VALID" - } - } - }, - exec: { - output: [ /https:\/\/example.com\/browser\/devtools\/client\/commandline\/test\/browser_cmd_inject.js loaded/ ] - } diff --git a/devtools/client/debugger/new/test/mochitest/examples/wasm-sourcemaps/average.js b/devtools/client/debugger/new/test/mochitest/examples/wasm-sourcemaps/average.js --- a/devtools/client/debugger/new/test/mochitest/examples/wasm-sourcemaps/average.js +++ b/devtools/client/debugger/new/test/mochitest/examples/wasm-sourcemaps/average.js @@ -1734,17 +1734,17 @@ function integrateWasmJS(Module) { asm2wasm: asm2wasmImports, parent: Module // Module inside wasm-js.cpp refers to wasm-js.cpp; this allows access to the outside program. }; var exports = null; function lookupImport(mod, base) { var lookup = info; - if (mod.indexOf(".") < 0) { + if (!mod.includes(".")) { lookup = (lookup || {})[mod]; } else { var parts = mod.split("."); lookup = (lookup || {})[parts[0]]; lookup = (lookup || {})[parts[1]]; } if (base) { lookup = (lookup || {})[base]; @@ -2093,18 +2093,18 @@ integrateWasmJS(Module); var ASM_CONSTS = []; STATIC_BASE = Runtime.GLOBAL_BASE; STATICTOP = STATIC_BASE + 3008; /* global initializers */ __ATINIT__.push(); memoryInitializer = - Module["wasmJSMethod"].indexOf("asmjs") >= 0 || - Module["wasmJSMethod"].indexOf("interpret-asm2wasm") >= 0 + Module["wasmJSMethod"].includes("asmjs") || + Module["wasmJSMethod"].includes("interpret-asm2wasm") ? "average.js.mem" : null; var STATIC_BUMP = 3008; Module["STATIC_BASE"] = STATIC_BASE; Module["STATIC_BUMP"] = STATIC_BUMP; /* no memory initializer */ diff --git a/devtools/client/debugger/new/test/mochitest/examples/wasm-sourcemaps/average.js.1339461-1.later b/devtools/client/debugger/new/test/mochitest/examples/wasm-sourcemaps/average.js.1339461-1.later deleted file mode 100644 --- a/devtools/client/debugger/new/test/mochitest/examples/wasm-sourcemaps/average.js.1339461-1.later +++ /dev/null @@ -1,42 +0,0 @@ ---- average.js -+++ average.js -@@ -1734,17 +1734,17 @@ function integrateWasmJS(Module) { - asm2wasm: asm2wasmImports, - parent: Module // Module inside wasm-js.cpp refers to wasm-js.cpp; this allows access to the outside program. - }; - - var exports = null; - - function lookupImport(mod, base) { - var lookup = info; -- if (mod.indexOf(".") < 0) { -+ if (!mod.includes(".")) { - lookup = (lookup || {})[mod]; - } else { - var parts = mod.split("."); - lookup = (lookup || {})[parts[0]]; - lookup = (lookup || {})[parts[1]]; - } - if (base) { - lookup = (lookup || {})[base]; -@@ -2093,18 +2093,18 @@ integrateWasmJS(Module); - var ASM_CONSTS = []; - - STATIC_BASE = Runtime.GLOBAL_BASE; - - STATICTOP = STATIC_BASE + 3008; - /* global initializers */ __ATINIT__.push(); - - memoryInitializer = -- Module["wasmJSMethod"].indexOf("asmjs") >= 0 || -- Module["wasmJSMethod"].indexOf("interpret-asm2wasm") >= 0 -+ Module["wasmJSMethod"].includes("asmjs") || -+ Module["wasmJSMethod"].includes("interpret-asm2wasm") - ? "average.js.mem" - : null; - - var STATIC_BUMP = 3008; - Module["STATIC_BASE"] = STATIC_BASE; - Module["STATIC_BUMP"] = STATIC_BUMP; - - /* no memory initializer */ diff --git a/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js b/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js --- a/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js +++ b/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js @@ -271,17 +271,17 @@ NewConsoleOutputWrapper.prototype = { dispatchMessageUpdate: function (message, res) { // network-message-updated will emit when all the update message arrives. // Since we can't ensure the order of the network update, we check // that networkInfo.updates has all we need. // Note that 'requestPostData' is sent only for POST requests, so we need // to count with that. const NUMBER_OF_NETWORK_UPDATE = 8; let expectedLength = NUMBER_OF_NETWORK_UPDATE; - if (res.networkInfo.updates.indexOf("requestPostData") != -1) { + if (res.networkInfo.updates.includes("requestPostData")) { expectedLength++; } if (res.networkInfo.updates.length === expectedLength) { this.batchedMessageUpdates({ res, message }); } }, diff --git a/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js.1339461-1.later b/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js.1339461-1.later deleted file mode 100644 --- a/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js.1339461-1.later +++ /dev/null @@ -1,21 +0,0 @@ ---- new-console-output-wrapper.js -+++ new-console-output-wrapper.js -@@ -271,17 +271,17 @@ NewConsoleOutputWrapper.prototype = { - dispatchMessageUpdate: function (message, res) { - // network-message-updated will emit when all the update message arrives. - // Since we can't ensure the order of the network update, we check - // that networkInfo.updates has all we need. - // Note that 'requestPostData' is sent only for POST requests, so we need - // to count with that. - const NUMBER_OF_NETWORK_UPDATE = 8; - let expectedLength = NUMBER_OF_NETWORK_UPDATE; -- if (res.networkInfo.updates.indexOf("requestPostData") != -1) { -+ if (res.networkInfo.updates.includes("requestPostData")) { - expectedLength++; - } - - if (res.networkInfo.updates.length === expectedLength) { - this.batchedMessageUpdates({ res, message }); - } - }, - diff --git a/editor/libeditor/tests/test_bug1425997.html b/editor/libeditor/tests/test_bug1425997.html --- a/editor/libeditor/tests/test_bug1425997.html +++ b/editor/libeditor/tests/test_bug1425997.html @@ -30,17 +30,17 @@ SimpleTest.waitForFocus(function() { let originalContent = editor.innerHTML; function onCharacterDataModified() { // Until removing all NBSPs which were inserted by the editor, // emulates Backspace key with "delete" command. // When this test is created, the behavior is: // after 1st delete: "\n  \n" // after 2nd delete: "\n \n" // after 3rd delete: "\n\n" - while (editor.innerHTML.indexOf(" ") !== -1) { + while (editor.innerHTML.includes(" ")) { document.execCommand("delete", false); } } editor.addEventListener("DOMCharacterDataModified", onCharacterDataModified, { once: true }); editor.focus(); selection.selectAllChildren(document.getElementById("inline")); document.execCommand('insertHTML', false, 'text'); // This expected result is just same as the result of Chrome. diff --git a/editor/libeditor/tests/test_bug1425997.html.1339461-1.later b/editor/libeditor/tests/test_bug1425997.html.1339461-1.later deleted file mode 100644 --- a/editor/libeditor/tests/test_bug1425997.html.1339461-1.later +++ /dev/null @@ -1,21 +0,0 @@ ---- test_bug1425997.html -+++ test_bug1425997.html -@@ -30,17 +30,17 @@ SimpleTest.waitForFocus(function() { - let originalContent = editor.innerHTML; - function onCharacterDataModified() { - // Until removing all NBSPs which were inserted by the editor, - // emulates Backspace key with "delete" command. - // When this test is created, the behavior is: - // after 1st delete: "\n  \n" - // after 2nd delete: "\n \n" - // after 3rd delete: "\n\n" -- while (editor.innerHTML.indexOf(" ") !== -1) { -+ while (editor.innerHTML.includes(" ")) { - document.execCommand("delete", false); - } - } - editor.addEventListener("DOMCharacterDataModified", onCharacterDataModified, { once: true }); - editor.focus(); - selection.selectAllChildren(document.getElementById("inline")); - document.execCommand('insertHTML', false, 'text'); - // This expected result is just same as the result of Chrome. diff --git a/layout/base/tests/bug970964_inner2.html b/layout/base/tests/bug970964_inner2.html --- a/layout/base/tests/bug970964_inner2.html +++ b/layout/base/tests/bug970964_inner2.html @@ -53,17 +53,17 @@ function touchEvent(aOptions) { } function sendTouchEvent(windowUtils, aType, aEvent, aModifiers) { var ids = [], xs=[], ys=[], rxs = [], rys = [], rotations = [], forces = []; for (var touchType of ["touches", "changedTouches", "targetTouches"]) { for (var i = 0; i < aEvent[touchType].length; i++) { - if (ids.indexOf(aEvent[touchType][i].identifier) == -1) { + if (!ids.includes(aEvent[touchType][i].identifier)) { ids.push(aEvent[touchType][i].identifier); xs.push(aEvent[touchType][i].page.x); ys.push(aEvent[touchType][i].page.y); rxs.push(aEvent[touchType][i].radius.x); rys.push(aEvent[touchType][i].radius.y); rotations.push(aEvent[touchType][i].rotationAngle); forces.push(aEvent[touchType][i].force); } diff --git a/layout/base/tests/bug970964_inner2.html.1339461-1.later b/layout/base/tests/bug970964_inner2.html.1339461-1.later deleted file mode 100644 --- a/layout/base/tests/bug970964_inner2.html.1339461-1.later +++ /dev/null @@ -1,21 +0,0 @@ ---- bug970964_inner2.html -+++ bug970964_inner2.html -@@ -53,17 +53,17 @@ function touchEvent(aOptions) { - } - - function sendTouchEvent(windowUtils, aType, aEvent, aModifiers) { - var ids = [], xs=[], ys=[], rxs = [], rys = [], - rotations = [], forces = []; - - for (var touchType of ["touches", "changedTouches", "targetTouches"]) { - for (var i = 0; i < aEvent[touchType].length; i++) { -- if (ids.indexOf(aEvent[touchType][i].identifier) == -1) { -+ if (!ids.includes(aEvent[touchType][i].identifier)) { - ids.push(aEvent[touchType][i].identifier); - xs.push(aEvent[touchType][i].page.x); - ys.push(aEvent[touchType][i].page.y); - rxs.push(aEvent[touchType][i].radius.x); - rys.push(aEvent[touchType][i].radius.y); - rotations.push(aEvent[touchType][i].rotationAngle); - forces.push(aEvent[touchType][i].force); - } diff --git a/layout/style/test/chrome/bug418986-2.js b/layout/style/test/chrome/bug418986-2.js --- a/layout/style/test/chrome/bug418986-2.js +++ b/layout/style/test/chrome/bug418986-2.js @@ -109,17 +109,17 @@ var testMatch = function (key, val) { }; // __testToggles(resisting)__. // Test whether we are able to match the "toggle" media queries. var testToggles = function (resisting) { suppressed_toggles.forEach( function (key) { var exists = keyValMatches(key, 0) || keyValMatches(key, 1); - if (resisting || (toggles_enabled_in_content.indexOf(key) === -1 && !is_chrome_window)) { + if (resisting || (!toggles_enabled_in_content.includes(key) && !is_chrome_window)) { ok(!exists, key + " should not exist."); } else { ok(exists, key + " should exist."); } }); }; // __testWindowsSpecific__. @@ -205,17 +205,17 @@ var generateCSSLines = function (resisti let lines = ".spoof { background-color: red;}\n"; expected_values.forEach( function ([key, offVal, onVal]) { lines += mediaQueryCSSLine(key, resisting ? onVal : offVal, "green"); }); lines += ".suppress { background-color: " + (resisting ? "green" : "red") + ";}\n"; suppressed_toggles.forEach( function (key) { - if (toggles_enabled_in_content.indexOf(key) === -1 && !resisting && !is_chrome_window) { + if (!toggles_enabled_in_content.includes(key) && !resisting && !is_chrome_window) { lines += "#" + key + " { background-color: green; }\n"; } else { lines += suppressedMediaQueryCSSLine(key, resisting ? "red" : "green"); } }); if (OS === "WINNT") { lines += ".windows { background-color: " + (resisting ? "green" : "red") + ";}\n"; lines += windows_versions.map(val => "(-moz-os-version: " + val + ")").join(", ") + diff --git a/layout/style/test/chrome/bug418986-2.js.1339461-1.later b/layout/style/test/chrome/bug418986-2.js.1339461-1.later deleted file mode 100644 --- a/layout/style/test/chrome/bug418986-2.js.1339461-1.later +++ /dev/null @@ -1,40 +0,0 @@ ---- bug418986-2.js -+++ bug418986-2.js -@@ -109,17 +109,17 @@ var testMatch = function (key, val) { - }; - - // __testToggles(resisting)__. - // Test whether we are able to match the "toggle" media queries. - var testToggles = function (resisting) { - suppressed_toggles.forEach( - function (key) { - var exists = keyValMatches(key, 0) || keyValMatches(key, 1); -- if (resisting || (toggles_enabled_in_content.indexOf(key) === -1 && !is_chrome_window)) { -+ if (resisting || (!toggles_enabled_in_content.includes(key) && !is_chrome_window)) { - ok(!exists, key + " should not exist."); - } else { - ok(exists, key + " should exist."); - } - }); - }; - - // __testWindowsSpecific__. -@@ -205,17 +205,17 @@ var generateCSSLines = function (resisti - let lines = ".spoof { background-color: red;}\n"; - expected_values.forEach( - function ([key, offVal, onVal]) { - lines += mediaQueryCSSLine(key, resisting ? onVal : offVal, "green"); - }); - lines += ".suppress { background-color: " + (resisting ? "green" : "red") + ";}\n"; - suppressed_toggles.forEach( - function (key) { -- if (toggles_enabled_in_content.indexOf(key) === -1 && !resisting && !is_chrome_window) { -+ if (!toggles_enabled_in_content.includes(key) && !resisting && !is_chrome_window) { - lines += "#" + key + " { background-color: green; }\n"; - } else { - lines += suppressedMediaQueryCSSLine(key, resisting ? "red" : "green"); - } - }); - if (OS === "WINNT") { - lines += ".windows { background-color: " + (resisting ? "green" : "red") + ";}\n"; - lines += windows_versions.map(val => "(-moz-os-version: " + val + ")").join(", ") +