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.

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

mercurial