Bug 1544834 - Replace deprecated generics in test code r=evilpie

- `Array.map` becomes `Array.from`
- Array copying via `Array.slice` becomes `Array.from`.
- `Array.forEach` that did not rely on closures becomes `for`-`of` loops.
- Anything else: `Array.X` becomes `Array.prototype.X`.

Complex cases:

dom/bindings/test/TestInterfaceJS.js and
dom/bindings/test/test_exception_options_from_jsimplemented.html
use `Array.indexOf` to generate an error with a specific error message.
Switched to `Array.prototype.forEach` to generate the same error.

js/src/jit-test/tests/basic/exception-column-number.js
In this test `Array.indexOf()` is used to generate an error. Since the
exact message doesn't matter, I switched to `Array.from()`.

Intentionally not changed:

editor/libeditor/tests/browserscope/lib/richtext/richtext/js/range.js
Did not modify because this is 3rd-party code and the code uses
feature detection as a fall back when Array generics are not used.

testing/talos/talos/tests/dromaeo/lib/mootools.js
Did not modify because mootools adds the `Array.slice` method to the
`Array` object.

Not changed because they check the implementation of Array generics:
js/src/jit-test/tests/basic/arrayNatives.js
js/src/jit-test/tests/basic/bug563243.js
js/src/jit-test/tests/basic/bug618853.js
js/src/jit-test/tests/basic/bug830967.js
js/src/jit-test/tests/jaeger/recompile/bug656753.js
js/src/jit-test/tests/self-hosting/alternate-static-and-instance-array-extras.js
js/src/tests/non262/Array/generics.js
js/src/tests/non262/Array/regress-415540.js
js/src/tests/non262/extensions/regress-355497.js
js/src/tests/non262/extensions/typedarray-set-neutering.js

Depends on D27802

Differential Revision: https://phabricator.services.mozilla.com/D27803

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Rob Wu 2019-04-17 19:03:19 +00:00
Родитель 1af4c55c01
Коммит 4a6f84f91d
57 изменённых файлов: 110 добавлений и 111 удалений

Просмотреть файл

