dom/tests/mochitest/storageevent/interOriginFrame.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 function postMsg(message)
     2 {
     3   var l = SpecialPowers.wrap(parent.window.location);
     4   parent.postMessage(message, l.protocol + "//" + l.host);
     5 }
     7 window.addEventListener("message", onMessageReceived, false);
     9 function onMessageReceived(event)
    10 {
    11   if (event.data == "step") {
    12     var performed = false;
    13     try {
    14       performed = doStep();
    15     }
    16     catch (ex) {
    17       postMsg("FAILURE: exception threw at "+ location +":\n" + ex);
    18       finishTest();
    19     }
    21     if (performed)
    22       postMsg("perf");
    24     return;
    25   }
    27   if (parent)
    28     postMsg(event.data);
    29 }
    31 function ok(a, message)
    32 {
    33   if (!a)
    34     postMsg("FAILURE: " + message);
    35   else
    36     postMsg(message);
    37 }
    39 function is(a, b, message)
    40 {
    41   if (a != b)
    42     postMsg("FAILURE: " + message + ", expected "+b+" got "+a);
    43   else
    44     postMsg(message + ", expected "+b+" got "+a);
    45 }
    47 function todo(a, b, message)
    48 {
    49   postMsg("TODO: " + message + ", expected "+b+" got "+a);
    50 }
    52 function finishTest()
    53 {
    54   postMsg("done");
    55   return false;
    56 }

mercurial