dom/tests/mochitest/localstorage/interOriginTest2.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 t = async_test(document.title);
     3 var frameLoadsPending = 2;
     5 var callMasterFrame = true;
     6 var testDone = false;
     8 var masterFrameOrigin = "";
     9 var slaveFrameOrigin = "";
    11 var failureRegExp = new RegExp("^FAILURE");
    13 const framePath = "/tests/dom/tests/mochitest/localstorage/";
    15 window.addEventListener("message", onMessageReceived, false);
    17 function onMessageReceived(event)
    18 {
    19   switch (event.data)
    20   {
    21     // Indication of the frame onload event
    22     case "frame loaded":
    23       if (--frameLoadsPending)
    24         break;
    26       // Just fall through...
    28     // Indication of successfully finished step of a test
    29     case "perf":
    30       if (callMasterFrame)
    31         masterFrame.postMessage("step", masterFrameOrigin);
    32       else
    33         slaveFrame.postMessage("step", slaveFrameOrigin);
    34       callMasterFrame = !callMasterFrame;
    35       break;
    37     // Indication of all test parts finish (from any of the frames)
    38     case "done":
    39       if (testDone)
    40         break;
    42       testDone = true;
    43       t.done();
    44       break;
    46     // Any other message indicates error, succes or todo message of a test
    47     default:
    48       t.step(function() {
    49         assert_true(!event.data.match(failureRegExp), event.data);
    50       });
    51       break;
    52   }
    53 }

mercurial