dom/tests/mochitest/storageevent/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 frameLoadsPending = 2;
michael@0 2
michael@0 3 var callMasterFrame = true;
michael@0 4 var testDone = false;
michael@0 5
michael@0 6 var masterFrameOrigin = "";
michael@0 7 var slaveFrameOrigin = "";
michael@0 8
michael@0 9 var failureRegExp = new RegExp("^FAILURE");
michael@0 10 var todoRegExp = new RegExp("^TODO");
michael@0 11
michael@0 12 const framePath = "/tests/dom/tests/mochitest/storageevent/";
michael@0 13
michael@0 14 window.addEventListener("message", onMessageReceived, false);
michael@0 15
michael@0 16 function onMessageReceived(event)
michael@0 17 {
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", "*");
michael@0 32 else if (slaveFrame)
michael@0 33 slaveFrame.postMessage("step", "*");
michael@0 34 else if (SpecialPowers.wrap(masterFrame).slaveFrame)
michael@0 35 SpecialPowers.wrap(masterFrame).slaveFrame.postMessage("step", "*");
michael@0 36 callMasterFrame = !callMasterFrame;
michael@0 37 break;
michael@0 38
michael@0 39 // Indication of all test parts finish (from any of the frames)
michael@0 40 case "done":
michael@0 41 if (testDone)
michael@0 42 break;
michael@0 43
michael@0 44 testDone = true;
michael@0 45 SimpleTest.finish();
michael@0 46 break;
michael@0 47
michael@0 48 // Any other message indicates error, succes or todo message of a test
michael@0 49 default:
michael@0 50 if (typeof event.data == "undefined")
michael@0 51 break; // XXXkhuey this receives undefined values
michael@0 52 // (which used to become empty strings) on occasion ...
michael@0 53 if (event.data.match(todoRegExp))
michael@0 54 SimpleTest.todo(false, event.data);
michael@0 55 else
michael@0 56 SimpleTest.ok(!event.data.match(failureRegExp), event.data);
michael@0 57 break;
michael@0 58 }
michael@0 59 }

mercurial