1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/netmonitor/test/browser_net_accessibility-02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,126 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if keyboard and mouse navigation works in the network requests menu. 1.9 + */ 1.10 + 1.11 +function test() { 1.12 + initNetMonitor(CUSTOM_GET_URL).then(([aTab, aDebuggee, aMonitor]) => { 1.13 + info("Starting test... "); 1.14 + 1.15 + // It seems that this test may be slow on Ubuntu builds running on ec2. 1.16 + requestLongerTimeout(2); 1.17 + 1.18 + let { window, $, NetMonitorView } = aMonitor.panelWin; 1.19 + let { RequestsMenu } = NetMonitorView; 1.20 + 1.21 + RequestsMenu.lazyUpdate = false; 1.22 + 1.23 + waitForNetworkEvents(aMonitor, 2).then(() => { 1.24 + check(-1, false); 1.25 + 1.26 + EventUtils.sendKey("DOWN", window); 1.27 + check(0, true); 1.28 + EventUtils.sendKey("UP", window); 1.29 + check(0, true); 1.30 + 1.31 + EventUtils.sendKey("PAGE_DOWN", window); 1.32 + check(1, true); 1.33 + EventUtils.sendKey("PAGE_UP", window); 1.34 + check(0, true); 1.35 + 1.36 + EventUtils.sendKey("END", window); 1.37 + check(1, true); 1.38 + EventUtils.sendKey("HOME", window); 1.39 + check(0, true); 1.40 + 1.41 + aDebuggee.performRequests(18); 1.42 + return waitForNetworkEvents(aMonitor, 18); 1.43 + }) 1.44 + .then(() => { 1.45 + EventUtils.sendKey("DOWN", window); 1.46 + check(1, true); 1.47 + EventUtils.sendKey("DOWN", window); 1.48 + check(2, true); 1.49 + EventUtils.sendKey("UP", window); 1.50 + check(1, true); 1.51 + EventUtils.sendKey("UP", window); 1.52 + check(0, true); 1.53 + 1.54 + EventUtils.sendKey("PAGE_DOWN", window); 1.55 + check(4, true); 1.56 + EventUtils.sendKey("PAGE_DOWN", window); 1.57 + check(8, true); 1.58 + EventUtils.sendKey("PAGE_UP", window); 1.59 + check(4, true); 1.60 + EventUtils.sendKey("PAGE_UP", window); 1.61 + check(0, true); 1.62 + 1.63 + EventUtils.sendKey("HOME", window); 1.64 + check(0, true); 1.65 + EventUtils.sendKey("HOME", window); 1.66 + check(0, true); 1.67 + EventUtils.sendKey("PAGE_UP", window); 1.68 + check(0, true); 1.69 + EventUtils.sendKey("HOME", window); 1.70 + check(0, true); 1.71 + 1.72 + EventUtils.sendKey("END", window); 1.73 + check(19, true); 1.74 + EventUtils.sendKey("END", window); 1.75 + check(19, true); 1.76 + EventUtils.sendKey("PAGE_DOWN", window); 1.77 + check(19, true); 1.78 + EventUtils.sendKey("END", window); 1.79 + check(19, true); 1.80 + 1.81 + EventUtils.sendKey("PAGE_UP", window); 1.82 + check(15, true); 1.83 + EventUtils.sendKey("PAGE_UP", window); 1.84 + check(11, true); 1.85 + EventUtils.sendKey("UP", window); 1.86 + check(10, true); 1.87 + EventUtils.sendKey("UP", window); 1.88 + check(9, true); 1.89 + EventUtils.sendKey("PAGE_DOWN", window); 1.90 + check(13, true); 1.91 + EventUtils.sendKey("PAGE_DOWN", window); 1.92 + check(17, true); 1.93 + EventUtils.sendKey("PAGE_DOWN", window); 1.94 + check(19, true); 1.95 + EventUtils.sendKey("PAGE_DOWN", window); 1.96 + check(19, true); 1.97 + 1.98 + EventUtils.sendKey("HOME", window); 1.99 + check(0, true); 1.100 + EventUtils.sendKey("DOWN", window); 1.101 + check(1, true); 1.102 + EventUtils.sendKey("END", window); 1.103 + check(19, true); 1.104 + EventUtils.sendKey("DOWN", window); 1.105 + check(19, true); 1.106 + 1.107 + EventUtils.sendMouseEvent({ type: "mousedown" }, $("#details-pane-toggle")); 1.108 + check(-1, false); 1.109 + 1.110 + EventUtils.sendMouseEvent({ type: "mousedown" }, $(".side-menu-widget-item")); 1.111 + check(0, true); 1.112 + 1.113 + teardown(aMonitor).then(finish); 1.114 + }); 1.115 + 1.116 + let count = 0; 1.117 + 1.118 + function check(aSelectedIndex, aPaneVisibility) { 1.119 + info("Performing check " + (count++) + "."); 1.120 + 1.121 + is(RequestsMenu.selectedIndex, aSelectedIndex, 1.122 + "The selected item in the requests menu was incorrect."); 1.123 + is(NetMonitorView.detailsPaneHidden, !aPaneVisibility, 1.124 + "The network requests details pane visibility state was incorrect."); 1.125 + } 1.126 + 1.127 + aDebuggee.performRequests(2); 1.128 + }); 1.129 +}