Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | "use strict"; |
michael@0 | 5 | |
michael@0 | 6 | function test() { |
michael@0 | 7 | waitForExplicitFinish(); |
michael@0 | 8 | runTests(); |
michael@0 | 9 | } |
michael@0 | 10 | |
michael@0 | 11 | gTests.push({ |
michael@0 | 12 | desc: "regular link click", |
michael@0 | 13 | run: function () { |
michael@0 | 14 | let tab = yield addTab(chromeRoot + "browser_link_click.html"); |
michael@0 | 15 | let tabCount = Browser.tabs.length; |
michael@0 | 16 | |
michael@0 | 17 | EventUtils.sendMouseEvent({type: "click"}, "link", tab.browser.contentWindow); |
michael@0 | 18 | yield waitForCondition(() => tab.browser.currentURI.spec == "about:blank"); |
michael@0 | 19 | is(Browser.tabs.length, tabCount, "link loaded in the same tab"); |
michael@0 | 20 | } |
michael@0 | 21 | }); |
michael@0 | 22 | |
michael@0 | 23 | gTests.push({ |
michael@0 | 24 | desc: "middle-click opens link in background tab", |
michael@0 | 25 | run: function () { |
michael@0 | 26 | let tab = yield addTab(chromeRoot + "browser_link_click.html"); |
michael@0 | 27 | |
michael@0 | 28 | let tabOpen = waitForEvent(window, "TabOpen"); |
michael@0 | 29 | EventUtils.sendMouseEvent({type: "click", button: 1}, "link", tab.browser.contentWindow); |
michael@0 | 30 | let event = yield tabOpen; |
michael@0 | 31 | |
michael@0 | 32 | let newTab = Browser.getTabFromChrome(event.originalTarget); |
michael@0 | 33 | yield waitForEvent(newTab.browser, "pageshow"); |
michael@0 | 34 | |
michael@0 | 35 | is(newTab.browser.currentURI.spec, "about:blank"); |
michael@0 | 36 | ok(newTab != Browser.selectedTab, "new tab is in the background"); |
michael@0 | 37 | |
michael@0 | 38 | Browser.closeTab(newTab, { forceClose: true }); |
michael@0 | 39 | } |
michael@0 | 40 | }); |
michael@0 | 41 | |
michael@0 | 42 | gTests.push({ |
michael@0 | 43 | desc: "shift-middle-click opens link in background tab", |
michael@0 | 44 | run: function () { |
michael@0 | 45 | let tab = yield addTab(chromeRoot + "browser_link_click.html"); |
michael@0 | 46 | |
michael@0 | 47 | let tabOpen = waitForEvent(window, "TabOpen"); |
michael@0 | 48 | EventUtils.sendMouseEvent({type: "click", button: 1, shiftKey: true}, "link", tab.browser.contentWindow); |
michael@0 | 49 | let event = yield tabOpen; |
michael@0 | 50 | |
michael@0 | 51 | let newTab = Browser.getTabFromChrome(event.originalTarget); |
michael@0 | 52 | yield waitForEvent(newTab.browser, "pageshow"); |
michael@0 | 53 | |
michael@0 | 54 | is(newTab.browser.currentURI.spec, "about:blank"); |
michael@0 | 55 | ok(newTab == Browser.selectedTab, "new tab is in the foreground"); |
michael@0 | 56 | |
michael@0 | 57 | Browser.closeTab(newTab, { forceClose: true }); |
michael@0 | 58 | } |
michael@0 | 59 | }); |
michael@0 | 60 | |
michael@0 | 61 | gTests.push({ |
michael@0 | 62 | desc: "ctrl-click opens link in background tab", |
michael@0 | 63 | run: function () { |
michael@0 | 64 | let tab = yield addTab(chromeRoot + "browser_link_click.html"); |
michael@0 | 65 | |
michael@0 | 66 | let tabOpen = waitForEvent(window, "TabOpen"); |
michael@0 | 67 | EventUtils.sendMouseEvent({type: "click", ctrlKey: true}, "link", tab.browser.contentWindow); |
michael@0 | 68 | let event = yield tabOpen; |
michael@0 | 69 | |
michael@0 | 70 | let newTab = Browser.getTabFromChrome(event.originalTarget); |
michael@0 | 71 | yield waitForEvent(newTab.browser, "pageshow"); |
michael@0 | 72 | |
michael@0 | 73 | is(newTab.browser.currentURI.spec, "about:blank"); |
michael@0 | 74 | ok(newTab != Browser.selectedTab, "new tab is in the background"); |
michael@0 | 75 | |
michael@0 | 76 | Browser.closeTab(newTab, { forceClose: true }); |
michael@0 | 77 | } |
michael@0 | 78 | }); |
michael@0 | 79 | |
michael@0 | 80 | gTests.push({ |
michael@0 | 81 | desc: "shift-ctrl-click opens link in background tab", |
michael@0 | 82 | run: function () { |
michael@0 | 83 | let tab = yield addTab(chromeRoot + "browser_link_click.html"); |
michael@0 | 84 | |
michael@0 | 85 | let tabOpen = waitForEvent(window, "TabOpen"); |
michael@0 | 86 | EventUtils.sendMouseEvent({type: "click", ctrlKey: true, shiftKey: true}, "link", tab.browser.contentWindow); |
michael@0 | 87 | let event = yield tabOpen; |
michael@0 | 88 | |
michael@0 | 89 | let newTab = Browser.getTabFromChrome(event.originalTarget); |
michael@0 | 90 | yield waitForEvent(newTab.browser, "pageshow"); |
michael@0 | 91 | |
michael@0 | 92 | is(newTab.browser.currentURI.spec, "about:blank"); |
michael@0 | 93 | ok(newTab == Browser.selectedTab, "new tab is in the foreground"); |
michael@0 | 94 | |
michael@0 | 95 | Browser.closeTab(newTab, { forceClose: true }); |
michael@0 | 96 | } |
michael@0 | 97 | }); |