michael@0: michael@0: michael@0: michael@0:
michael@0:michael@0: \n" + michael@0: "\n" + michael@0: "michael@0:" + description + "
\n" + michael@0: ""; michael@0: michael@0: return contents; michael@0: } michael@0: michael@0: function finish() michael@0: { michael@0: SimpleTest.finish(); michael@0: } michael@0: michael@0: var xhtmlns = "http://www.w3.org/1999/xhtml"; michael@0: michael@0: function insert(el) michael@0: { michael@0: var content = $("content"); michael@0: content.parentNode.insertBefore(el, content); michael@0: } michael@0: michael@0: function setupBlank() michael@0: { michael@0: var aboutBlankFrame = document.createElementNS(xhtmlns, "iframe"); michael@0: aboutBlankFrame.setAttribute("src", "about:blank"); michael@0: insert(aboutBlankFrame); michael@0: michael@0: aboutBlankWindow = aboutBlankFrame.contentWindow; michael@0: var doc = aboutBlankWindow.document; michael@0: doc.open(); michael@0: doc.write(getContents("This was about:blank #1", "about:blank-response")); michael@0: doc.close(); michael@0: michael@0: // I don't believe anything guarantees sync parsing, so we have to wait for michael@0: // the new window to poke us to actually do the test. :-\ michael@0: } michael@0: michael@0: function setupBlank2() michael@0: { michael@0: var aboutBlank2Frame = document.createElementNS(xhtmlns, "iframe"); michael@0: aboutBlank2Frame.addEventListener("load", nextTest, false); michael@0: aboutBlank2Frame.setAttribute("src", "about:blank"); michael@0: michael@0: insert(aboutBlank2Frame); michael@0: } michael@0: michael@0: // Could use window.btoa here, but that's not standardized, and we want to be michael@0: // able to run these tests against browsers that don't support it. michael@0: var dataURI = "data:text/html;base64," + michael@0: b64(getContents("A data: URL", "data-response")); michael@0: michael@0: function setupData() michael@0: { michael@0: var dataFrame = document.createElementNS(xhtmlns, "iframe"); michael@0: dataFrame.setAttribute("src", dataURI); michael@0: insert(dataFrame); michael@0: michael@0: dataWindow = dataFrame.contentWindow; michael@0: michael@0: // ...and wait again for the window to load... michael@0: } michael@0: michael@0: var count = 0; michael@0: function nextTest() michael@0: { michael@0: switch (count++) michael@0: { michael@0: case 0: michael@0: testBlank(); michael@0: break; michael@0: michael@0: case 1: michael@0: testBlank2(); michael@0: break; michael@0: michael@0: case 2: michael@0: testData(); michael@0: break; michael@0: michael@0: default: michael@0: ok(false, "unreached"); michael@0: break; michael@0: } michael@0: } michael@0: michael@0: function testBlank() michael@0: { michael@0: aboutBlankWindow.postMessage("from-opener", "http://mochi.test:8888"); michael@0: } michael@0: michael@0: function testBlank2() michael@0: { michael@0: // For some reason we can't access this across browsers prior to the iframe michael@0: // loading, so set its value here. michael@0: aboutBlank2Window = window.frames[1]; michael@0: michael@0: var doc = aboutBlank2Window.document; michael@0: michael@0: doc.body.textContent = "This was about:blank #2"; michael@0: michael@0: var script = doc.createElement("script"); michael@0: script.textContent = michael@0: "window.parent.postMessage('about:blank2-response', " + michael@0: " 'http://mochi.test:8888');"; michael@0: doc.body.appendChild(script); michael@0: } michael@0: michael@0: function testData() michael@0: { michael@0: dataWindow.postMessage("from-opener", "http://mochi.test:8888"); michael@0: } michael@0: michael@0: window.addEventListener("message", messageReceiver, false); michael@0: michael@0: addLoadEvent(setupBlank); michael@0: ]]> michael@0: