From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../browser_toolbox_options_disable_cache-03.js | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 devtools/client/framework/test/browser_toolbox_options_disable_cache-03.js (limited to 'devtools/client/framework/test/browser_toolbox_options_disable_cache-03.js') diff --git a/devtools/client/framework/test/browser_toolbox_options_disable_cache-03.js b/devtools/client/framework/test/browser_toolbox_options_disable_cache-03.js new file mode 100644 index 0000000000..f3a53f6422 --- /dev/null +++ b/devtools/client/framework/test/browser_toolbox_options_disable_cache-03.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that even when the cache is disabled, the inspector/styleeditor don't fetch again +// stylesheets from the server to display them in devtools, but use the cached version. + +const TEST_CSS = URL_ROOT + "browser_toolbox_options_disable_cache.css.sjs"; +const TEST_PAGE = ` + + + + + +`; + +add_task(async function () { + info("Setup preferences for testing"); + // Disable rcwn to make cache behavior deterministic. + await pushPref("network.http.rcwn.enabled", false); + // Disable the cache. + await pushPref("devtools.cache.disabled", true); + + info("Open inspector"); + const toolbox = await openNewTabAndToolbox( + `data:text/html;charset=UTF-8,${encodeURIComponent(TEST_PAGE)}`, + "inspector" + ); + const inspector = toolbox.getPanel("inspector"); + + info( + "Check that the CSS content loaded in the page " + + "and the one shown in the inspector are the same" + ); + const webContent = await getWebContent(); + const inspectorContent = await getInspectorContent(inspector); + is( + webContent, + inspectorContent, + "The contents of both web and DevTools are same" + ); + + await closeTabAndToolbox(); +}); + +async function getInspectorContent(inspector) { + const ruleView = inspector.getPanel("ruleview").view; + const valueEl = await waitFor(() => + ruleView.styleDocument.querySelector(".ruleview-propertyvalue") + ); + return valueEl.textContent; +} + +async function getWebContent() { + return SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => { + const doc = content.document; + return doc.ownerGlobal.getComputedStyle(doc.body, "::before").content; + }); +} -- cgit v1.2.3