diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/inspector/rules/test/sjs_imported_stylesheet_edit.sjs | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/inspector/rules/test/sjs_imported_stylesheet_edit.sjs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/devtools/client/inspector/rules/test/sjs_imported_stylesheet_edit.sjs b/devtools/client/inspector/rules/test/sjs_imported_stylesheet_edit.sjs new file mode 100644 index 0000000000..5a68c5571c --- /dev/null +++ b/devtools/client/inspector/rules/test/sjs_imported_stylesheet_edit.sjs @@ -0,0 +1,53 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ + +"use strict"; +const INITIAL_CONTENT = ` +div { + color: red +} +`; + +const UPDATED_CONTENT = ` +span { + color: green; +} + +a { + color: blue; +} + +div { + color: gold; +} +`; + +/** + * This sjs file supports three endpoint: + * - "sjs_imported_stylesheet_edit.sjs" -> will return a text/css content which + * will be either INITIAL_CONTENT or UPDATED_CONTENT. Initially will return + * INITIAL_CONTENT. + * - "sjs_imported_stylesheet_edit.sjs?update-stylesheet" -> will update an + * internal flag. After calling this URL, the regular endpoint will return + * UPDATED_CONTENT instead of INITIAL_CONTENT + * - "sjs_imported_stylesheet_edit.sjs?setup" -> set the internal flag to its + * default value. Should be called at the beginning of every test to avoid + * side effects. + */ +function handleRequest(request, response) { + const { queryString } = request; + if (queryString === "setup") { + setState("serve-updated-content", "false"); + response.setHeader("Content-Type", "text/html"); + response.write("OK"); + } else if (queryString === "update-stylesheet") { + setState("serve-updated-content", "true"); + response.setHeader("Content-Type", "text/html"); + response.write("OK"); + } else { + response.setHeader("Content-Type", "text/css"); + const shouldServeUpdatedCSS = getState("serve-updated-content") == "true"; + response.write(shouldServeUpdatedCSS ? UPDATED_CONTENT : INITIAL_CONTENT); + } +} |