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.

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

mercurial