browser/base/content/test/general/browser_bug462289.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 var tab1, tab2;
     3 function focus_in_navbar()
     4 {
     5   var parent = document.activeElement.parentNode;
     6   while (parent && parent.id != "nav-bar")
     7     parent = parent.parentNode;
     9   return parent != null;
    10 }
    12 function test()
    13 {
    14   waitForExplicitFinish();
    16   tab1 = gBrowser.addTab("about:blank", {skipAnimation: true});
    17   tab2 = gBrowser.addTab("about:blank", {skipAnimation: true});
    19   EventUtils.synthesizeMouseAtCenter(tab1, {});
    20   setTimeout(step2, 0);
    21 }
    23 function step2()
    24 {
    25   is(gBrowser.selectedTab, tab1, "1st click on tab1 selects tab");
    26   isnot(document.activeElement, tab1, "1st click on tab1 does not activate tab");
    28   EventUtils.synthesizeMouseAtCenter(tab1, {});
    29   setTimeout(step3, 0);
    30 }
    32 function step3()
    33 {
    34   is(gBrowser.selectedTab, tab1, "2nd click on selected tab1 keeps tab selected");
    35   isnot(document.activeElement, tab1, "2nd click on selected tab1 does not activate tab");
    37   ok(true, "focusing URLBar then sending 1 Shift+Tab.");
    38   gURLBar.focus();
    39   EventUtils.synthesizeKey("VK_TAB", {shiftKey: true});
    40   is(gBrowser.selectedTab, tab1, "tab key to selected tab1 keeps tab selected");
    41   is(document.activeElement, tab1, "tab key to selected tab1 activates tab");
    43   EventUtils.synthesizeMouseAtCenter(tab1, {});
    44   setTimeout(step4, 0);
    45 }
    47 function step4()
    48 {
    49   is(gBrowser.selectedTab, tab1, "3rd click on activated tab1 keeps tab selected");
    50   is(document.activeElement, tab1, "3rd click on activated tab1 keeps tab activated");
    52   EventUtils.synthesizeMouseAtCenter(tab2, {});
    53   setTimeout(step5, 0);
    54 }
    56 function step5()
    57 {
    58   // The tabbox selects a tab within a setTimeout in a bubbling mousedown event
    59   // listener, and focuses the current tab if another tab previously had focus.
    60   is(gBrowser.selectedTab, tab2, "click on tab2 while tab1 is activated selects tab");
    61   is(document.activeElement, tab2, "click on tab2 while tab1 is activated activates tab");
    63   ok(true, "focusing content then sending middle-button mousedown to tab2.");
    64   gBrowser.selectedBrowser.focus();
    65   EventUtils.synthesizeMouseAtCenter(tab2, {button: 1, type: "mousedown"});
    66   setTimeout(step6, 0);
    67 }
    69 function step6()
    70 {
    71   is(gBrowser.selectedTab, tab2, "middle-button mousedown on selected tab2 keeps tab selected");
    72   isnot(document.activeElement, tab2, "middle-button mousedown on selected tab2 does not activate tab");
    74   gBrowser.removeTab(tab2);
    75   gBrowser.removeTab(tab1);
    77   finish();
    78 }

mercurial