browser_jsonview_nojs.js (904B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_task(async function () { 7 info("Test JSON without JavaScript started."); 8 9 const oldPref = Services.prefs.getBoolPref("javascript.enabled"); 10 Services.prefs.setBoolPref("javascript.enabled", false); 11 12 const TEST_JSON_URL = "data:application/json,[1,2,3]"; 13 14 // "uninitialized" will be the last app readyState because JS is disabled. 15 await addJsonViewTab(TEST_JSON_URL, { appReadyState: "uninitialized" }); 16 17 info("Checking visible text contents."); 18 19 const text = await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => { 20 const element = content.document.querySelector("html"); 21 return element ? element.innerText : null; 22 }); 23 is(text, "[1,2,3]", "The raw source should be visible."); 24 25 Services.prefs.setBoolPref("javascript.enabled", oldPref); 26 });