browser_toolbox_options_disable_cache-03.js (1850B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that even when the cache is disabled, the inspector/styleeditor don't fetch again 7 // stylesheets from the server to display them in devtools, but use the cached version. 8 9 const TEST_CSS = URL_ROOT + "browser_toolbox_options_disable_cache.css.sjs"; 10 const TEST_PAGE = `<html> 11 <head> 12 <meta charset="utf-8"/> 13 <link href="${TEST_CSS}" rel="stylesheet" type="text/css"/> 14 </head> 15 <body></body> 16 </html>`; 17 18 add_task(async function () { 19 info("Setup preferences for testing"); 20 // Disable rcwn to make cache behavior deterministic. 21 await pushPref("network.http.rcwn.enabled", false); 22 // Disable the cache. 23 await pushPref("devtools.cache.disabled", true); 24 25 info("Open inspector"); 26 const toolbox = await openNewTabAndToolbox( 27 `data:text/html;charset=UTF-8,${encodeURIComponent(TEST_PAGE)}`, 28 "inspector" 29 ); 30 const inspector = toolbox.getPanel("inspector"); 31 32 info( 33 "Check that the CSS content loaded in the page " + 34 "and the one shown in the inspector are the same" 35 ); 36 const webContent = await getWebContent(); 37 const inspectorContent = await getInspectorContent(inspector); 38 is( 39 webContent, 40 inspectorContent, 41 "The contents of both web and DevTools are same" 42 ); 43 44 await closeTabAndToolbox(); 45 }); 46 47 async function getInspectorContent(inspector) { 48 const ruleView = inspector.getPanel("ruleview").view; 49 const valueEl = await waitFor(() => 50 ruleView.styleDocument.querySelector(".ruleview-propertyvalue") 51 ); 52 return valueEl.textContent; 53 } 54 55 async function getWebContent() { 56 return SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => { 57 const doc = content.document; 58 return doc.ownerGlobal.getComputedStyle(doc.body, "::before").content; 59 }); 60 }