@ -32,12 +32,12 @@ function editableTextTest(aID) {
* Schedule a test, the given function with its arguments will be executed
* when preceding test is complete.
*/
this.scheduleTest = function scheduleTest(aFunc) {
this.scheduleTest = function scheduleTest(aFunc, ...aFuncArgs) {
// A data container acts like a dummy invoker, it's never invoked but
// it's used to generate real invoker when previous invoker was handled.
var dataContainer = {
func: aFunc,
funcArgs: Array.slice(arguments, 1),
funcArgs: aFuncArgs,
};
this.mEventQueue.push(dataContainer);

Просмотреть файл

@ -37,7 +37,7 @@ function doTabsTest() {
gBrowser.tabContainer.addEventListener("TabClose", function(event) {
var closedTab = event.originalTarget;
var scheme = closedTab.linkedBrowser.currentURI.scheme;
Array.slice(gBrowser.tabs).forEach(function(aTab) {
Array.from(gBrowser.tabs).forEach(function(aTab) {
if (aTab != closedTab && aTab.linkedBrowser.currentURI.scheme == scheme)
gBrowser.removeTab(aTab, {skipPermitUnload: true});
});

Просмотреть файл

@ -32,5 +32,5 @@ function test() {
}
function idx(tab) {
return Array.indexOf(gBrowser.tabs, tab);
return Array.prototype.indexOf.call(gBrowser.tabs, tab);
}

Просмотреть файл

@ -1,6 +1,6 @@
function test() {
var ids = {};
Array.forEach(document.querySelectorAll("[id]"), function(node) {
Array.prototype.forEach.call(document.querySelectorAll("[id]"), function(node) {
var id = node.id;
ok(!(id in ids), id + " should be unique");
ids[id] = null;

Просмотреть файл

@ -29,7 +29,7 @@ add_task(async function() {
let validLinks = await ContentTask.spawn(gBrowser.selectedBrowser, items, function(contentItems) {
let contentValidLinks = 0;
Array.forEach(content.document.querySelectorAll("link, style"), function(el) {
Array.prototype.forEach.call(content.document.querySelectorAll("link, style"), function(el) {
var title = el.getAttribute("title");
var rel = el.getAttribute("rel");
var media = el.getAttribute("media");

Просмотреть файл

@ -40,7 +40,7 @@ add_task(async function() {
await addTab("http://mochi.test:8888/#7");
function testPosition(tabNum, expectedPosition, msg) {
is(Array.indexOf(gBrowser.tabs, tabs[tabNum]), expectedPosition, msg);
is(Array.prototype.indexOf.call(gBrowser.tabs, tabs[tabNum]), expectedPosition, msg);
}
testPosition(0, 3, "tab without referrer was opened to the far right");

Просмотреть файл

@ -65,7 +65,7 @@ add_task(async function() {
is(gBrowser.selectedTab, testTab, "next to test tab again");
// Try showing all tabs
gBrowser.showOnlyTheseTabs(Array.slice(gBrowser.tabs));
gBrowser.showOnlyTheseTabs(Array.from(gBrowser.tabs));
is(gBrowser.visibleTabs.length, 3, "all 3 tabs are visible again");
// Select the pinned tab and show the testTab to make sure selection updates

Просмотреть файл

@ -22,9 +22,9 @@ function test() {
gBrowser.removeTab(tabOne);
gBrowser.removeTab(tabTwo);
Array.forEach(gBrowser.tabs, function(tab) {
for (let tab of gBrowser.tabs) {
gBrowser.showTab(tab);
});
}
finish();
});

Просмотреть файл

@ -901,7 +901,7 @@ function checkSendToDeviceItems(expectedItems, forUrlbar = false) {
function collectContextMenuItems() {
let contextMenu = document.getElementById("pageActionContextMenu");
return Array.filter(contextMenu.children, node => {
return Array.prototype.filter.call(contextMenu.children, node => {
return window.getComputedStyle(node).visibility == "visible";
});
}

Просмотреть файл

@ -118,7 +118,7 @@ add_task(async function many() {
let bodyID = viewID + "-body";
let body = document.getElementById(bodyID);
Assert.deepEqual(
Array.map(body.children, n => n.label),
Array.from(body.children, n => n.label),
[
"page_action_menu_add_search_engine_0",
"page_action_menu_add_search_engine_1",
@ -147,7 +147,7 @@ add_task(async function many() {
EventUtils.synthesizeMouseAtCenter(button, {});
await viewPromise;
Assert.deepEqual(
Array.map(body.children, n => n.label),
Array.from(body.children, n => n.label),
[
"page_action_menu_add_search_engine_1",
"page_action_menu_add_search_engine_2",
@ -250,7 +250,7 @@ add_task(async function many() {
await viewPromise;
body = document.getElementById(bodyID);
Assert.deepEqual(
Array.map(body.children, n => n.label),
Array.from(body.children, n => n.label),
[
"page_action_menu_add_search_engine_0",
"page_action_menu_add_search_engine_1",
@ -272,7 +272,7 @@ add_task(async function many() {
EventUtils.synthesizeMouseAtCenter(button, {});
await viewPromise;
Assert.deepEqual(
Array.map(body.children, n => n.label),
Array.from(body.children, n => n.label),
[
"page_action_menu_add_search_engine_0",
"page_action_menu_add_search_engine_1",
@ -368,7 +368,7 @@ add_task(async function urlbarMany() {
Assert.equal(view.id, viewID, "View ID");
let body = view.firstElementChild;
Assert.deepEqual(
Array.map(body.children, n => n.label),
Array.from(body.children, n => n.label),
[
"page_action_menu_add_search_engine_0",
"page_action_menu_add_search_engine_1",
@ -396,7 +396,7 @@ add_task(async function urlbarMany() {
view = await waitForActivatedActionPanel();
body = view.firstElementChild;
Assert.deepEqual(
Array.map(body.children, n => n.label),
Array.from(body.children, n => n.label),
[
"page_action_menu_add_search_engine_1",
"page_action_menu_add_search_engine_2",
@ -461,7 +461,7 @@ add_task(async function urlbarMany() {
view = await waitForActivatedActionPanel();
body = view.firstElementChild;
Assert.deepEqual(
Array.map(body.children, n => n.label),
Array.from(body.children, n => n.label),
[
"page_action_menu_add_search_engine_0",
"page_action_menu_add_search_engine_1",
@ -486,7 +486,7 @@ add_task(async function urlbarMany() {
view = await waitForActivatedActionPanel();
body = view.firstElementChild;
Assert.deepEqual(
Array.map(body.children, n => n.label),
Array.from(body.children, n => n.label),
[
"page_action_menu_add_search_engine_0",
"page_action_menu_add_search_engine_1",

Просмотреть файл

@ -217,7 +217,7 @@ function checkPopup(popup, notifyObj) {
}
// Additional secondary actions appear as menu items.
let actualExtraSecondaryActions =
Array.filter(notification.menupopup.childNodes, child => child.nodeName == "menuitem");
Array.prototype.filter.call(notification.menupopup.childNodes, child => child.nodeName == "menuitem");
let extraSecondaryActions = notifyObj.secondaryActions ? notifyObj.secondaryActions.slice(1) : [];
is(actualExtraSecondaryActions.length, extraSecondaryActions.length,
"number of extra secondary actions matches");

Просмотреть файл

@ -47,9 +47,9 @@ add_task(async function test_simple() {
// Messages should be visible when the scheme is HTTP, and invisible when
// the scheme is HTTPS.
is(Array.every(document.getElementById("identity-popup-mainView")
.querySelectorAll("[when-loginforms=insecure]"),
element => !BrowserTestUtils.is_hidden(element)),
is(Array.prototype.every.call(document.getElementById("identity-popup-mainView")
.querySelectorAll("[when-loginforms=insecure]"),
element => !BrowserTestUtils.is_hidden(element)),
expectWarning,
"The relevant messages should be visible or hidden in the main view.");
@ -85,9 +85,9 @@ add_task(async function test_simple() {
// Messages should be visible when the scheme is HTTP, and invisible when
// the scheme is HTTPS.
is(Array.every(document.getElementById("identity-popup-securityView")
.querySelectorAll("[when-loginforms=insecure]"),
element => !BrowserTestUtils.is_hidden(element)),
is(Array.prototype.every.call(document.getElementById("identity-popup-securityView")
.querySelectorAll("[when-loginforms=insecure]"),
element => !BrowserTestUtils.is_hidden(element)),
expectWarning,
"The relevant messages should be visible or hidden in the security view.");
@ -161,9 +161,9 @@ add_task(async function test_ignoring_window_opener() {
gIdentityHandler._identityBox.click();
await promisePanelOpen;
ok(Array.every(document.getElementById("identity-popup-mainView")
.querySelectorAll("[when-loginforms=insecure]"),
element => BrowserTestUtils.is_hidden(element)),
ok(Array.prototype.every.call(document.getElementById("identity-popup-mainView")
.querySelectorAll("[when-loginforms=insecure]"),
element => BrowserTestUtils.is_hidden(element)),
"All messages should be hidden in the main view.");
let promiseViewShown = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "ViewShown");
@ -195,9 +195,9 @@ add_task(async function test_ignoring_window_opener() {
"url(\"chrome://browser/skin/controlcenter/connection.svg\")",
"Using expected icon image in the Control Center subview");
ok(Array.every(document.getElementById("identity-popup-securityView")
.querySelectorAll("[when-loginforms=insecure]"),
element => BrowserTestUtils.is_hidden(element)),
ok(Array.prototype.every.call(document.getElementById("identity-popup-securityView")
.querySelectorAll("[when-loginforms=insecure]"),
element => BrowserTestUtils.is_hidden(element)),
"All messages should be hidden in the security view.");
if (gIdentityHandler._identityPopup.state != "closed") {

Просмотреть файл

@ -226,9 +226,9 @@ async function assertMixedContentBlockingState(tabbrowser, states = {}) {
let promiseViewShown = BrowserTestUtils.waitForEvent(gIdentityHandler._identityPopup, "ViewShown");
doc.getElementById("identity-popup-security-expander").click();
await promiseViewShown;
is(Array.filter(doc.getElementById("identity-popup-securityView")
.querySelectorAll(".identity-popup-mcb-learn-more"),
element => !BrowserTestUtils.is_hidden(element)).length, 1,
is(Array.prototype.filter.call(doc.getElementById("identity-popup-securityView")
.querySelectorAll(".identity-popup-mcb-learn-more"),
element => !BrowserTestUtils.is_hidden(element)).length, 1,
"The 'Learn more' link should be visible once.");
}

Просмотреть файл

@ -1,7 +1,7 @@
var tabs;
function index(tab) {
return Array.indexOf(gBrowser.tabs, tab);
return Array.prototype.indexOf.call(gBrowser.tabs, tab);
}
function indexTest(tab, expectedIndex, msg) {

Просмотреть файл

@ -4,7 +4,7 @@
"use strict";
function index(tab) {
return Array.indexOf(gBrowser.tabs, tab);
return Array.prototype.indexOf.call(gBrowser.tabs, tab);
}
async function testNewTabPosition(expectedPosition, modifiers = {}) {

Просмотреть файл

@ -123,7 +123,7 @@ class AboutConfigTest {
*/
get rows() {
let elements = this.prefsTable.querySelectorAll("tr:not(.hidden)");
return Array.map(elements, element => new AboutConfigRowTest(element));
return Array.from(elements, element => new AboutConfigRowTest(element));
}
/**

Просмотреть файл

@ -146,7 +146,7 @@ add_task(async function test_hiddenPageActionContextMenu() {
await extension.awaitMessage("ready");
const menu = await openContextMenuInPageActionPanel(extension);
const menuItems = Array.filter(menu.children, node => {
const menuItems = Array.prototype.filter.call(menu.children, node => {
return window.getComputedStyle(node).visibility == "visible";
});

Просмотреть файл

@ -33,8 +33,8 @@ function checkMenuEntries(expectedValues) {
function getMenuEntries() {
// Could perhaps pull values directly from the controller, but it seems
// more reliable to test the values that are actually in the richlistbox?
return Array.map(searchBar.textbox.popup.richlistbox.itemChildren,
item => item.getAttribute("ac-value"));
return Array.from(searchBar.textbox.popup.richlistbox.itemChildren,
item => item.getAttribute("ac-value"));
}
function countEntries(name, value) {

Просмотреть файл

@ -68,6 +68,6 @@ add_task(async function() {
function getMenuEntries(searchBar) {
// Could perhaps pull values directly from the controller, but it seems
// more reliable to test the values that are actually in the richlistbox?
return Array.map(searchBar.textbox.popup.richlistbox.itemChildren,
item => item.getAttribute("ac-value"));
return Array.from(searchBar.textbox.popup.richlistbox.itemChildren,
item => item.getAttribute("ac-value"));
}

Просмотреть файл

@ -54,7 +54,7 @@ function test() {
else if (typeof aValue == "number")
node.selectedIndex = aValue;
else
Array.forEach(node.options, (aOpt, aIx) =>
Array.prototype.forEach.call(node.options, (aOpt, aIx) =>
(aOpt.selected = aValue.indexOf(aIx) > -1));
}
@ -69,7 +69,7 @@ function test() {
return aValue == node.value;
if (!node.multiple)
return aValue == node.selectedIndex;
return Array.every(node.options, (aOpt, aIx) =>
return Array.prototype.every.call(node.options, (aOpt, aIx) =>
(aValue.indexOf(aIx) > -1) == aOpt.selected);
}

Просмотреть файл

@ -8,12 +8,12 @@ add_task(async function() {
let tab2 = BrowserTestUtils.addTab(gBrowser);
gBrowser.pinTab(tab2);
is(Array.indexOf(gBrowser.tabs, tab1), 0, "pinned tab 1 is at the first position");
is(Array.prototype.indexOf.call(gBrowser.tabs, tab1), 0, "pinned tab 1 is at the first position");
await promiseRemoveTabAndSessionState(tab1);
tab1 = undoCloseTab();
ok(tab1.pinned, "pinned tab 1 has been restored as a pinned tab");
is(Array.indexOf(gBrowser.tabs, tab1), 0, "pinned tab 1 has been restored to the first position");
is(Array.prototype.indexOf.call(gBrowser.tabs, tab1), 0, "pinned tab 1 has been restored to the first position");
BrowserTestUtils.removeTab(tab1);
BrowserTestUtils.removeTab(tab2);

Просмотреть файл

@ -85,7 +85,7 @@ add_task(async function() {
await setBrowserState(state);
// Wait until the selected tab is restored and all others are pending.
await Promise.all(Array.map(gBrowser.tabs, tab => {
await Promise.all(Array.from(gBrowser.tabs, tab => {
return (tab == gBrowser.selectedTab) ?
promiseTabRestored(tab) : promiseTabRestoring(tab);
}));

Просмотреть файл

@ -88,13 +88,13 @@ defineListener("setSelectedIndex", function(data) {
defineListener("getMultipleSelected", function(data) {
let input = queryElement(data);
return Array.map(input.options, (opt, idx) => idx)
return Array.from(input.options, (opt, idx) => idx)
.filter(idx => input.options[idx].selected);
});
defineListener("setMultipleSelected", function(data) {
let input = queryElement(data);
Array.forEach(input.options, (opt, idx) => opt.selected = data.indices.indexOf(idx) > -1);
Array.prototype.forEach.call(input.options, (opt, idx) => opt.selected = data.indices.indexOf(idx) > -1);
dispatchUIEvent(input, "input");
});

Просмотреть файл

@ -54,7 +54,7 @@ addEventListener("hashchange", function() {
addMessageListener("ss-test:getStyleSheets", function(msg) {
let sheets = content.document.styleSheets;
let titles = Array.map(sheets, ss => [ss.title, ss.disabled]);
let titles = Array.from(sheets, ss => [ss.title, ss.disabled]);
sendSyncMessage("ss-test:getStyleSheets", titles);
});

Просмотреть файл

@ -791,7 +791,7 @@ add_task(async function nonBuiltFirst() {
EventUtils.synthesizeMouseAtCenter(BrowserPageActions.mainButtonNode, {});
await promisePageActionPanelHidden();
Assert.deepEqual(
Array.map(BrowserPageActions.mainViewBodyNode.children, n => n.id),
Array.from(BrowserPageActions.mainViewBodyNode.children, n => n.id),
[BrowserPageActions.panelButtonNodeIDForActionID(action.id)],
"Action should be in panel"
);
@ -833,7 +833,7 @@ add_task(async function nonBuiltFirst() {
"All actions should be in PageActions.actionsInPanel()"
);
Assert.deepEqual(
Array.map(BrowserPageActions.mainViewBodyNode.children, n => n.id),
Array.from(BrowserPageActions.mainViewBodyNode.children, n => n.id),
initialActionsInPanel.map(a => a.id).concat(
[PageActions.ACTION_ID_BUILT_IN_SEPARATOR],
[action.id]
@ -871,7 +871,7 @@ add_task(async function nonBuiltFirst() {
"Action should no longer be in PageActions.actionsInPanel()"
);
Assert.deepEqual(
Array.map(BrowserPageActions.mainViewBodyNode.children, n => n.id),
Array.from(BrowserPageActions.mainViewBodyNode.children, n => n.id),
initialActionsInPanel.map(a => BrowserPageActions.panelButtonNodeIDForActionID(a.id)),
"Action should no longer be in panel"
);
@ -1509,7 +1509,7 @@ add_task(async function transient() {
EventUtils.synthesizeMouseAtCenter(BrowserPageActions.mainButtonNode, {});
await promisePageActionPanelHidden();
Assert.deepEqual(
Array.map(BrowserPageActions.mainViewBodyNode.children, n => n.id),
Array.from(BrowserPageActions.mainViewBodyNode.children, n => n.id),
initialActionsInPanel.map(a => a.id).concat([
PageActions.ACTION_ID_TRANSIENT_SEPARATOR,
action.id,
@ -1536,7 +1536,7 @@ add_task(async function transient() {
EventUtils.synthesizeMouseAtCenter(BrowserPageActions.mainButtonNode, {});
await promisePageActionPanelHidden();
Assert.deepEqual(
Array.map(BrowserPageActions.mainViewBodyNode.children, n => n.id),
Array.from(BrowserPageActions.mainViewBodyNode.children, n => n.id),
initialActionsInPanel
.map(a => BrowserPageActions.panelButtonNodeIDForActionID(a.id)),
"Actions in panel should be correct"
@ -1559,7 +1559,7 @@ add_task(async function transient() {
EventUtils.synthesizeMouseAtCenter(BrowserPageActions.mainButtonNode, {});
await promisePageActionPanelHidden();
Assert.deepEqual(
Array.map(BrowserPageActions.mainViewBodyNode.children, n => n.id),
Array.from(BrowserPageActions.mainViewBodyNode.children, n => n.id),
initialActionsInPanel.map(a => a.id).concat([
PageActions.ACTION_ID_TRANSIENT_SEPARATOR,
action.id,
@ -1594,7 +1594,7 @@ add_task(async function transient() {
EventUtils.synthesizeMouseAtCenter(BrowserPageActions.mainButtonNode, {});
await promisePageActionPanelHidden();
Assert.deepEqual(
Array.map(BrowserPageActions.mainViewBodyNode.children, n => n.id),
Array.from(BrowserPageActions.mainViewBodyNode.children, n => n.id),
initialActionsInPanel.map(a => a.id).concat([
PageActions.ACTION_ID_BUILT_IN_SEPARATOR,
otherAction.id,
@ -1626,7 +1626,7 @@ add_task(async function transient() {
EventUtils.synthesizeMouseAtCenter(BrowserPageActions.mainButtonNode, {});
await promisePageActionPanelHidden();
Assert.deepEqual(
Array.map(BrowserPageActions.mainViewBodyNode.children, n => n.id),
Array.from(BrowserPageActions.mainViewBodyNode.children, n => n.id),
initialActionsInPanel.map(a => a.id).concat([
PageActions.ACTION_ID_BUILT_IN_SEPARATOR,
otherAction.id,
@ -1653,7 +1653,7 @@ add_task(async function transient() {
EventUtils.synthesizeMouseAtCenter(BrowserPageActions.mainButtonNode, {});
await promisePageActionPanelHidden();
Assert.deepEqual(
Array.map(BrowserPageActions.mainViewBodyNode.children, n => n.id),
Array.from(BrowserPageActions.mainViewBodyNode.children, n => n.id),
initialActionsInPanel.map(a => a.id).concat([
PageActions.ACTION_ID_BUILT_IN_SEPARATOR,
otherAction.id,
@ -1789,7 +1789,7 @@ function promisePageActionViewChildrenVisible(panelViewNode) {
function collectContextMenuItems() {
let contextMenu = document.getElementById("pageActionContextMenu");
return Array.filter(contextMenu.children, node => {
return Array.prototype.filter.call(contextMenu.children, node => {
return window.getComputedStyle(node).visibility == "visible";
});
}

Просмотреть файл

@ -44,8 +44,8 @@ async function spawnTest() {
.filter(m => MARKER_TYPES.includes(m.name));
info(`Got ${bars.length} bars and ${markers.length} markers.`);
info("Markers types from datasrc: " + Array.map(markers, e => e.name));
info("Markers names from sidebar: " + Array.map(bars, e => e.parentNode.parentNode.querySelector(".waterfall-marker-name").getAttribute("value")));
info("Markers types from datasrc: " + Array.from(markers, e => e.name));
info("Markers names from sidebar: " + Array.from(bars, e => e.parentNode.parentNode.querySelector(".waterfall-marker-name").getAttribute("value")));
ok(bars.length >= MARKER_TYPES.length, `Got at least ${MARKER_TYPES.length} markers (1)`);
ok(markers.length >= MARKER_TYPES.length, `Got at least ${MARKER_TYPES.length} markers (2)`);

Просмотреть файл

@ -29,7 +29,8 @@ add_task(function() {
is(container.childNodes.length, 7,
"The container node should have all children available.");
is(Array.filter(container.childNodes, e => e.className != "call-tree-item").length, 0,
is(Array.from(container.childNodes).filter(e => e.className != "call-tree-item").length,
0,
"All item nodes in the tree have the correct class name.");
is($$fun(0).style.marginInlineStart, "0px",

Просмотреть файл

@ -50,7 +50,7 @@ async function spawnTest() {
ok(beforeResizeBarsCount < initialBarsCount,
"A subset of the total markers was selected.");
is(Array.indexOf($$(".waterfall-tree-item"), $(".waterfall-tree-item:focus")), 2,
is(Array.prototype.indexOf.call($$(".waterfall-tree-item"), $(".waterfall-tree-item:focus")), 2,
"The correct item was focused in the tree.");
ok(!$("#waterfall-details").hidden,
"The waterfall sidebar is now visible.");
@ -65,7 +65,7 @@ async function spawnTest() {
is(afterResizeBarsCount, beforeResizeBarsCount,
"The same subset of the total markers remained visible.");
is(Array.indexOf($$(".waterfall-tree-item"), $(".waterfall-tree-item:focus")), 2,
is(Array.prototype.indexOf.call($$(".waterfall-tree-item"), $(".waterfall-tree-item:focus")), 2,
"The correct item is still focused in the tree.");
ok(!$("#waterfall-details").hidden,
"The waterfall sidebar is still visible.");

Просмотреть файл

@ -40,8 +40,8 @@ async function spawnTest() {
let markers = PerformanceController.getCurrentRecording().getMarkers();
info(`Got ${bars.length} bars and ${markers.length} markers.`);
info("Markers types from datasrc: " + Array.map(markers, e => e.name));
info("Markers names from sidebar: " + Array.map(bars, e => e.parentNode.parentNode.querySelector(".waterfall-marker-name").getAttribute("value")));
info("Markers types from datasrc: " + Array.from(markers, e => e.name));
info("Markers names from sidebar: " + Array.from(bars, e => e.parentNode.parentNode.querySelector(".waterfall-marker-name").getAttribute("value")));
ok(bars.length > 2, "Got at least 3 markers (1)");
ok(markers.length > 2, "Got at least 3 markers (2)");

Просмотреть файл

@ -82,7 +82,7 @@ function runTest(parser, serializer) {
continue;
}
let array = Array.map(t.input, function(c) { return c.charCodeAt(c); });
let array = Array.from(t.input, function(c) { return c.charCodeAt(c); });
let inputs = [
{array: array, name: "parseFromBuffer (array)"},
{array: new Uint8Array(array), name: "parseFromBuffer (Uint8Array)"},

Просмотреть файл

@ -85,11 +85,11 @@ TestInterfaceJS.prototype = {
},
testThrowXraySelfHosted() {
this._win.Array.indexOf();
this._win.Array.prototype.forEach();
},
testThrowSelfHosted() {
Array.indexOf();
Array.prototype.forEach();
},
testPromiseWithThrowingChromePromiseInit() {

Просмотреть файл

@ -89,16 +89,16 @@ ${asyncFrame}`,
}
try {
t.testThrowCallbackError(function() { Array.indexOf(); });
t.testThrowCallbackError(function() { Array.prototype.forEach(); });
} catch (e) {
ok(e instanceof TypeError, "Should have a TypeError here (3)");
ok(!(e instanceof DOMException), "Should not have DOMException here (3)");
ok(!("code" in e), "Should not have a 'code' property (3)");
is(e.name, "TypeError", "Should be named TypeError (3)");
is(e.message, "missing argument 0 when calling function Array.indexOf",
is(e.message, "missing argument 0 when calling function Array.prototype.forEach",
"Should also have the right message (3)");
is(e.stack,
`doTest/<@${file}:92:51
`doTest/<@${file}:92:61
doTest@${file}:92:9
${asyncFrame}`,
"Exception stack for TypeError should only show our code (3)");
@ -106,7 +106,7 @@ ${asyncFrame}`,
file,
"Should still have the right file name for TypeError (3)");
is(e.lineNumber, 92, "Should still have the right line number for TypeError (3)");
is(e.columnNumber, 51, "Should have the right column number for TypeError (3)");
is(e.columnNumber, 61, "Should have the right column number for TypeError (3)");
}
try {

Просмотреть файл

@ -33,7 +33,7 @@ const browserElementTestHelpers = {
_setPrefs() {
this.lockTestReady();
SpecialPowers.pushPrefEnv({"set": Array.slice(arguments)}, this.unlockTestReady.bind(this));
SpecialPowers.pushPrefEnv({"set": Array.from(arguments)}, this.unlockTestReady.bind(this));
},
_testReadyLockCount: 0,

Просмотреть файл

@ -42,7 +42,7 @@ function runTests() {
SimpleTest.waitForFocus(runTests);
function isRectContainedInRectFromRegion(rect, region) {
return Array.some(region, function (r) {
return Array.prototype.some.call(region, function (r) {
return rect.left >= r.left &&
rect.top >= r.top &&
rect.right <= r.right &&

Просмотреть файл

@ -58,7 +58,7 @@ function runTests() {
SimpleTest.waitForFocus(runTests);
function isRectContainedInRectFromRegion(rect, region) {
return Array.some(region, function (r) {
return Array.prototype.some.call(region, function (r) {
return rect.left >= r.left &&
rect.top >= r.top &&
rect.right <= r.right &&

Просмотреть файл

@ -1094,8 +1094,8 @@ class VideoStreamHelper {
await h.waitForPixel(video, px => {
let result = h.isOpaquePixelNot(px, h.black, threshold);
info("Checking that we have a frame, got [" +
Array.slice(px) + "]. Ref=[" +
Array.slice(h.black.data) + "]. Threshold=" + threshold +
Array.from(px) + "]. Ref=[" +
Array.from(h.black.data) + "]. Threshold=" + threshold +
". Pass=" + result);
return result;
}, { offsetX, offsetY });
@ -1113,7 +1113,7 @@ class VideoStreamHelper {
await h.waitForPixel(video, px => {
let result = h.isPixelNot(px, startPixel, threshold);
info("Checking playing, [" +
Array.slice(px) + "] vs [" + Array.slice(startPixel.data) +
Array.from(px) + "] vs [" + Array.from(startPixel.data) +
"]. Threshold=" + threshold + " Pass=" + result);
return result;
}, { offsetX, offsetY });
@ -1132,7 +1132,7 @@ class VideoStreamHelper {
await h.waitForPixel(video, px => {
let result = h.isOpaquePixelNot(px, startPixel, threshold);
info("Checking paused, [" +
Array.slice(px) + "] vs [" + Array.slice(startPixel.data) +
Array.from(px) + "] vs [" + Array.from(startPixel.data) +
"]. Threshold=" + threshold + " Pass=" + result);
return result;
}, { offsetX, offsetY, cancel: wait(time, "timeout") });

Просмотреть файл

@ -41,7 +41,7 @@
await helper.waitForPixel(video, px => {
let result = helper.isPixel(px, color, 16);
info("Checking pixel against " + color.name + ". Got ["
+ Array.slice(px) + "] (" + (result ? "YES" : "NO") + ")");
+ Array.from(px) + "] (" + (result ? "YES" : "NO") + ")");
return result;
}, {offsetX: x, offsetY: y});
}

Просмотреть файл

@ -38,7 +38,7 @@ function spawnWithObserver(browser, observerFunc, func) {
" let gLevel, gArgs, gStyle;",
" let expect = function(level) {",
" gLevel = level;",
" gArgs = Array.slice(arguments, 1);",
" gArgs = Array.prototype.slice.call(arguments, 1);",
" }",
// To ease the transition to the new format, content.window is avaliable as gWindow
// in the content.

Просмотреть файл

@ -31,7 +31,7 @@ var Native = function(k) {
} ());
Array.alias("forEach", "each");
function $merge() {
var a = Array.slice(arguments);
var a = Array.prototype.slice.call(arguments);
a.unshift({});
return $mixin.apply(null, a);
}

Просмотреть файл

@ -1,5 +1,5 @@
try {
Array.indexOf();
Array.from();
} catch (e) {
assertEq(e.columnNumber, 11);
// Filter the filename from the stack, since we have no clue what

Просмотреть файл

@ -2,9 +2,8 @@
load(libdir + "asserts.js");
function testcase(obj, fn) {
function testcase(obj, fn, ...args) {
assertEq(typeof fn, "function");
var args = Array.slice(arguments, 2);
assertThrowsInstanceOf(function () { fn.apply(obj, args); }, TypeError);
}

Просмотреть файл

@ -2,9 +2,8 @@
load(libdir + "asserts.js");
function testcase(obj, fn) {
function testcase(obj, fn, ...args) {
assertEq(typeof fn, "function");
var args = Array.slice(arguments, 2);
assertThrowsInstanceOf(function () { fn.apply(obj, args); }, TypeError);
}

Просмотреть файл

@ -29,7 +29,7 @@ function test()
}
function reportResults(size, N, literalMs, newArrayMs, arrayMs) {
print(Array.join(arguments, "\t"));
print(Array.prototype.join.call(arguments, "\t"));
}
var repetitions = [ 9000, 7000, 4000, 2000, 2000, 2000, 800, 800, 800, 300, 100, 100 ]

Просмотреть файл

@ -190,7 +190,7 @@ var gDisplay = document.getElementById("display")
[ 'omta_is', 'omta_todo_is', 'omta_is_approx' ].forEach(function(fn) {
var origFn = window[fn];
window[fn] = function() {
var args = Array.slice(arguments);
var args = Array.from(arguments);
if (!(args[0] instanceof Element)) {
args.unshift(gDiv);
}

Просмотреть файл

@ -28,7 +28,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=635286
/** Test for Bug 635286 **/
window.addEventListener("load", function() {
var cases = Array.slice(document.getElementsByTagName("div"));
var cases = Array.from(document.getElementsByTagName("div"));
cases.forEach(function(aCase, aIndex) {
aCase.className = "after";
});

Просмотреть файл

@ -39,7 +39,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=613888
var count_remaining = 6;
window.addEventListener('load', function() {
var cases = Array.slice(document.querySelectorAll('#animated-elements-container > span'));
var cases = Array.from(document.querySelectorAll('#animated-elements-container > span'));
cases.forEach(function(aTarget) {
aTarget.addEventListener('transitionend', function(aEvent) {

Просмотреть файл

@ -73,7 +73,7 @@ function doTest() {
testResizer(1, 1);
var resizers = document.getElementsByTagName("resizer");
Array.forEach(resizers, function (element) {
Array.prototype.forEach.call(resizers, function (element) {
is(getComputedStyle(element, "").cursor,
element.getAttribute("expectedcursor"),
"cursor for " + element.dir);
@ -82,7 +82,7 @@ function doTest() {
// now check the cursors in rtl. The bottomend resizer
// should be reversed
document.documentElement.setAttribute("localedir", "rtl");
Array.forEach(resizers, function (element) {
Array.prototype.forEach.call(resizers, function (element) {
is(getComputedStyle(element, "").cursor,
element.dir == "bottomend" ? "sw-resize" :
element.getAttribute("expectedcursor"),

Просмотреть файл

@ -58,7 +58,7 @@ function do_check_throws_message(aFunc, aResult) {
* @usage _(1, 2, 3) -> prints "1 2 3"
*/
var _ = function(some, debug, text, to) {
print(Array.slice(arguments).join(" "));
print(Array.from(arguments).join(" "));
};
function httpd_setup(handlers, port = -1) {

Просмотреть файл

@ -69,5 +69,5 @@ addResourceAlias();
* @usage _(1, 2, 3) -> prints "1 2 3"
*/
var _ = function(some, debug, text, to) {
print(Array.slice(arguments).join(" "));
print(Array.from(arguments).join(" "));
};

Просмотреть файл

@ -28,12 +28,12 @@ add_task(async function test_clients_escape() {
let serialized = JSON.stringify(record);
let checkCount = 0;
_("Checking for all ASCII:", serialized);
Array.forEach(serialized, function(ch) {
for (let ch of serialized) {
let code = ch.charCodeAt(0);
_("Checking asciiness of '", ch, "'=", code);
Assert.ok(code < 128);
checkCount++;
});
}
_("Processed", checkCount, "characters out of", serialized.length);
Assert.equal(checkCount, serialized.length);

Просмотреть файл

@ -15,7 +15,7 @@ function run_test() {
Assert.equal(encodeURIComponent(newGuid).length, 12);
// Verify that the GUID only contains base64url characters
Assert.ok(Array.every(newGuid, function(chr) {
Assert.ok(Array.prototype.every.call(newGuid, function(chr) {
return base64url.includes(chr);
}));

Просмотреть файл

@ -279,7 +279,7 @@ function onEx(event, names, dontRemove) {
obs[meth] = () => do_throw(meth + " should not be called for " + name);
});
obs["onContentPref" + event] = function() {
args[name].push(Array.slice(arguments));
args[name].push(Array.from(arguments));
if (!triggered) {
triggered = true;

Просмотреть файл

@ -6,8 +6,8 @@ add_task(async function test_MatchPattern_matches() {
function test(url, pattern, normalized = pattern, options = {}, explicit) {
let uri = Services.io.newURI(url);
pattern = Array.concat(pattern);
normalized = Array.concat(normalized);
pattern = Array.prototype.concat.call(pattern);
normalized = Array.prototype.concat.call(normalized);
let patterns = pattern.map(pat => new MatchPattern(pat, options));
@ -172,9 +172,9 @@ add_task(async function test_MatchPattern_matches() {
add_task(async function test_MatchPattern_overlaps() {
function test(filter, hosts, optional) {
filter = Array.concat(filter);
hosts = Array.concat(hosts);
optional = Array.concat(optional);
filter = Array.prototype.concat.call(filter);
hosts = Array.prototype.concat.call(hosts);
optional = Array.prototype.concat.call(optional);
const set = new MatchPatternSet([...hosts, ...optional]);
const pat = new MatchPatternSet(filter);

Просмотреть файл

@ -138,7 +138,7 @@ var checkStyle = async function(browser, styleProperty, expected) {
var checkHighlight = async function(browser, expected) {
let highlighted = await ContentTask.spawn(browser, {}, async function() {
let spans = content.document.getElementsByTagName("span");
return Array.some(spans, (span) => {
return Array.prototype.some.call(spans, (span) => {
let style = content.getComputedStyle(span);
return style.getPropertyValue("color") !== "rgb(0, 0, 0)";
});

Просмотреть файл

@ -69,7 +69,7 @@ function popupShowingEventOccurred(event)
// considers the zeroth position to be before the first element, the value
// should be one higher than its index within its parent.
is(event.rangeParent, trigger.parentNode, testname + "rangeParent");
is(event.rangeOffset, Array.indexOf(trigger.parentNode.childNodes, trigger) + 1, testname + "rangeOffset");
is(event.rangeOffset, Array.prototype.indexOf.call(trigger.parentNode.childNodes, trigger) + 1, testname + "rangeOffset");
var popuprect = event.target.getBoundingClientRect();
is(Math.round(popuprect.left), Math.round(rect.left + 4), "popup left");

Просмотреть файл

@ -19,7 +19,7 @@ const {DownloadUtils} = ChromeUtils.import("resource://gre/modules/DownloadUtils
* @usage _(1, 2, 3) -> prints "1 2 3"
*/
var _ = function(some, debug, text, to) {
print(Array.slice(arguments).join(" "));
print(Array.from(arguments).join(" "));
};
_("Make an array of time lefts and expected string to be shown for that time");

Просмотреть файл

@ -25,7 +25,7 @@ function test_binary_streams() {
const LargeNum = Math.pow(2, 18) + Math.pow(2, 12) + 1;
const HugeNum = Math.pow(2, 62);
const HelloStr = "Hello World";
const HelloArray = Array.map(HelloStr, function(c) { return c.charCodeAt(0); });
const HelloArray = Array.from(HelloStr, function(c) { return c.charCodeAt(0); });
var countObj = {};
var msg = {};
var buffer = new ArrayBuffer(HelloArray.length);