| <html> |
| <!-- |
| This 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. |
| However, this test case can work only when customHTMLTokenizerChunkSize() is equal to or smaller than 256. To reproduce the problem with other settings, try |
| adding more tags into body. |
| |
| To 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. |
| --> |
| <script> |
| var showingAlert = false; |
| |
| function log(message, replace) |
| { |
| if (replace) |
| document.getElementById("result").innerHTML = message; |
| else |
| document.getElementById("result").innerHTML += "<br>" + message; |
| } |
| |
| function showAlert() |
| { |
| showingAlert = true; |
| alert("Test"); |
| showingAlert = false; |
| } |
| |
| // Insert a script element so the script will be executed when the resource is loaded. |
| function insertScript() |
| { |
| var head = document.getElementsByTagName("head")[0]; |
| var myScript = document.createElement('script'); |
| myScript.type = 'text/javascript'; |
| myScript.src = 'resources/bugzilla-48077.js'; |
| head.appendChild(myScript); |
| } |
| function check() |
| { |
| // Check JS re-entrancy. If showingAlert is true, we are still in showAlert(). |
| if (showingAlert) |
| log("Error detected!", false); |
| else |
| log("No error detected.", false); |
| } |
| |
| // Do a time consuming job so we can make HTML parser run over time limit. |
| function logTime() |
| { |
| // time consuming job; |
| var startTime = new Date(); |
| do { |
| var currentTime = new Date(); |
| log(currentTime, true); |
| } while (currentTime - startTime < 1000); |
| } |
| </script> |
| <body> |
| <p id="result"></p> |
| |
| <script> |
| insertScript(); |
| </script> |
| |
| <!-- Time consuming job to make HTML parser run over chunk time limit --> |
| <script> |
| logTime(); |
| </script> |
| |
| <!-- Lots of tags to make HTML parser run over chunk size limit --> |
| <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> |
| |
| <!-- Time consuming job to make HTML parser run over chunk time limit --> |
| <script> |
| logTime(); |
| </script> |
| |
| <!-- Lots of tags to make HTML parser run over chunk size limit --> |
| <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> |
| |
| |
| <script> |
| check(); |
| </script> |
| |
| |
| |
| </body> |
| </html> |