gecko-dev/browser/base/content/test/tabs/browser_pinnedTabs_clickOpen.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.8 KiB
JavaScript
Raw Normal View History

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function index(tab) {
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
2019-04-17 19:03:19 +00:00
return Array.prototype.indexOf.call(gBrowser.tabs, tab);
}
async function testNewTabPosition(expectedPosition, modifiers = {}) {
let opening = BrowserTestUtils.waitForNewTab(
gBrowser,
"http://mochi.test:8888/"
);
BrowserTestUtils.synthesizeMouseAtCenter(
"#link",
modifiers,
gBrowser.selectedBrowser
);
let newtab = await opening;
is(index(newtab), expectedPosition, "clicked tab is in correct position");
return newtab;
}
// Test that a tab opened from a pinned tab is not in the pinned region.
add_task(async function test_pinned_content_click() {
let testUri =
'data:text/html;charset=utf-8,<a href="http://mochi.test:8888/" target="_blank" id="link">link</a>';
let tabs = [
gBrowser.selectedTab,
await BrowserTestUtils.openNewForegroundTab(gBrowser, testUri),
BrowserTestUtils.addTab(gBrowser),
];
gBrowser.pinTab(tabs[1]);
gBrowser.pinTab(tabs[2]);
// First test new active tabs open at the start of non-pinned tabstrip.
let newtab1 = await testNewTabPosition(2);
// Switch back to our test tab.
await BrowserTestUtils.switchTab(gBrowser, tabs[1]);
let newtab2 = await testNewTabPosition(2);
gBrowser.removeTab(newtab1);
gBrowser.removeTab(newtab2);
// Second test new background tabs open in order.
let modifiers =
AppConstants.platform == "macosx" ? { metaKey: true } : { ctrlKey: true };
await BrowserTestUtils.switchTab(gBrowser, tabs[1]);
newtab1 = await testNewTabPosition(2, modifiers);
newtab2 = await testNewTabPosition(3, modifiers);
gBrowser.removeTab(tabs[1]);
gBrowser.removeTab(tabs[2]);
gBrowser.removeTab(newtab1);
gBrowser.removeTab(newtab2);
});