5 document
.getElementById("log").textContent
+= msg
+ "\n";
8 function getText(iframe
) {
9 return iframe
.contentDocument
.documentElement
.textContent
;
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
);
29 iframe
.onload = function() {
30 log('ASYNC : ' + name
);
31 iframe
.parentNode
.removeChild(iframe
);
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();
49 if (testIndex
>= tests
.length
) {
51 if (window
.testRunner
)
52 testRunner
.notifyDone();
55 var test
= tests
[testIndex
++];
56 runTest(test
.name
, test
.testFunction
);