michael@0: var frameLoadsPending = 2; michael@0: michael@0: var callMasterFrame = true; michael@0: var testDone = false; michael@0: michael@0: var masterFrameOrigin = ""; michael@0: var slaveFrameOrigin = ""; michael@0: michael@0: var failureRegExp = new RegExp("^FAILURE"); michael@0: var todoRegExp = new RegExp("^TODO"); michael@0: michael@0: const framePath = "/tests/dom/tests/mochitest/storageevent/"; michael@0: michael@0: window.addEventListener("message", onMessageReceived, false); michael@0: michael@0: function onMessageReceived(event) michael@0: { michael@0: michael@0: switch (event.data) michael@0: { michael@0: // Indication of the frame onload event michael@0: case "frame loaded": michael@0: if (--frameLoadsPending) michael@0: break; michael@0: michael@0: // Just fall through... michael@0: michael@0: // Indication of successfully finished step of a test michael@0: case "perf": michael@0: if (callMasterFrame) michael@0: masterFrame.postMessage("step", "*"); michael@0: else if (slaveFrame) michael@0: slaveFrame.postMessage("step", "*"); michael@0: else if (SpecialPowers.wrap(masterFrame).slaveFrame) michael@0: SpecialPowers.wrap(masterFrame).slaveFrame.postMessage("step", "*"); michael@0: callMasterFrame = !callMasterFrame; michael@0: break; michael@0: michael@0: // Indication of all test parts finish (from any of the frames) michael@0: case "done": michael@0: if (testDone) michael@0: break; michael@0: michael@0: testDone = true; michael@0: SimpleTest.finish(); michael@0: break; michael@0: michael@0: // Any other message indicates error, succes or todo message of a test michael@0: default: michael@0: if (typeof event.data == "undefined") michael@0: break; // XXXkhuey this receives undefined values michael@0: // (which used to become empty strings) on occasion ... michael@0: if (event.data.match(todoRegExp)) michael@0: SimpleTest.todo(false, event.data); michael@0: else michael@0: SimpleTest.ok(!event.data.match(failureRegExp), event.data); michael@0: break; michael@0: } michael@0: }