summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/rules/test/sjs_imported_stylesheet_edit.sjs
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/inspector/rules/test/sjs_imported_stylesheet_edit.sjs')
-rw-r--r--devtools/client/inspector/rules/test/sjs_imported_stylesheet_edit.sjs53
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);
+ }
+}