toolkit/mozapps/extensions/test/browser/cancelCompatCheck.sjs

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 // Delay before responding to an HTTP call attempting to read
michael@0 5 // an addon update RDF file
michael@0 6
michael@0 7 function handleRequest(req, resp) {
michael@0 8 resp.processAsync();
michael@0 9 resp.setHeader("Cache-Control", "no-cache, no-store", false);
michael@0 10 resp.setHeader("Content-Type", "text/xml;charset=utf-8", false);
michael@0 11
michael@0 12 let file = null;
michael@0 13 getObjectState("SERVER_ROOT", function(serverRoot)
michael@0 14 {
michael@0 15 file = serverRoot.getFile("browser/toolkit/mozapps/extensions/test/browser/browser_bug557956.rdf");
michael@0 16 });
michael@0 17 dump("*** cancelCompatCheck.sjs: " + file.path + "\n");
michael@0 18 let fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].
michael@0 19 createInstance(Components.interfaces.nsIFileInputStream);
michael@0 20 fstream.init(file, -1, 0, 0);
michael@0 21 let cstream = null;
michael@0 22 cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
michael@0 23 createInstance(Components.interfaces.nsIConverterInputStream);
michael@0 24 cstream.init(fstream, "UTF-8", 0, 0);
michael@0 25
michael@0 26 // The delay can be passed on the query string
michael@0 27 let delay = req.queryString + 0;
michael@0 28
michael@0 29 timer = Components.classes["@mozilla.org/timer;1"].
michael@0 30 createInstance(Components.interfaces.nsITimer);
michael@0 31 timer.init(function sendFile() {
michael@0 32 dump("cancelCompatCheck: starting to send file\n");
michael@0 33 let (str = {}) {
michael@0 34 let read = 0;
michael@0 35 do {
michael@0 36 // read as much as we can and put it in str.value
michael@0 37 read = cstream.readString(0xffffffff, str);
michael@0 38 resp.write(str.value);
michael@0 39 } while (read != 0);
michael@0 40 }
michael@0 41 cstream.close();
michael@0 42 resp.finish();
michael@0 43 }, delay, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
michael@0 44 }

mercurial