diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /netwerk/test/mochitests/subResources.sjs | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | netwerk/test/mochitests/subResources.sjs | 78 |
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;"); +} |