From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- dom/base/test/file_browser_refresh_image.sjs | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 dom/base/test/file_browser_refresh_image.sjs (limited to 'dom/base/test/file_browser_refresh_image.sjs') diff --git a/dom/base/test/file_browser_refresh_image.sjs b/dom/base/test/file_browser_refresh_image.sjs new file mode 100644 index 0000000000..17f11e87e9 --- /dev/null +++ b/dom/base/test/file_browser_refresh_image.sjs @@ -0,0 +1,38 @@ +"use strict"; + +function handleRequest(request, response) { + const file = Components.classes["@mozilla.org/file/directory_service;1"] + .getService(Components.interfaces.nsIProperties) + .get("CurWorkD", Components.interfaces.nsIFile); + + file.append("tests"); + file.append("image"); + file.append("test"); + file.append("mochitest"); + + const redirectstate = "image_resource"; + if (getState(redirectstate) == "") { + file.append("green.png"); + setState(redirectstate, "green"); + } else { + file.append("red.png"); + setState(redirectstate, ""); + } + + response.setHeader("Cache-Control", "max-age=3600", false); + + const fileStream = Components.classes[ + "@mozilla.org/network/file-input-stream;1" + ].createInstance(Components.interfaces.nsIFileInputStream); + + fileStream.init(file, 1, 0, false); + const binaryStream = Components.classes[ + "@mozilla.org/binaryinputstream;1" + ].createInstance(Components.interfaces.nsIBinaryInputStream); + binaryStream.setInputStream(fileStream); + + response.bodyOutputStream.writeFrom(binaryStream, binaryStream.available()); + + binaryStream.close(); + fileStream.close(); +} -- cgit v1.2.3