dom/tests/mochitest/ajax/offline/updatingIframe.sjs

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 ver1iframe =
     2   "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" +
     3   "<head>\n" +
     4   "<title>Update iframe</title>\n" +
     5   "</head>\n" +
     6   "<body onload=\"parent.frameLoad(1)\">\n" +
     7   "First version of updating iframe.\n" +
     8   "</body>\n" +
     9   "</html>\n";
    11 ver2iframe =
    12   "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" +
    13   "<head>\n" +
    14   "<title>Update iframe</title>\n" +
    15   "</head>\n" +
    16   "<body onload=\"parent.frameLoad(2)\">\n" +
    17   "Second version of updating iframe.\n" +
    18   "</body>\n" +
    19   "</html>\n";
    21 function handleRequest(request, response)
    22 {
    23   var match = request.queryString.match(/^state=(.*)$/);
    24   if (match)
    25   {
    26     response.setStatusLine(request.httpVersion, 204, "No content");
    27     setState("offline.updatingIframe", match[1]);
    28   }
    30   if (request.queryString == "")
    31   {
    32     response.setStatusLine(request.httpVersion, 200, "Ok");
    33     response.setHeader("Content-Type", "text/html");
    34     response.setHeader("Cache-Control", "no-cache");
    35     switch (getState("offline.updatingIframe"))
    36     {
    37       case "": // The default value
    38         response.write(ver1iframe);
    39         break;
    40       case "second":
    41         response.write(ver2iframe);
    42         break;
    43     }
    44   }
    45 }

mercurial