dom/tests/mochitest/localstorage/interOriginTest.js

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 var slaveLoadsPending = 1;
     3 var slaveOrigin = "";
     4 var slave = null;
     6 var failureRegExp = new RegExp("^FAILURE");
     7 const slavePath = "/tests/dom/tests/mochitest/localstorage/";
     9 window.addEventListener("message", onMessageReceived, false);
    11 function onMessageReceived(event)
    12 {
    13   switch (event.data)
    14   {
    15     // Indication of the frame onload event
    16     case "frame loaded":
    17       if (--slaveLoadsPending)
    18         break;
    20       // Just fall through...
    22     // Indication of successfully finished step of a test
    23     case "perf":
    24       if (event.data == "perf")
    25         doStep();
    27       slave.postMessage("step", slaveOrigin);
    28       break;
    30     // Indication of all test parts finish (from any of the frames)
    31     case "done":
    32       localStorage.clear();
    33       slaveLoadsPending = 1;
    34       doNextTest();
    35       break;
    37     // Any other message indicates error or succes message of a test
    38     default:
    39       SimpleTest.ok(!event.data.match(failureRegExp), event.data);
    40       break;
    41   }
    42 }

mercurial