Skip tests on arm/mips that time out now we're running on CLoop
[WebKit-https.git] / LayoutTests / html5lib / webkit-resumer.html
1 <title>html5lib test runner</title>
2 <script>
3 // Copyright (c) 2008 Geoffrey Sneddon
4 // 
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 // 
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 // 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 </script>
23 <script src=../resources/dump-as-markup.js></script>
24 <style>
25 .overview:hover {
26 background: #ccc;
27 }
28 iframe {
29 display: none;
30 }
31 </style>
32 <p>Script did not run</p>
33 <iframe></iframe>
34 <script>
35 if (window.testRunner)
36     testRunner.waitUntilDone();
37 Markup.noAutoDump();
38 Markup.useHTML5libOutputFormat();
39
40 var test_files = [
41         // 'resources/tests1.dat',
42         // 'resources/tests2.dat',
43         // 'resources/tests3.dat',
44         // 'resources/tests4.dat',
45         // 'resources/tests5.dat',
46         // 'resources/tests6.dat',
47         // 'resources/tests7.dat',
48         // 'resources/tests8.dat',
49         // 'resources/tests9.dat',
50         // 'resources/tests10.dat',
51         // 'resources/tests11.dat',
52         // 'resources/tests12.dat',
53         // 'resources/tests14.dat',
54         // 'resources/tests15.dat',
55         // 'resources/tests16.dat',
56         'resources/webkit01.dat',
57         // 'resources/doctype01.dat',
58         // 'resources/scriptdata01.dat',
59         // 'resources/entities01.dat',
60         // 'resources/comments01.dat'
61     ],
62     tests = [],
63     iframe = document.getElementsByTagName("iframe")[0],
64     stat = document.getElementsByTagName("p")[0].firstChild,
65     file = "",
66     test_number = 1,
67     subtest_number = 0,
68     fail_list = [],
69     log = "";
70
71 iframe.contentWindow.document.open()
72 iframe.contentWindow.document.write("Test");
73 iframe.contentWindow.document.close();
74 var write = iframe.contentWindow.document.lastChild.lastChild.lastChild !== null;
75 var ignoreTitle = iframe.contentWindow.document.getElementsByTagName("title")[0] !== undefined;
76
77 window.onload = function()
78 {
79     stat.data = "Running";
80     run();
81 }
82
83 function run()
84 {
85     var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
86     if (file = test_files.shift())
87     {
88         stat.data = "Retriving " + file;
89         test_number = 1;
90         fail_list = [];
91         log = "";
92         xhr.open("GET", file);
93         xhr.onreadystatechange = function()
94         {
95             if (xhr.readyState === 4)
96             {
97                 tests = xhr.responseText.split(/(?:^|\n\n)#data\n/);
98                 tests.shift();
99                 test();
100             }
101         }
102         xhr.send(null);
103     } else {
104         if (window.testRunner)
105             testRunner.notifyDone();
106     }
107 }
108
109 function test()
110 {
111     var input, errorsStart, fragmentStart, contextElement, domStart, dom;
112     if (data = tests.shift())
113     {
114         subtest_number = 0;
115         stat.data = "Running test " + test_number + " of " + (test_number + tests.length) + " in " + file;
116         errorsStart = data.indexOf("\n#errors\n");
117         if (errorsStart !== -1)
118         {
119             input = data.substring(0, errorsStart);
120             fragmentStart = data.indexOf("\n#document-fragment\n")
121             domStart = data.indexOf("\n#document\n")
122             if (fragmentStart !== -1)
123             {
124                 contextElement = data.substring(fragmentStart + 20, domStart);
125             }
126             if (domStart !== -1)
127             {
128                 dom = data.substring(domStart + 11);
129                 if (dom.substring(dom.length - 1) === "\n")
130                 {
131                     dom = dom.substring(0, dom.length - 1);
132                 }
133                 run_test(input, contextElement, dom);
134                 return;
135             }
136         }
137         alert("Invalid test: " + data);
138         test();
139         return;
140     }
141     else
142     {
143         stat.data = "Finished running " + file;
144         var overview = document.createElement("p");
145         if (fail_list.length)
146         {
147             overview.innerHTML = file + ":<br>" + fail_list.join("<br>");
148             overview.className = "overview";
149             overview.title = "Click for more details";
150             overview.onclick = function()
151             {
152                 this.nextSibling.style.display = this.nextSibling.style.display == "none" ? "block" : "none";
153             }
154             var detail = document.createElement("pre");
155             detail.appendChild(document.createTextNode(log.substring(2)));
156             detail.style.display = "none";
157             document.body.appendChild(overview);
158             document.body.appendChild(detail);
159         }
160         else
161         {
162             overview.innerHTML = file + ": PASS";
163             document.body.appendChild(overview);
164         }
165         stat.data = "";
166         run();
167     }
168 }
169
170 function run_test(input, contextElement, expected)
171 {
172     while (++subtest_number < input.length) {
173         lower_input = input.substring(0, subtest_number);
174         upper_input = input.substring(subtest_number, input.length);
175         if (contextElement)
176         {
177             var element = document.createElement(contextElement);
178             try
179             {
180                 element.innerHTML = input;
181             }
182             catch(e) {}
183             process_result(input, element, expected);
184         }
185         else if (write)
186         {
187             iframe.contentWindow.document.open();
188             try
189             {
190                 iframe.contentWindow.document.write(lower_input);
191                 iframe.contentWindow.document.write(upper_input);
192             }
193             catch(e) {}
194             iframe.contentWindow.document.close();
195             if (ignoreTitle)
196             {
197                 var title = iframe.contentWindow.document.getElementsByTagName("title")[0];
198                 if (!title.innerHTML)
199                 {
200                     title.parentElement.removeChild(title);
201                 }
202             }
203             process_result(input, iframe.contentWindow.document, expected);
204         }
205         else
206         {
207             iframe.onload = function()
208             {
209                 if (ignoreTitle)
210                 {
211                     var title = iframe.contentWindow.document.getElementsByTagName("title")[0];
212                     if (!title.innerHTML)
213                     {
214                         title.parentElement.removeChild(title);
215                     }
216                 }
217                 process_result(input, iframe.contentWindow.document, expected, true);
218             }
219             iframe.src = "data:text/html," + encodeURIComponent(input);
220             break;
221         }
222     }
223     test();
224 }
225
226 function process_result(input, result, expected, async)
227 {
228     result = Markup.get(result);
229     if (result !== expected)
230     {
231         fail_list.push(test_number + "." + subtest_number);
232         log += "\n\nTest " + (test_number) + " of " + (test_number + tests.length) + " in " + file + " failed. Input:\n" + input + "\nGot:\n" + result + "\nExpected:\n" + expected;
233     }
234     test_number++;
235     if (async)
236         test();
237 }
238 </script>