summaryrefslogtreecommitdiffstats
path: root/layout/generic/test/file_SlowImage.sjs
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /layout/generic/test/file_SlowImage.sjs
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
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();
+ });
+ }
+}