Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / html / imports / resources / import-helpers.js
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 requestAnimationFrame(function() { finishJSTest(); }, 0);
12         return runSingleTest(options);
13     }
14
15     function runSingleTest(options)
16     {
17         var interval = 1;
18         var ntries = 8;
19         function checkWhenReady()
20         {
21             if (--ntries < 0) {
22                 testFailed("Timed out");
23                 return finishJSTest();
24             }
25
26             interval *= 2;
27             if (!options.ready())
28                 return setTimeout(checkWhenReady, interval);
29
30             options.test();
31             return runNext();
32         }
33
34         debug(options.description);
35         if (options.setup)
36             options.setup();
37         checkWhenReady();
38     }
39
40     window.setTimeout(runNext, 0);
41 }
42
43 function createPlaceholder()
44 {
45     var link = document.createElement("link");
46     link.setAttribute("href", "resources/placeholder.html");
47     link.setAttribute("rel", "import");
48     document.head.appendChild(link);
49     return link;
50 }