michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: "use strict"; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: runTests(); michael@0: } michael@0: michael@0: gTests.push({ michael@0: desc: "regular link click", michael@0: run: function () { michael@0: let tab = yield addTab(chromeRoot + "browser_link_click.html"); michael@0: let tabCount = Browser.tabs.length; michael@0: michael@0: EventUtils.sendMouseEvent({type: "click"}, "link", tab.browser.contentWindow); michael@0: yield waitForCondition(() => tab.browser.currentURI.spec == "about:blank"); michael@0: is(Browser.tabs.length, tabCount, "link loaded in the same tab"); michael@0: } michael@0: }); michael@0: michael@0: gTests.push({ michael@0: desc: "middle-click opens link in background tab", michael@0: run: function () { michael@0: let tab = yield addTab(chromeRoot + "browser_link_click.html"); michael@0: michael@0: let tabOpen = waitForEvent(window, "TabOpen"); michael@0: EventUtils.sendMouseEvent({type: "click", button: 1}, "link", tab.browser.contentWindow); michael@0: let event = yield tabOpen; michael@0: michael@0: let newTab = Browser.getTabFromChrome(event.originalTarget); michael@0: yield waitForEvent(newTab.browser, "pageshow"); michael@0: michael@0: is(newTab.browser.currentURI.spec, "about:blank"); michael@0: ok(newTab != Browser.selectedTab, "new tab is in the background"); michael@0: michael@0: Browser.closeTab(newTab, { forceClose: true }); michael@0: } michael@0: }); michael@0: michael@0: gTests.push({ michael@0: desc: "shift-middle-click opens link in background tab", michael@0: run: function () { michael@0: let tab = yield addTab(chromeRoot + "browser_link_click.html"); michael@0: michael@0: let tabOpen = waitForEvent(window, "TabOpen"); michael@0: EventUtils.sendMouseEvent({type: "click", button: 1, shiftKey: true}, "link", tab.browser.contentWindow); michael@0: let event = yield tabOpen; michael@0: michael@0: let newTab = Browser.getTabFromChrome(event.originalTarget); michael@0: yield waitForEvent(newTab.browser, "pageshow"); michael@0: michael@0: is(newTab.browser.currentURI.spec, "about:blank"); michael@0: ok(newTab == Browser.selectedTab, "new tab is in the foreground"); michael@0: michael@0: Browser.closeTab(newTab, { forceClose: true }); michael@0: } michael@0: }); michael@0: michael@0: gTests.push({ michael@0: desc: "ctrl-click opens link in background tab", michael@0: run: function () { michael@0: let tab = yield addTab(chromeRoot + "browser_link_click.html"); michael@0: michael@0: let tabOpen = waitForEvent(window, "TabOpen"); michael@0: EventUtils.sendMouseEvent({type: "click", ctrlKey: true}, "link", tab.browser.contentWindow); michael@0: let event = yield tabOpen; michael@0: michael@0: let newTab = Browser.getTabFromChrome(event.originalTarget); michael@0: yield waitForEvent(newTab.browser, "pageshow"); michael@0: michael@0: is(newTab.browser.currentURI.spec, "about:blank"); michael@0: ok(newTab != Browser.selectedTab, "new tab is in the background"); michael@0: michael@0: Browser.closeTab(newTab, { forceClose: true }); michael@0: } michael@0: }); michael@0: michael@0: gTests.push({ michael@0: desc: "shift-ctrl-click opens link in background tab", michael@0: run: function () { michael@0: let tab = yield addTab(chromeRoot + "browser_link_click.html"); michael@0: michael@0: let tabOpen = waitForEvent(window, "TabOpen"); michael@0: EventUtils.sendMouseEvent({type: "click", ctrlKey: true, shiftKey: true}, "link", tab.browser.contentWindow); michael@0: let event = yield tabOpen; michael@0: michael@0: let newTab = Browser.getTabFromChrome(event.originalTarget); michael@0: yield waitForEvent(newTab.browser, "pageshow"); michael@0: michael@0: is(newTab.browser.currentURI.spec, "about:blank"); michael@0: ok(newTab == Browser.selectedTab, "new tab is in the foreground"); michael@0: michael@0: Browser.closeTab(newTab, { forceClose: true }); michael@0: } michael@0: });