browser_net_accessibility-02.js (3546B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Tests if keyboard and mouse navigation works in the network requests menu. 8 */ 9 10 add_task(async function () { 11 const { tab, monitor } = await initNetMonitor(CUSTOM_GET_URL, { 12 requestCount: 1, 13 }); 14 info("Starting test... "); 15 16 // It seems that this test may be slow on Ubuntu builds running on ec2. 17 requestLongerTimeout(2); 18 19 const { window, document, windowRequire, store } = monitor.panelWin; 20 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 21 22 store.dispatch(Actions.batchEnable(false)); 23 24 let count = 0; 25 function check(selectedIndex, panelVisibility) { 26 info("Performing check " + count++ + "."); 27 28 const requestItems = Array.from( 29 document.querySelectorAll(".request-list-item") 30 ); 31 is( 32 requestItems.findIndex(item => item.matches(".selected")), 33 selectedIndex, 34 "The selected item in the requests menu was incorrect." 35 ); 36 is( 37 !!document.querySelector(".network-details-bar"), 38 panelVisibility, 39 "The network details panel should render correctly." 40 ); 41 } 42 43 // Execute requests. 44 await performRequests(monitor, tab, 2); 45 46 document.querySelector(".requests-list-row-group").focus(); 47 48 check(-1, false); 49 50 EventUtils.sendKey("DOWN", window); 51 check(0, true); 52 EventUtils.sendKey("UP", window); 53 check(0, true); 54 55 EventUtils.sendKey("PAGE_DOWN", window); 56 check(1, true); 57 EventUtils.sendKey("PAGE_UP", window); 58 check(0, true); 59 60 EventUtils.sendKey("END", window); 61 check(1, true); 62 EventUtils.sendKey("HOME", window); 63 check(0, true); 64 65 // Execute requests. 66 await performRequests(monitor, tab, 18); 67 68 EventUtils.sendKey("DOWN", window); 69 check(1, true); 70 EventUtils.sendKey("DOWN", window); 71 check(2, true); 72 EventUtils.sendKey("UP", window); 73 check(1, true); 74 EventUtils.sendKey("UP", window); 75 check(0, true); 76 77 EventUtils.sendKey("PAGE_DOWN", window); 78 check(4, true); 79 EventUtils.sendKey("PAGE_DOWN", window); 80 check(8, true); 81 EventUtils.sendKey("PAGE_UP", window); 82 check(4, true); 83 EventUtils.sendKey("PAGE_UP", window); 84 check(0, true); 85 86 EventUtils.sendKey("HOME", window); 87 check(0, true); 88 EventUtils.sendKey("HOME", window); 89 check(0, true); 90 EventUtils.sendKey("PAGE_UP", window); 91 check(0, true); 92 EventUtils.sendKey("HOME", window); 93 check(0, true); 94 95 EventUtils.sendKey("END", window); 96 check(19, true); 97 EventUtils.sendKey("END", window); 98 check(19, true); 99 EventUtils.sendKey("PAGE_DOWN", window); 100 check(19, true); 101 EventUtils.sendKey("END", window); 102 check(19, true); 103 104 EventUtils.sendKey("PAGE_UP", window); 105 check(15, true); 106 EventUtils.sendKey("PAGE_UP", window); 107 check(11, true); 108 EventUtils.sendKey("UP", window); 109 check(10, true); 110 EventUtils.sendKey("UP", window); 111 check(9, true); 112 EventUtils.sendKey("PAGE_DOWN", window); 113 check(13, true); 114 EventUtils.sendKey("PAGE_DOWN", window); 115 check(17, true); 116 EventUtils.sendKey("PAGE_DOWN", window); 117 check(19, true); 118 EventUtils.sendKey("PAGE_DOWN", window); 119 check(19, true); 120 121 EventUtils.sendKey("HOME", window); 122 check(0, true); 123 EventUtils.sendKey("DOWN", window); 124 check(1, true); 125 EventUtils.sendKey("END", window); 126 check(19, true); 127 EventUtils.sendKey("DOWN", window); 128 check(19, true); 129 130 EventUtils.sendMouseEvent( 131 { type: "mousedown" }, 132 document.querySelector(".request-list-item") 133 ); 134 check(0, true); 135 136 await teardown(monitor); 137 });