summaryrefslogtreecommitdiffstats
path: root/netwerk/test/mochitests/subResources.sjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /netwerk/test/mochitests/subResources.sjs
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--netwerk/test/mochitests/subResources.sjs78
1 files changed, 78 insertions, 0 deletions
diff --git a/netwerk/test/mochitests/subResources.sjs b/netwerk/test/mochitests/subResources.sjs
new file mode 100644
index 0000000000..ec2cfaa750
--- /dev/null
+++ b/netwerk/test/mochitests/subResources.sjs
@@ -0,0 +1,78 @@
+const kTwoDays = 2 * 24 * 60 * 60;
+const kInTwoDays = new Date().getTime() + kTwoDays * 1000;
+
+function getDateInTwoDays() {
+ let date2 = new Date(kInTwoDays);
+ let days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
+ let months = [
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec",
+ ];
+ let day = date2.getUTCDate();
+ if (day < 10) {
+ day = "0" + day;
+ }
+ let month = months[date2.getUTCMonth()];
+ let year = date2.getUTCFullYear();
+ let hour = date2.getUTCHours();
+ if (hour < 10) {
+ hour = "0" + hour;
+ }
+ let minute = date2.getUTCMinutes();
+ if (minute < 10) {
+ minute = "0" + minute;
+ }
+ let second = date2.getUTCSeconds();
+ if (second < 10) {
+ second = "0" + second;
+ }
+ return (
+ days[date2.getUTCDay()] +
+ ", " +
+ day +
+ "-" +
+ month +
+ "-" +
+ year +
+ " " +
+ hour +
+ ":" +
+ minute +
+ ":" +
+ second +
+ " GMT"
+ );
+}
+
+function handleRequest(aRequest, aResponse) {
+ aResponse.setStatusLine(aRequest.httpVersion, 200);
+
+ let suffix = " path=/; domain:.mochi.test";
+
+ if (aRequest.queryString.includes("3")) {
+ aResponse.setHeader(
+ "Set-Cookie",
+ "test3=value3; expires=Fri, 02-Jan-2037 00:00:01 GMT;" + suffix
+ );
+ } else if (aRequest.queryString.includes("4")) {
+ let date2 = getDateInTwoDays();
+
+ aResponse.setHeader(
+ "Set-Cookie",
+ "test4=value4; expires=" + date2 + ";" + suffix
+ );
+ }
+
+ aResponse.setHeader("Content-Type", "text/javascript", false);
+ aResponse.write("42;");
+}