michael@0: /* Any copyright is dedicated to the public domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Test that an '; michael@0: // For kicks, this test uses a display:none iframe. This shouldn't make a michael@0: // difference in anything. michael@0: iframe.style.display = 'none'; michael@0: document.body.appendChild(iframe); michael@0: } michael@0: michael@0: var numMsgReceived = 0; michael@0: function outerIframeLoaded() { michael@0: var injectedScript = michael@0: "data:,function is(a, b, desc) { \ michael@0: if (a == b) { \ michael@0: sendAsyncMessage('test:test-pass', desc); \ michael@0: } else { \ michael@0: sendAsyncMessage('test:test-fail', desc + ' ' + a + ' != ' + b); \ michael@0: } \ michael@0: } \ michael@0: is(content.window.top, content.window, 'top'); \ michael@0: is(content.window.content, content.window, 'content'); \ michael@0: is(content.window.parent, content.window, 'parent'); \ michael@0: is(content.window.frameElement, null, 'frameElement'); \ michael@0: var innerIframe = content.document.getElementById('inner-iframe'); \ michael@0: var innerWindow = innerIframe.contentWindow; \ michael@0: is(innerWindow.top, content.window, 'inner top'); \ michael@0: is(innerWindow.content, content.window, 'inner content'); \ michael@0: is(innerWindow.parent, content.window, 'inner parent'); \ michael@0: is(innerWindow.frameElement, innerIframe, 'inner frameElement');" michael@0: michael@0: var mm = SpecialPowers.getBrowserFrameMessageManager(iframe); michael@0: michael@0: function onRecvTestPass(msg) { michael@0: numMsgReceived++; michael@0: ok(true, msg.json); michael@0: } michael@0: mm.addMessageListener('test:test-pass', onRecvTestPass); michael@0: michael@0: function onRecvTestFail(msg) { michael@0: numMsgReceived++; michael@0: ok(false, msg.json); michael@0: } michael@0: mm.addMessageListener('test:test-fail', onRecvTestFail); michael@0: michael@0: mm.loadFrameScript(injectedScript, /* allowDelayedLoad = */ false); michael@0: michael@0: waitForMessages(6); michael@0: } michael@0: michael@0: function waitForMessages(num) { michael@0: if (numMsgReceived < num) { michael@0: SimpleTest.executeSoon(function() { waitForMessages(num); }); michael@0: return; michael@0: } michael@0: michael@0: SimpleTest.finish(); michael@0: } michael@0: michael@0: addEventListener('testready', runTest);