Mozilla Bug 387706

\n" +
    "\n" +
    "

" + description + "

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