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.

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

mercurial