OLD | NEW |
(Empty) | |
| 1 |
| 2 |
| 3 function waitAndTest(tests) |
| 4 { |
| 5 window.jsTestIsAsync = true; |
| 6 |
| 7 function runNext() |
| 8 { |
| 9 var options = tests.shift(); |
| 10 if (!options) |
| 11 return finishJSTest(); |
| 12 return runSingleTest(options); |
| 13 } |
| 14 |
| 15 function runSingleTest(options) |
| 16 { |
| 17 var ntries = 10; |
| 18 function checkWhenReady() |
| 19 { |
| 20 if (--ntries < 0) { |
| 21 testFailed("Timed out"); |
| 22 return finishJSTest(); |
| 23 } |
| 24 |
| 25 if (!options.ready()) |
| 26 return setTimeout(checkWhenReady, 0); |
| 27 |
| 28 options.test(); |
| 29 return runNext(); |
| 30 } |
| 31 |
| 32 debug(options.description); |
| 33 if (options.setup) |
| 34 options.setup(); |
| 35 checkWhenReady(); |
| 36 } |
| 37 |
| 38 window.setTimeout(runNext, 0); |
| 39 } |
| 40 |
| 41 function createPlaceholder() |
| 42 { |
| 43 var link = document.createElement("link"); |
| 44 link.setAttribute("href", "resources/placeholder.html"); |
| 45 link.setAttribute("rel", "import"); |
| 46 document.head.appendChild(link); |
| 47 return link; |
| 48 } |
OLD | NEW |