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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/base/content/test/general/browser_bug462289.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,78 @@
     1.4 +var tab1, tab2;
     1.5 +
     1.6 +function focus_in_navbar()
     1.7 +{
     1.8 +  var parent = document.activeElement.parentNode;
     1.9 +  while (parent && parent.id != "nav-bar")
    1.10 +    parent = parent.parentNode;
    1.11 +
    1.12 +  return parent != null;
    1.13 +}
    1.14 +
    1.15 +function test()
    1.16 +{
    1.17 +  waitForExplicitFinish();
    1.18 +
    1.19 +  tab1 = gBrowser.addTab("about:blank", {skipAnimation: true});
    1.20 +  tab2 = gBrowser.addTab("about:blank", {skipAnimation: true});
    1.21 +
    1.22 +  EventUtils.synthesizeMouseAtCenter(tab1, {});
    1.23 +  setTimeout(step2, 0);
    1.24 +}
    1.25 +
    1.26 +function step2()
    1.27 +{
    1.28 +  is(gBrowser.selectedTab, tab1, "1st click on tab1 selects tab");
    1.29 +  isnot(document.activeElement, tab1, "1st click on tab1 does not activate tab");
    1.30 +
    1.31 +  EventUtils.synthesizeMouseAtCenter(tab1, {});
    1.32 +  setTimeout(step3, 0);
    1.33 +}
    1.34 +
    1.35 +function step3()
    1.36 +{
    1.37 +  is(gBrowser.selectedTab, tab1, "2nd click on selected tab1 keeps tab selected");
    1.38 +  isnot(document.activeElement, tab1, "2nd click on selected tab1 does not activate tab");
    1.39 +
    1.40 +  ok(true, "focusing URLBar then sending 1 Shift+Tab.");
    1.41 +  gURLBar.focus();
    1.42 +  EventUtils.synthesizeKey("VK_TAB", {shiftKey: true});
    1.43 +  is(gBrowser.selectedTab, tab1, "tab key to selected tab1 keeps tab selected");
    1.44 +  is(document.activeElement, tab1, "tab key to selected tab1 activates tab");
    1.45 +
    1.46 +  EventUtils.synthesizeMouseAtCenter(tab1, {});
    1.47 +  setTimeout(step4, 0);
    1.48 +}
    1.49 +
    1.50 +function step4()
    1.51 +{
    1.52 +  is(gBrowser.selectedTab, tab1, "3rd click on activated tab1 keeps tab selected");
    1.53 +  is(document.activeElement, tab1, "3rd click on activated tab1 keeps tab activated");
    1.54 +
    1.55 +  EventUtils.synthesizeMouseAtCenter(tab2, {});
    1.56 +  setTimeout(step5, 0);
    1.57 +}
    1.58 +
    1.59 +function step5()
    1.60 +{
    1.61 +  // The tabbox selects a tab within a setTimeout in a bubbling mousedown event
    1.62 +  // listener, and focuses the current tab if another tab previously had focus.
    1.63 +  is(gBrowser.selectedTab, tab2, "click on tab2 while tab1 is activated selects tab");
    1.64 +  is(document.activeElement, tab2, "click on tab2 while tab1 is activated activates tab");
    1.65 +
    1.66 +  ok(true, "focusing content then sending middle-button mousedown to tab2.");
    1.67 +  gBrowser.selectedBrowser.focus();
    1.68 +  EventUtils.synthesizeMouseAtCenter(tab2, {button: 1, type: "mousedown"});
    1.69 +  setTimeout(step6, 0);
    1.70 +}
    1.71 +
    1.72 +function step6()
    1.73 +{
    1.74 +  is(gBrowser.selectedTab, tab2, "middle-button mousedown on selected tab2 keeps tab selected");
    1.75 +  isnot(document.activeElement, tab2, "middle-button mousedown on selected tab2 does not activate tab");
    1.76 +
    1.77 +  gBrowser.removeTab(tab2);
    1.78 +  gBrowser.removeTab(tab1);
    1.79 +
    1.80 +  finish();
    1.81 +}

mercurial