browser/base/content/test/general/browser_bug555767.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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
michael@0 5 function test() {
michael@0 6 waitForExplicitFinish();
michael@0 7
michael@0 8 let testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";
michael@0 9 let tabSelected = false;
michael@0 10
michael@0 11 // Open the base tab
michael@0 12 let baseTab = gBrowser.addTab(testURL);
michael@0 13 baseTab.linkedBrowser.addEventListener("load", function() {
michael@0 14 // Wait for the tab to be fully loaded so matching happens correctly
michael@0 15 if (baseTab.linkedBrowser.currentURI.spec == "about:blank")
michael@0 16 return;
michael@0 17 baseTab.linkedBrowser.removeEventListener("load", arguments.callee, true);
michael@0 18
michael@0 19 let testTab = gBrowser.addTab();
michael@0 20
michael@0 21 // Select the testTab
michael@0 22 gBrowser.selectedTab = testTab;
michael@0 23
michael@0 24 // Ensure that this tab has no history entries
michael@0 25 ok(testTab.linkedBrowser.sessionHistory.count < 2,
michael@0 26 "The test tab has 1 or less history entries");
michael@0 27 // Ensure that this tab is on about:blank
michael@0 28 is(testTab.linkedBrowser.currentURI.spec, "about:blank",
michael@0 29 "The test tab is on about:blank");
michael@0 30 // Ensure that this tab's document has no child nodes
michael@0 31 ok(!testTab.linkedBrowser.contentDocument.body.hasChildNodes(),
michael@0 32 "The test tab has no child nodes");
michael@0 33 ok(!testTab.hasAttribute("busy"),
michael@0 34 "The test tab doesn't have the busy attribute");
michael@0 35
michael@0 36 // Set the urlbar to include the moz-action
michael@0 37 gURLBar.value = "moz-action:switchtab," + testURL;
michael@0 38 // Focus the urlbar so we can press enter
michael@0 39 gURLBar.focus();
michael@0 40
michael@0 41 // Functions for TabClose and TabSelect
michael@0 42 function onTabClose(aEvent) {
michael@0 43 gBrowser.tabContainer.removeEventListener("TabClose", onTabClose, false);
michael@0 44 // Make sure we get the TabClose event for testTab
michael@0 45 is(aEvent.originalTarget, testTab, "Got the TabClose event for the right tab");
michael@0 46 // Confirm that we did select the tab
michael@0 47 ok(tabSelected, "Confirming that the tab was selected");
michael@0 48 gBrowser.removeTab(baseTab);
michael@0 49 finish();
michael@0 50 }
michael@0 51 function onTabSelect(aEvent) {
michael@0 52 gBrowser.tabContainer.removeEventListener("TabSelect", onTabSelect, false);
michael@0 53 // Make sure we got the TabSelect event for baseTab
michael@0 54 is(aEvent.originalTarget, baseTab, "Got the TabSelect event for the right tab");
michael@0 55 // Confirm that the selected tab is in fact base tab
michael@0 56 is(gBrowser.selectedTab, baseTab, "We've switched to the correct tab");
michael@0 57 tabSelected = true;
michael@0 58 }
michael@0 59
michael@0 60 // Add the TabClose, TabSelect event listeners before we press enter
michael@0 61 gBrowser.tabContainer.addEventListener("TabClose", onTabClose, false);
michael@0 62 gBrowser.tabContainer.addEventListener("TabSelect", onTabSelect, false);
michael@0 63
michael@0 64 // Press enter!
michael@0 65 EventUtils.synthesizeKey("VK_RETURN", {});
michael@0 66 }, true);
michael@0 67 }
michael@0 68

mercurial