1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/storageevent/interOriginFrame.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 1.4 +function postMsg(message) 1.5 +{ 1.6 + var l = SpecialPowers.wrap(parent.window.location); 1.7 + parent.postMessage(message, l.protocol + "//" + l.host); 1.8 +} 1.9 + 1.10 +window.addEventListener("message", onMessageReceived, false); 1.11 + 1.12 +function onMessageReceived(event) 1.13 +{ 1.14 + if (event.data == "step") { 1.15 + var performed = false; 1.16 + try { 1.17 + performed = doStep(); 1.18 + } 1.19 + catch (ex) { 1.20 + postMsg("FAILURE: exception threw at "+ location +":\n" + ex); 1.21 + finishTest(); 1.22 + } 1.23 + 1.24 + if (performed) 1.25 + postMsg("perf"); 1.26 + 1.27 + return; 1.28 + } 1.29 + 1.30 + if (parent) 1.31 + postMsg(event.data); 1.32 +} 1.33 + 1.34 +function ok(a, message) 1.35 +{ 1.36 + if (!a) 1.37 + postMsg("FAILURE: " + message); 1.38 + else 1.39 + postMsg(message); 1.40 +} 1.41 + 1.42 +function is(a, b, message) 1.43 +{ 1.44 + if (a != b) 1.45 + postMsg("FAILURE: " + message + ", expected "+b+" got "+a); 1.46 + else 1.47 + postMsg(message + ", expected "+b+" got "+a); 1.48 +} 1.49 + 1.50 +function todo(a, b, message) 1.51 +{ 1.52 + postMsg("TODO: " + message + ", expected "+b+" got "+a); 1.53 +} 1.54 + 1.55 +function finishTest() 1.56 +{ 1.57 + postMsg("done"); 1.58 + return false; 1.59 +}