1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_bug555767.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function test() { 1.9 + waitForExplicitFinish(); 1.10 + 1.11 + let testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html"; 1.12 + let tabSelected = false; 1.13 + 1.14 + // Open the base tab 1.15 + let baseTab = gBrowser.addTab(testURL); 1.16 + baseTab.linkedBrowser.addEventListener("load", function() { 1.17 + // Wait for the tab to be fully loaded so matching happens correctly 1.18 + if (baseTab.linkedBrowser.currentURI.spec == "about:blank") 1.19 + return; 1.20 + baseTab.linkedBrowser.removeEventListener("load", arguments.callee, true); 1.21 + 1.22 + let testTab = gBrowser.addTab(); 1.23 + 1.24 + // Select the testTab 1.25 + gBrowser.selectedTab = testTab; 1.26 + 1.27 + // Ensure that this tab has no history entries 1.28 + ok(testTab.linkedBrowser.sessionHistory.count < 2, 1.29 + "The test tab has 1 or less history entries"); 1.30 + // Ensure that this tab is on about:blank 1.31 + is(testTab.linkedBrowser.currentURI.spec, "about:blank", 1.32 + "The test tab is on about:blank"); 1.33 + // Ensure that this tab's document has no child nodes 1.34 + ok(!testTab.linkedBrowser.contentDocument.body.hasChildNodes(), 1.35 + "The test tab has no child nodes"); 1.36 + ok(!testTab.hasAttribute("busy"), 1.37 + "The test tab doesn't have the busy attribute"); 1.38 + 1.39 + // Set the urlbar to include the moz-action 1.40 + gURLBar.value = "moz-action:switchtab," + testURL; 1.41 + // Focus the urlbar so we can press enter 1.42 + gURLBar.focus(); 1.43 + 1.44 + // Functions for TabClose and TabSelect 1.45 + function onTabClose(aEvent) { 1.46 + gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, false); 1.47 + // Make sure we get the TabClose event for testTab 1.48 + is(aEvent.originalTarget, testTab, "Got the TabClose event for the right tab"); 1.49 + // Confirm that we did select the tab 1.50 + ok(tabSelected, "Confirming that the tab was selected"); 1.51 + gBrowser.removeTab(baseTab); 1.52 + finish(); 1.53 + } 1.54 + function onTabSelect(aEvent) { 1.55 + gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect, false); 1.56 + // Make sure we got the TabSelect event for baseTab 1.57 + is(aEvent.originalTarget, baseTab, "Got the TabSelect event for the right tab"); 1.58 + // Confirm that the selected tab is in fact base tab 1.59 + is(gBrowser.selectedTab, baseTab, "We've switched to the correct tab"); 1.60 + tabSelected = true; 1.61 + } 1.62 + 1.63 + // Add the TabClose, TabSelect event listeners before we press enter 1.64 + gBrowser.tabContainer.addEventListener("TabClose", onTabClose, false); 1.65 + gBrowser.tabContainer.addEventListener("TabSelect", onTabSelect, false); 1.66 + 1.67 + // Press enter! 1.68 + EventUtils.synthesizeKey("VK_RETURN", {}); 1.69 + }, true); 1.70 +} 1.71 +