dom/tests/mochitest/localstorage/interOriginFrame.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 function postMsg(message)
     2 {
     3   parent.postMessage(message, "http://mochi.test:8888");
     4 }
     6 window.addEventListener("message", onMessageReceived, false);
     8 function onMessageReceived(event)
     9 {
    10   if (event.data == "step") {
    11     var performed = false;
    12     try {
    13       performed = doStep();
    14     }
    15     catch (ex) {
    16       postMsg("FAILURE: exception threw at "+ location +":\n" + ex);
    17       finishTest();
    18     }
    20     if (performed)
    21       postMsg("perf");
    23     return;
    24   }
    26   postMsg("Invalid message");
    27 }
    29 function ok(a, message)
    30 {
    31   if (!a)
    32     postMsg("FAILURE: " + message);
    33   else
    34     postMsg(message);
    35 }
    37 function is(a, b, message)
    38 {
    39   if (a != b)
    40     postMsg("FAILURE: " + message + ", expected "+b+" got "+a);
    41   else
    42     postMsg(message + ", expected "+b+" got "+a);
    43 }
    45 function todo(a, b, message)
    46 {
    47   postMsg("TODO: " + message + ", expected "+b+" got "+a);
    48 }
    50 function finishTest()
    51 {
    52   localStorage.clear();
    53   postMsg("done");
    54   return false;
    55 }

mercurial