1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/sessionstorage/interOriginSlave.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +function postMsg(message) 1.5 +{ 1.6 + opener.postMessage(message, "http://mochi.test:8888"); 1.7 +} 1.8 + 1.9 +window.addEventListener("message", onMessageReceived, false); 1.10 + 1.11 +function onMessageReceived(event) 1.12 +{ 1.13 + //alert("slave got event: "+event.data); 1.14 + if (event.data == "step") { 1.15 + if (doStep()) 1.16 + postMsg("perf"); 1.17 + 1.18 + return; 1.19 + } 1.20 + 1.21 + postMsg("Invalid message"); 1.22 +} 1.23 + 1.24 +function ok(a, message) 1.25 +{ 1.26 + if (!a) 1.27 + postMsg("FAILURE: " + message); 1.28 + else 1.29 + postMsg(message); 1.30 +} 1.31 + 1.32 +function is(a, b, message) 1.33 +{ 1.34 + if (a != b) 1.35 + postMsg("FAILURE: " + message + ", expected "+b+" got "+a); 1.36 + else 1.37 + postMsg(message + ", expected "+b+" got "+a); 1.38 +} 1.39 + 1.40 +function finishTest() 1.41 +{ 1.42 + sessionStorage.clear(); 1.43 + postMsg("done"); 1.44 + return false; 1.45 +}