browser_aboutprofiling-features-disabled.js (2037B)
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 features that are disabled on the platform are disabled in about:profiling." 10 ); 11 12 const supportedFeatures = Services.profiler.GetFeatures(); 13 const allFeatures = Services.profiler.GetAllFeatures(); 14 const unsupportedFeatures = allFeatures.filter( 15 feature => !supportedFeatures.includes(feature) 16 ); 17 18 if (unsupportedFeatures.length === 0) { 19 ok(true, "This platform has no unsupported features. Skip this test."); 20 return; 21 } 22 23 await withAboutProfiling(async document => { 24 { 25 info("Find and click a supported feature to toggle it."); 26 const [firstSupportedFeature] = supportedFeatures; 27 const checkbox = getFeatureCheckbox(document, firstSupportedFeature); 28 const initialValue = checkbox.checked; 29 info("Click the supported checkbox."); 30 checkbox.click(); 31 is( 32 initialValue, 33 !checkbox.checked, 34 "A supported feature can be toggled." 35 ); 36 checkbox.click(); 37 } 38 39 { 40 info("Find and click an unsupported feature, it should be disabled."); 41 const [firstUnsupportedFeature] = unsupportedFeatures; 42 const checkbox = getFeatureCheckbox(document, firstUnsupportedFeature); 43 is(checkbox.checked, false, "The unsupported feature is not checked."); 44 45 info("Click the unsupported checkbox."); 46 checkbox.click(); 47 is(checkbox.checked, false, "After clicking it, it's still not checked."); 48 } 49 }); 50 }); 51 52 /** 53 * @param {HTMLDocument} document 54 * @param {string} feature 55 * @return {HTMLElement} 56 */ 57 function getFeatureCheckbox(document, feature) { 58 const element = document.querySelector(`input[value="${feature}"]`); 59 if (!element) { 60 throw new Error("Could not find the checkbox for the feature: " + feature); 61 } 62 return element; 63 }