| OLD | NEW |
| (Empty) |
| 1 <body> | |
| 2 <pre id="log"></pre> | |
| 3 <script> | |
| 4 function log(msg) { | |
| 5 document.getElementById("log").textContent += msg + "\n"; | |
| 6 } | |
| 7 | |
| 8 function getText(iframe) { | |
| 9 return iframe.contentDocument.documentElement.textContent; | |
| 10 } | |
| 11 | |
| 12 var testIndex = 0; | |
| 13 | |
| 14 function runTest(name, testFunction) { | |
| 15 var iframe = document.createElement('iframe'); | |
| 16 document.body.appendChild(iframe); | |
| 17 | |
| 18 var expectedText = "foo " + testIndex; | |
| 19 iframe.onerror = function() { | |
| 20 log(name + ' error ' + getText(iframe)); | |
| 21 } | |
| 22 testFunction(iframe, expectedText); | |
| 23 var resultText = getText(iframe); | |
| 24 if (resultText == expectedText) { | |
| 25 log(' sync : ' + name); | |
| 26 iframe.parentNode.removeChild(iframe); | |
| 27 nextTest(); | |
| 28 } else { | |
| 29 iframe.onload = function() { | |
| 30 log('ASYNC : ' + name); | |
| 31 iframe.parentNode.removeChild(iframe); | |
| 32 nextTest(); | |
| 33 } | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 var tests = [ | |
| 38 { name: 'src = javascript:"content"', testFunction: function(iframe, expecte
dText) { iframe.src = 'javascript: "' + expectedText + '"'} }, | |
| 39 { name: 'src = data:text/html,content', testFunction: function(iframe, expec
tedText) { iframe.src = 'data:text/html,"' + expectedText + '"'} }, | |
| 40 { name: 'srcdoc = "content"', testFunction: function(iframe, expectedText) {
iframe.src = 'data:text/html,"' + expectedText + '"'} }, | |
| 41 ]; | |
| 42 | |
| 43 if (window.testRunner) { | |
| 44 testRunner.dumpAsText(); | |
| 45 testRunner.waitUntilDone(); | |
| 46 } | |
| 47 | |
| 48 function nextTest() { | |
| 49 if (testIndex >= tests.length) { | |
| 50 log("done"); | |
| 51 if (window.testRunner) | |
| 52 testRunner.notifyDone(); | |
| 53 return; | |
| 54 } | |
| 55 var test = tests[testIndex++]; | |
| 56 runTest(test.name, test.testFunction); | |
| 57 } | |
| 58 nextTest(); | |
| 59 </script> | |
| OLD | NEW |