dom/tests/mochitest/localstorage/interOriginFrame.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/localstorage/interOriginFrame.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +function postMsg(message)
     1.5 +{
     1.6 +  parent.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 +  if (event.data == "step") {
    1.14 +    var performed = false;
    1.15 +    try {
    1.16 +      performed = doStep();
    1.17 +    }
    1.18 +    catch (ex) {
    1.19 +      postMsg("FAILURE: exception threw at "+ location +":\n" + ex);
    1.20 +      finishTest();
    1.21 +    }
    1.22 +
    1.23 +    if (performed)
    1.24 +      postMsg("perf");
    1.25 +
    1.26 +    return;
    1.27 +  }
    1.28 +
    1.29 +  postMsg("Invalid message");
    1.30 +}
    1.31 +
    1.32 +function ok(a, message)
    1.33 +{
    1.34 +  if (!a)
    1.35 +    postMsg("FAILURE: " + message);
    1.36 +  else
    1.37 +    postMsg(message);
    1.38 +}
    1.39 +
    1.40 +function is(a, b, message)
    1.41 +{
    1.42 +  if (a != b)
    1.43 +    postMsg("FAILURE: " + message + ", expected "+b+" got "+a);
    1.44 +  else
    1.45 +    postMsg(message + ", expected "+b+" got "+a);
    1.46 +}
    1.47 +
    1.48 +function todo(a, b, message)
    1.49 +{
    1.50 +  postMsg("TODO: " + message + ", expected "+b+" got "+a);
    1.51 +}
    1.52 +
    1.53 +function finishTest()
    1.54 +{
    1.55 +  localStorage.clear();
    1.56 +  postMsg("done");
    1.57 +  return false;
    1.58 +}

mercurial