summaryrefslogtreecommitdiffstats
path: root/image/test/crashtests/1763581-1.sjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /image/test/crashtests/1763581-1.sjs
parentInitial commit. (diff)
downloadthunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz
thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'image/test/crashtests/1763581-1.sjs')
-rw-r--r--image/test/crashtests/1763581-1.sjs71
1 files changed, 71 insertions, 0 deletions
diff --git a/image/test/crashtests/1763581-1.sjs b/image/test/crashtests/1763581-1.sjs
new file mode 100644
index 0000000000..9fb70dd463
--- /dev/null
+++ b/image/test/crashtests/1763581-1.sjs
@@ -0,0 +1,71 @@
+
+function getFileStream(filename)
+{
+ // Get the location of this sjs file, and then use that to figure out where
+ // to find where our other files are.
+ var self = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsIFile);
+ self.initWithPath(getState("__LOCATION__"));
+ var file = self.parent;
+ file.append(filename);
+
+ var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1']
+ .createInstance(Components.interfaces.nsIFileInputStream);
+ fileStream.init(file, 1, 0, false);
+
+ return fileStream;
+}
+
+// stolen from file_blocked_script.sjs
+function setGlobalState(data, key) {
+ x = {
+ data,
+ QueryInterface: ChromeUtils.generateQI([]),
+ };
+ x.wrappedJSObject = x;
+ setObjectState(key, x);
+}
+
+function getGlobalState(key) {
+ var data;
+ getObjectState(key, function(x) {
+ data = x && x.wrappedJSObject.data;
+ });
+ return data;
+}
+
+const DELAY_MS = 100;
+let gTimer;
+
+function handleRequest(request, response) {
+ let count = getGlobalState("count");
+ if (count == null) {
+ count = 0;
+ }
+
+ if (count > 0) {
+ response.processAsync();
+
+ gTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
+ gTimer.init(
+ () => {
+ response.setStatusLine(request.httpVersion, 304, "Not Modified");
+ response.finish();
+ },
+ DELAY_MS,
+ Ci.nsITimer.TYPE_ONE_SHOT
+ );
+
+ return;
+ }
+
+ response.setStatusLine(request.httpVersion, 200, "OK");
+ response.setHeader("Content-Type", "image/gif", false);
+
+ var inputStream = getFileStream("1763581-1.gif");
+ response.bodyOutputStream.writeFrom(inputStream, inputStream.available());
+ inputStream.close();
+
+ count++;
+ setGlobalState(count, "count");
+}