blob: 67bb1f1a6b00601e574f6403d9d222ffd09e1ce0 [file] [log] [blame]
Torne (Richard Coles)5c87bf82012-11-14 11:46:17 +00001<html>
2<!--
3This test case is used to prove HTMLParserScheduler should be suspended when page loading is deferred. See https://bugs.webkit.org/show_bug.cgi?id=48077.
4However, this test case can work only when customHTMLTokenizerChunkSize() is equal to or smaller than 256. To reproduce the problem with other settings, try
5adding more tags into body.
6
7To use the test case, open it in browser, when the alert shows up, wait for a few seconds, and close the alert. If it shows "Error detected", that means the problem exists.
8-->
9<script>
10var showingAlert = false;
11
12function log(message, replace)
13{
14 if (replace)
15 document.getElementById("result").innerHTML = message;
16 else
17 document.getElementById("result").innerHTML += "<br>" + message;
18}
19
20function showAlert()
21{
22 showingAlert = true;
23 alert("Test");
24 showingAlert = false;
25}
26
27// Insert a script element so the script will be executed when the resource is loaded.
28function insertScript()
29{
30 var head = document.getElementsByTagName("head")[0];
31 var myScript = document.createElement('script');
32 myScript.type = 'text/javascript';
33 myScript.src = 'resources/bugzilla-48077.js';
34 head.appendChild(myScript);
35}
36function check()
37{
38 // Check JS re-entrancy. If showingAlert is true, we are still in showAlert().
39 if (showingAlert)
40 log("Error detected!", false);
41 else
42 log("No error detected.", false);
43}
44
45// Do a time consuming job so we can make HTML parser run over time limit.
46function logTime()
47{
48 // time consuming job;
49 var startTime = new Date();
50 do {
51 var currentTime = new Date();
52 log(currentTime, true);
53 } while (currentTime - startTime < 1000);
54}
55</script>
56<body>
57<p id="result"></p>
58
59<script>
60insertScript();
61</script>
62
63<!-- Time consuming job to make HTML parser run over chunk time limit -->
64<script>
65logTime();
66</script>
67
68<!-- Lots of tags to make HTML parser run over chunk size limit -->
69<a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a>
70
71<!-- Time consuming job to make HTML parser run over chunk time limit -->
72<script>
73logTime();
74</script>
75
76<!-- Lots of tags to make HTML parser run over chunk size limit -->
77<a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a><a>1</a>
78
79
80<script>
81check();
82</script>
83
84
85
86</body>
87</html>