summaryrefslogtreecommitdiffstats
path: root/layout/generic/test/file_SlowImage.sjs
diff options
context:
space:
mode:
Diffstat (limited to 'layout/generic/test/file_SlowImage.sjs')
-rw-r--r--layout/generic/test/file_SlowImage.sjs45
1 files changed, 45 insertions, 0 deletions
diff --git a/layout/generic/test/file_SlowImage.sjs b/layout/generic/test/file_SlowImage.sjs
new file mode 100644
index 000000000..cf95eeeea
--- /dev/null
+++ b/layout/generic/test/file_SlowImage.sjs
@@ -0,0 +1,45 @@
+"use strict";
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+
+const IMG_BYTES = atob(
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAA" +
+ "DUlEQVQImWNgY2P7DwABOgESJhRQtgAAAABJRU5ErkJggg==");
+
+function handleRequest(request, response) {
+ response.processAsync();
+ getObjectState("context", function(obj) {
+ let ctx;
+ if (obj == null) {
+ ctx = {
+ QueryInterface: function(iid) {
+ if (iid.equals(Components.interfaces.nsISupports))
+ return this;
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ };
+ ctx.wrappedJSObject = ctx;
+
+ ctx.promise = new Promise(resolve => {
+ ctx.resolve = resolve;
+ });
+
+ setObjectState("context", ctx);
+ } else {
+ ctx = obj.wrappedJSObject;
+ }
+ Promise.resolve(ctx).then(next);
+ });
+
+ function next(ctx) {
+ if (request.queryString.indexOf("continue") >= 0) {
+ ctx.resolve();
+ }
+
+ ctx.promise.then(() => {
+ response.setHeader("Content-Type", "image/png");
+ response.write(IMG_BYTES);
+ response.finish();
+ });
+ }
+}