browser/metro/base/tests/mochitest/browser_link_click.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:5b590605125e
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";
5
6 function test() {
7 waitForExplicitFinish();
8 runTests();
9 }
10
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;
16
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 });
22
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");
27
28 let tabOpen = waitForEvent(window, "TabOpen");
29 EventUtils.sendMouseEvent({type: "click", button: 1}, "link", tab.browser.contentWindow);
30 let event = yield tabOpen;
31
32 let newTab = Browser.getTabFromChrome(event.originalTarget);
33 yield waitForEvent(newTab.browser, "pageshow");
34
35 is(newTab.browser.currentURI.spec, "about:blank");
36 ok(newTab != Browser.selectedTab, "new tab is in the background");
37
38 Browser.closeTab(newTab, { forceClose: true });
39 }
40 });
41
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");
46
47 let tabOpen = waitForEvent(window, "TabOpen");
48 EventUtils.sendMouseEvent({type: "click", button: 1, shiftKey: true}, "link", tab.browser.contentWindow);
49 let event = yield tabOpen;
50
51 let newTab = Browser.getTabFromChrome(event.originalTarget);
52 yield waitForEvent(newTab.browser, "pageshow");
53
54 is(newTab.browser.currentURI.spec, "about:blank");
55 ok(newTab == Browser.selectedTab, "new tab is in the foreground");
56
57 Browser.closeTab(newTab, { forceClose: true });
58 }
59 });
60
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");
65
66 let tabOpen = waitForEvent(window, "TabOpen");
67 EventUtils.sendMouseEvent({type: "click", ctrlKey: true}, "link", tab.browser.contentWindow);
68 let event = yield tabOpen;
69
70 let newTab = Browser.getTabFromChrome(event.originalTarget);
71 yield waitForEvent(newTab.browser, "pageshow");
72
73 is(newTab.browser.currentURI.spec, "about:blank");
74 ok(newTab != Browser.selectedTab, "new tab is in the background");
75
76 Browser.closeTab(newTab, { forceClose: true });
77 }
78 });
79
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");
84
85 let tabOpen = waitForEvent(window, "TabOpen");
86 EventUtils.sendMouseEvent({type: "click", ctrlKey: true, shiftKey: true}, "link", tab.browser.contentWindow);
87 let event = yield tabOpen;
88
89 let newTab = Browser.getTabFromChrome(event.originalTarget);
90 yield waitForEvent(newTab.browser, "pageshow");
91
92 is(newTab.browser.currentURI.spec, "about:blank");
93 ok(newTab == Browser.selectedTab, "new tab is in the foreground");
94
95 Browser.closeTab(newTab, { forceClose: true });
96 }
97 });

mercurial