Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / loader / iframe-sync-loads.html
blob34b3177ad2892ef773d22998e8a76a6b078b07bd
1 <body>
2 <pre id="log"></pre>
3 <script>
4 function log(msg) {
5 document.getElementById("log").textContent += msg + "\n";
8 function getText(iframe) {
9 return iframe.contentDocument.documentElement.textContent;
12 var testIndex = 0;
14 function runTest(name, testFunction) {
15 var iframe = document.createElement('iframe');
16 document.body.appendChild(iframe);
18 var expectedText = "foo " + testIndex;
19 iframe.onerror = function() {
20 log(name + ' error ' + getText(iframe));
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();
37 var tests = [
38 { name: 'src = javascript:"content"', testFunction: function(iframe, expectedText) { iframe.src = 'javascript: "' + expectedText + '"'} },
39 { name: 'src = data:text/html,content', testFunction: function(iframe, expectedText) { iframe.src = 'data:text/html,"' + expectedText + '"'} },
40 { name: 'srcdoc = "content"', testFunction: function(iframe, expectedText) { iframe.src = 'data:text/html,"' + expectedText + '"'} },
43 if (window.testRunner) {
44 testRunner.dumpAsText();
45 testRunner.waitUntilDone();
48 function nextTest() {
49 if (testIndex >= tests.length) {
50 log("done");
51 if (window.testRunner)
52 testRunner.notifyDone();
53 return;
55 var test = tests[testIndex++];
56 runTest(test.name, test.testFunction);
58 nextTest();
59 </script>