mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-13 06:38:48 +02:00
- `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
52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
/*
|
|
* "TabClose" event is possibly used for closing related tabs of the current.
|
|
* "removeTab" method should work correctly even if the number of tabs are
|
|
* changed while "TabClose" event.
|
|
*/
|
|
|
|
var count = 0;
|
|
const URIS = ["about:config",
|
|
"about:plugins",
|
|
"about:buildconfig",
|
|
"data:text/html,<title>OK</title>"];
|
|
|
|
function test() {
|
|
waitForExplicitFinish();
|
|
URIS.forEach(addTab);
|
|
}
|
|
|
|
function addTab(aURI, aIndex) {
|
|
var tab = BrowserTestUtils.addTab(gBrowser, aURI);
|
|
if (aIndex == 0)
|
|
gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true});
|
|
|
|
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
|
|
if (++count == URIS.length)
|
|
executeSoon(doTabsTest);
|
|
});
|
|
}
|
|
|
|
function doTabsTest() {
|
|
is(gBrowser.tabs.length, URIS.length, "Correctly opened all expected tabs");
|
|
|
|
// sample of "close related tabs" feature
|
|
gBrowser.tabContainer.addEventListener("TabClose", function(event) {
|
|
var closedTab = event.originalTarget;
|
|
var scheme = closedTab.linkedBrowser.currentURI.scheme;
|
|
Array.from(gBrowser.tabs).forEach(function(aTab) {
|
|
if (aTab != closedTab && aTab.linkedBrowser.currentURI.scheme == scheme)
|
|
gBrowser.removeTab(aTab, {skipPermitUnload: true});
|
|
});
|
|
}, {capture: true, once: true});
|
|
|
|
gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true});
|
|
is(gBrowser.tabs.length, 1, "Related tabs are not closed unexpectedly");
|
|
|
|
BrowserTestUtils.addTab(gBrowser, "about:blank");
|
|
gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true});
|
|
finish();
|
|
}
|