Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Tests if keyboard and mouse navigation works in the network requests menu. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { |
michael@0 | 10 | info("Starting test... "); |
michael@0 | 11 | |
michael@0 | 12 | // It seems that this test may be slow on Ubuntu builds running on ec2. |
michael@0 | 13 | requestLongerTimeout(2); |
michael@0 | 14 | |
michael@0 | 15 | let { window, $, NetMonitorView } = aMonitor.panelWin; |
michael@0 | 16 | let { RequestsMenu } = NetMonitorView; |
michael@0 | 17 | |
michael@0 | 18 | RequestsMenu.lazyUpdate = false; |
michael@0 | 19 | |
michael@0 | 20 | waitForNetworkEvents(aMonitor, 2).then(() => { |
michael@0 | 21 | check(-1, false); |
michael@0 | 22 | |
michael@0 | 23 | EventUtils.sendKey("DOWN", window); |
michael@0 | 24 | check(0, true); |
michael@0 | 25 | EventUtils.sendKey("UP", window); |
michael@0 | 26 | check(0, true); |
michael@0 | 27 | |
michael@0 | 28 | EventUtils.sendKey("PAGE_DOWN", window); |
michael@0 | 29 | check(1, true); |
michael@0 | 30 | EventUtils.sendKey("PAGE_UP", window); |
michael@0 | 31 | check(0, true); |
michael@0 | 32 | |
michael@0 | 33 | EventUtils.sendKey("END", window); |
michael@0 | 34 | check(1, true); |
michael@0 | 35 | EventUtils.sendKey("HOME", window); |
michael@0 | 36 | check(0, true); |
michael@0 | 37 | |
michael@0 | 38 | aDebuggee.performRequests(18); |
michael@0 | 39 | return waitForNetworkEvents(aMonitor, 18); |
michael@0 | 40 | }) |
michael@0 | 41 | .then(() => { |
michael@0 | 42 | EventUtils.sendKey("DOWN", window); |
michael@0 | 43 | check(1, true); |
michael@0 | 44 | EventUtils.sendKey("DOWN", window); |
michael@0 | 45 | check(2, true); |
michael@0 | 46 | EventUtils.sendKey("UP", window); |
michael@0 | 47 | check(1, true); |
michael@0 | 48 | EventUtils.sendKey("UP", window); |
michael@0 | 49 | check(0, true); |
michael@0 | 50 | |
michael@0 | 51 | EventUtils.sendKey("PAGE_DOWN", window); |
michael@0 | 52 | check(4, true); |
michael@0 | 53 | EventUtils.sendKey("PAGE_DOWN", window); |
michael@0 | 54 | check(8, true); |
michael@0 | 55 | EventUtils.sendKey("PAGE_UP", window); |
michael@0 | 56 | check(4, true); |
michael@0 | 57 | EventUtils.sendKey("PAGE_UP", window); |
michael@0 | 58 | check(0, true); |
michael@0 | 59 | |
michael@0 | 60 | EventUtils.sendKey("HOME", window); |
michael@0 | 61 | check(0, true); |
michael@0 | 62 | EventUtils.sendKey("HOME", window); |
michael@0 | 63 | check(0, true); |
michael@0 | 64 | EventUtils.sendKey("PAGE_UP", window); |
michael@0 | 65 | check(0, true); |
michael@0 | 66 | EventUtils.sendKey("HOME", window); |
michael@0 | 67 | check(0, true); |
michael@0 | 68 | |
michael@0 | 69 | EventUtils.sendKey("END", window); |
michael@0 | 70 | check(19, true); |
michael@0 | 71 | EventUtils.sendKey("END", window); |
michael@0 | 72 | check(19, true); |
michael@0 | 73 | EventUtils.sendKey("PAGE_DOWN", window); |
michael@0 | 74 | check(19, true); |
michael@0 | 75 | EventUtils.sendKey("END", window); |
michael@0 | 76 | check(19, true); |
michael@0 | 77 | |
michael@0 | 78 | EventUtils.sendKey("PAGE_UP", window); |
michael@0 | 79 | check(15, true); |
michael@0 | 80 | EventUtils.sendKey("PAGE_UP", window); |
michael@0 | 81 | check(11, true); |
michael@0 | 82 | EventUtils.sendKey("UP", window); |
michael@0 | 83 | check(10, true); |
michael@0 | 84 | EventUtils.sendKey("UP", window); |
michael@0 | 85 | check(9, true); |
michael@0 | 86 | EventUtils.sendKey("PAGE_DOWN", window); |
michael@0 | 87 | check(13, true); |
michael@0 | 88 | EventUtils.sendKey("PAGE_DOWN", window); |
michael@0 | 89 | check(17, true); |
michael@0 | 90 | EventUtils.sendKey("PAGE_DOWN", window); |
michael@0 | 91 | check(19, true); |
michael@0 | 92 | EventUtils.sendKey("PAGE_DOWN", window); |
michael@0 | 93 | check(19, true); |
michael@0 | 94 | |
michael@0 | 95 | EventUtils.sendKey("HOME", window); |
michael@0 | 96 | check(0, true); |
michael@0 | 97 | EventUtils.sendKey("DOWN", window); |
michael@0 | 98 | check(1, true); |
michael@0 | 99 | EventUtils.sendKey("END", window); |
michael@0 | 100 | check(19, true); |
michael@0 | 101 | EventUtils.sendKey("DOWN", window); |
michael@0 | 102 | check(19, true); |
michael@0 | 103 | |
michael@0 | 104 | EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); |
michael@0 | 105 | check(-1, false); |
michael@0 | 106 | |
michael@0 | 107 | EventUtils.sendMouseEvent({ type: "mousedown" }, $(".side-menu-widget-item")); |
michael@0 | 108 | check(0, true); |
michael@0 | 109 | |
michael@0 | 110 | teardown(aMonitor).then(finish); |
michael@0 | 111 | }); |
michael@0 | 112 | |
michael@0 | 113 | let count = 0; |
michael@0 | 114 | |
michael@0 | 115 | function check(aSelectedIndex, aPaneVisibility) { |
michael@0 | 116 | info("Performing check " + (count++) + "."); |
michael@0 | 117 | |
michael@0 | 118 | is(RequestsMenu.selectedIndex, aSelectedIndex, |
michael@0 | 119 | "The selected item in the requests menu was incorrect."); |
michael@0 | 120 | is(NetMonitorView.detailsPaneHidden, !aPaneVisibility, |
michael@0 | 121 | "The network requests details pane visibility state was incorrect."); |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | aDebuggee.performRequests(2); |
michael@0 | 125 | }); |
michael@0 | 126 | } |