browser_aboutprofiling-interval.js (2102B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 "use strict"; 5 6 add_task(async function test() { 7 info("Test that about:profiling can modify the sampling interval."); 8 9 await withAboutProfiling(async document => { 10 const intervalInput = await getNearestInputFromText( 11 document, 12 "Sampling interval:" 13 ); 14 is( 15 getActiveConfiguration().interval, 16 1, 17 "The active configuration's interval is set to a specific number initially." 18 ); 19 is( 20 intervalInput.getAttribute("aria-valuemin"), 21 "0.01", 22 "aria-valuemin has the expected value" 23 ); 24 is( 25 intervalInput.getAttribute("aria-valuemax"), 26 "1000", 27 "aria-valuemax has the expected value" 28 ); 29 is( 30 intervalInput.getAttribute("aria-valuenow"), 31 "1", 32 "aria-valuenow has the expected value" 33 ); 34 35 info( 36 "Increase the interval by an arbitrary amount. The input range will " + 37 "scale that to the final value presented to the profiler." 38 ); 39 setReactFriendlyInputValue(intervalInput, Number(intervalInput.value) + 1); 40 41 is( 42 getActiveConfiguration().interval, 43 2, 44 "The configuration's interval was able to be increased." 45 ); 46 is( 47 intervalInput.getAttribute("aria-valuenow"), 48 "2", 49 "aria-valuenow has the expected value" 50 ); 51 52 intervalInput.focus(); 53 54 info("Increase the interval with the keyboard"); 55 EventUtils.synthesizeKey("VK_RIGHT"); 56 await waitUntil(() => getActiveConfiguration().interval === 3); 57 is( 58 intervalInput.getAttribute("aria-valuenow"), 59 "3", 60 "aria-valuenow has the expected value" 61 ); 62 63 info("Decrease the interval with the keyboard"); 64 EventUtils.synthesizeKey("VK_LEFT"); 65 await waitUntil(() => getActiveConfiguration().interval === 2); 66 is( 67 intervalInput.getAttribute("aria-valuenow"), 68 "2", 69 "aria-valuenow has the expected value" 70 ); 71 }); 72 });