Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 "use strict";
6 function test() {
7 waitForExplicitFinish();
8 runTests();
9 }
11 gTests.push({
12 desc: "regular link click",
13 run: function () {
14 let tab = yield addTab(chromeRoot + "browser_link_click.html");
15 let tabCount = Browser.tabs.length;
17 EventUtils.sendMouseEvent({type: "click"}, "link", tab.browser.contentWindow);
18 yield waitForCondition(() => tab.browser.currentURI.spec == "about:blank");
19 is(Browser.tabs.length, tabCount, "link loaded in the same tab");
20 }
21 });
23 gTests.push({
24 desc: "middle-click opens link in background tab",
25 run: function () {
26 let tab = yield addTab(chromeRoot + "browser_link_click.html");
28 let tabOpen = waitForEvent(window, "TabOpen");
29 EventUtils.sendMouseEvent({type: "click", button: 1}, "link", tab.browser.contentWindow);
30 let event = yield tabOpen;
32 let newTab = Browser.getTabFromChrome(event.originalTarget);
33 yield waitForEvent(newTab.browser, "pageshow");
35 is(newTab.browser.currentURI.spec, "about:blank");
36 ok(newTab != Browser.selectedTab, "new tab is in the background");
38 Browser.closeTab(newTab, { forceClose: true });
39 }
40 });
42 gTests.push({
43 desc: "shift-middle-click opens link in background tab",
44 run: function () {
45 let tab = yield addTab(chromeRoot + "browser_link_click.html");
47 let tabOpen = waitForEvent(window, "TabOpen");
48 EventUtils.sendMouseEvent({type: "click", button: 1, shiftKey: true}, "link", tab.browser.contentWindow);
49 let event = yield tabOpen;
51 let newTab = Browser.getTabFromChrome(event.originalTarget);
52 yield waitForEvent(newTab.browser, "pageshow");
54 is(newTab.browser.currentURI.spec, "about:blank");
55 ok(newTab == Browser.selectedTab, "new tab is in the foreground");
57 Browser.closeTab(newTab, { forceClose: true });
58 }
59 });
61 gTests.push({
62 desc: "ctrl-click opens link in background tab",
63 run: function () {
64 let tab = yield addTab(chromeRoot + "browser_link_click.html");
66 let tabOpen = waitForEvent(window, "TabOpen");
67 EventUtils.sendMouseEvent({type: "click", ctrlKey: true}, "link", tab.browser.contentWindow);
68 let event = yield tabOpen;
70 let newTab = Browser.getTabFromChrome(event.originalTarget);
71 yield waitForEvent(newTab.browser, "pageshow");
73 is(newTab.browser.currentURI.spec, "about:blank");
74 ok(newTab != Browser.selectedTab, "new tab is in the background");
76 Browser.closeTab(newTab, { forceClose: true });
77 }
78 });
80 gTests.push({
81 desc: "shift-ctrl-click opens link in background tab",
82 run: function () {
83 let tab = yield addTab(chromeRoot + "browser_link_click.html");
85 let tabOpen = waitForEvent(window, "TabOpen");
86 EventUtils.sendMouseEvent({type: "click", ctrlKey: true, shiftKey: true}, "link", tab.browser.contentWindow);
87 let event = yield tabOpen;
89 let newTab = Browser.getTabFromChrome(event.originalTarget);
90 yield waitForEvent(newTab.browser, "pageshow");
92 is(newTab.browser.currentURI.spec, "about:blank");
93 ok(newTab == Browser.selectedTab, "new tab is in the foreground");
95 Browser.closeTab(newTab, { forceClose: true });
96 }
97 });