1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/browser/cancelCompatCheck.sjs Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Delay before responding to an HTTP call attempting to read 1.8 +// an addon update RDF file 1.9 + 1.10 +function handleRequest(req, resp) { 1.11 + resp.processAsync(); 1.12 + resp.setHeader("Cache-Control", "no-cache, no-store", false); 1.13 + resp.setHeader("Content-Type", "text/xml;charset=utf-8", false); 1.14 + 1.15 + let file = null; 1.16 + getObjectState("SERVER_ROOT", function(serverRoot) 1.17 + { 1.18 + file = serverRoot.getFile("browser/toolkit/mozapps/extensions/test/browser/browser_bug557956.rdf"); 1.19 + }); 1.20 + dump("*** cancelCompatCheck.sjs: " + file.path + "\n"); 1.21 + let fstream = Components.classes["@mozilla.org/network/file-input-stream;1"]. 1.22 + createInstance(Components.interfaces.nsIFileInputStream); 1.23 + fstream.init(file, -1, 0, 0); 1.24 + let cstream = null; 1.25 + cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]. 1.26 + createInstance(Components.interfaces.nsIConverterInputStream); 1.27 + cstream.init(fstream, "UTF-8", 0, 0); 1.28 + 1.29 + // The delay can be passed on the query string 1.30 + let delay = req.queryString + 0; 1.31 + 1.32 + timer = Components.classes["@mozilla.org/timer;1"]. 1.33 + createInstance(Components.interfaces.nsITimer); 1.34 + timer.init(function sendFile() { 1.35 + dump("cancelCompatCheck: starting to send file\n"); 1.36 + let (str = {}) { 1.37 + let read = 0; 1.38 + do { 1.39 + // read as much as we can and put it in str.value 1.40 + read = cstream.readString(0xffffffff, str); 1.41 + resp.write(str.value); 1.42 + } while (read != 0); 1.43 + } 1.44 + cstream.close(); 1.45 + resp.finish(); 1.46 + }, delay, Components.interfaces.nsITimer.TYPE_ONE_SHOT); 1.47 +}