browser_aboutSupport_user_namespaces.js (2512B)
1 /* Any copyright is dedicated to the Public Domain. 2 https://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_setup(async function setup() { 7 const originalValue = Services.sysinfo.getProperty("hasUserNamespaces"); 8 Services.sysinfo 9 .QueryInterface(Ci.nsIWritablePropertyBag2) 10 .setPropertyAsBool("hasUserNamespaces", false); 11 // Reset to original value at the end of the test 12 registerCleanupFunction(() => { 13 Services.sysinfo 14 .QueryInterface(Ci.nsIWritablePropertyBag2) 15 .setPropertyAsBool("hasUserNamespaces", originalValue); 16 }); 17 }); 18 19 add_task(async function test_user_namespaces() { 20 await BrowserTestUtils.withNewTab( 21 { gBrowser, url: "about:support" }, 22 async function (browser) { 23 const result = await SpecialPowers.spawn(browser, [], async function () { 24 try { 25 await ContentTaskUtils.waitForCondition(() => { 26 const tbody = content.document.getElementById("sandbox-tbody"); 27 if (!tbody) { 28 return false; 29 } 30 const tr = tbody.getElementsByTagName("tr"); 31 32 const expectedBackgroundColor = content.window.matchMedia( 33 "(prefers-color-scheme: dark)" 34 ).matches 35 ? "oklch(0.34 0.14 15)" 36 : "oklch(0.97 0.05 15)"; 37 38 return !![...tr] 39 .filter( 40 x => 41 x.querySelector("th").dataset.l10nId === "has-user-namespaces" 42 ) 43 .map(x => x.querySelector("td")) 44 .filter( 45 x => 46 content 47 .getComputedStyle(x) 48 .getPropertyValue("background-color") === 49 expectedBackgroundColor 50 ) 51 .filter( 52 x => 53 x.querySelector("span").dataset.l10nId === 54 "support-user-namespaces-unavailable" 55 ) 56 .map(x => x.querySelector("a")) 57 .filter( 58 x => 59 x.getAttribute("support-page") === 60 "install-firefox-linux#w_install-firefox-from-mozilla-builds" 61 ).length; 62 }, "User Namespaces loaded and has correct properties"); 63 } catch (exception) { 64 return false; 65 } 66 return true; 67 }); 68 69 ok( 70 result, 71 "User Namespaces should be loaded to table, set to false, have red background color, and have support link" 72 ); 73 } 74 ); 75 });