browser_aboutprofiling-presets-custom.js (3838B)
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 5 "use strict"; 6 7 add_task(async function test() { 8 info( 9 "Test that about:profiling presets override the individual settings when changed." 10 ); 11 const supportedFeatures = Services.profiler.GetFeatures(); 12 13 if (!supportedFeatures.includes("stackwalk")) { 14 ok(true, "This platform does not support stackwalking, skip this test."); 15 return; 16 } 17 // This test assumes that the Web Developer preset is set by default, which is 18 // not the case on Nightly and custom builds. 19 PrefsPresets.changePreset( 20 "aboutprofiling", 21 "web-developer", 22 supportedFeatures 23 ); 24 25 await withAboutProfiling(async document => { 26 const webdevPreset = await getNearestInputFromText( 27 document, 28 "Web Developer" 29 ); 30 const customPreset = await getNearestInputFromText(document, "Custom"); 31 const stackwalkFeature = await getNearestInputFromText( 32 document, 33 "Native Stacks" 34 ); 35 const geckoMainThread = await getNearestInputFromText( 36 document, 37 "GeckoMain" 38 ); 39 40 { 41 info("Check the defaults on the about:profiling page."); 42 ok( 43 webdevPreset.checked, 44 "By default the Web Developer preset is checked." 45 ); 46 ok(!customPreset.checked, "By default the custom preset is not checked."); 47 ok( 48 !stackwalkFeature.checked, 49 "Stack walking is not enabled for Web Developer." 50 ); 51 ok( 52 !activeConfigurationHasFeature("stackwalk"), 53 "Stack walking is not in the active configuration." 54 ); 55 ok( 56 geckoMainThread.checked, 57 "The GeckoMain thread is tracked for the Web Developer preset" 58 ); 59 ok( 60 activeConfigurationHasThread("GeckoMain"), 61 "The GeckoMain thread is in the active configuration." 62 ); 63 } 64 65 { 66 info("Change some settings, which will move the preset over to Custom."); 67 68 info("Click stack walking."); 69 stackwalkFeature.click(); 70 71 info("Click the GeckoMain thread."); 72 geckoMainThread.click(); 73 } 74 75 { 76 info("Check that the various settings were actually updated in the UI."); 77 ok( 78 !webdevPreset.checked, 79 "The Web Developer preset is no longer enabled." 80 ); 81 ok(customPreset.checked, "The Custom preset is now checked."); 82 ok(stackwalkFeature.checked, "Stack walking was enabled"); 83 ok( 84 activeConfigurationHasFeature("stackwalk"), 85 "Stack walking is in the active configuration." 86 ); 87 ok( 88 !geckoMainThread.checked, 89 "GeckoMain was removed from tracked threads." 90 ); 91 ok( 92 !activeConfigurationHasThread("GeckoMain"), 93 "The GeckoMain thread is not in the active configuration." 94 ); 95 } 96 97 { 98 info( 99 "Click the Web Developer preset, which should revert the other settings." 100 ); 101 webdevPreset.click(); 102 } 103 104 { 105 info( 106 "Now verify that everything was reverted back to the original settings." 107 ); 108 ok(webdevPreset.checked, "The Web Developer preset is checked again."); 109 ok(!customPreset.checked, "The custom preset is not checked."); 110 ok( 111 !stackwalkFeature.checked, 112 "Stack walking is reverted for the Web Developer preset." 113 ); 114 ok( 115 !activeConfigurationHasFeature("stackwalk"), 116 "Stack walking is not in the active configuration." 117 ); 118 ok( 119 geckoMainThread.checked, 120 "GeckoMain was added back to the tracked threads." 121 ); 122 ok( 123 activeConfigurationHasThread("GeckoMain"), 124 "The GeckoMain thread is in the active configuration." 125 ); 126 } 127 }); 128 });