Reviewed by Adam Barth.
Rewrite a bunch of XHR-based tests to use waitUntilDone()/notifyDone().
https://bugs.webkit.org/show_bug.cgi?id=62066
* fast/xmlhttprequest/xmlhttprequest-gc.html:
* fast/xmlhttprequest/xmlhttprequest-get.xhtml:
* fast/xmlhttprequest/xmlhttprequest-html-response-encoding.html:
* html5lib/runner.html:
* html5lib/webkit-resumer.html:
* http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache.html:
* http/tests/xmlhttprequest/access-control-basic-non-simple-allow-async.html:
* http/tests/xmlhttprequest/access-control-preflight-async-header-denied.html:
* http/tests/xmlhttprequest/access-control-preflight-async-method-denied.html:
* http/tests/xmlhttprequest/access-control-preflight-async-not-supported.html:
* http/tests/xmlhttprequest/cross-origin-preflight-get.html:
* http/tests/xmlhttprequest/event-listener-gc.html:
* http/tests/xmlhttprequest/interactive-state.html:
* http/tests/xmlhttprequest/resources/uri-resolution-opera-open-004-iframe.html:
* http/tests/xmlhttprequest/resources/uri-resolution-opera-open-005-iframe.html:
* http/tests/xmlhttprequest/resources/uri-resolution-opera-open-006-iframe.html:
* http/tests/xmlhttprequest/resources/uri-resolution-opera-open-007-iframe.html:
* http/tests/xmlhttprequest/resources/uri-resolution-opera-open-008-iframe.html:
* http/tests/xmlhttprequest/resources/uri-resolution-opera-open-009-iframe.html:
* http/tests/xmlhttprequest/resources/uri-resolution-opera-open-010-iframe.html:
* http/tests/xmlhttprequest/response-encoding.html:
* http/tests/xmlhttprequest/simple-cross-origin-progress-events.html:
* http/tests/xmlhttprequest/uri-resolution-opera-open-004.html:
* http/tests/xmlhttprequest/uri-resolution-opera-open-005.html:
* http/tests/xmlhttprequest/uri-resolution-opera-open-006.html:
* http/tests/xmlhttprequest/uri-resolution-opera-open-007.html:
* http/tests/xmlhttprequest/uri-resolution-opera-open-008.html:
* http/tests/xmlhttprequest/uri-resolution-opera-open-009.html:
* http/tests/xmlhttprequest/uri-resolution-opera-open-010.html:
* http/tests/xmlhttprequest/web-apps/001.html:
* http/tests/xmlhttprequest/xmlhttprequest-50ms-download-dispatch.html:
* http/tests/xmlhttprequest/xmlhttprequest-crlf-getAllResponseHeader.html:
* http/tests/xmlhttprequest/xmlhttprequest-unsafe-redirect.html:
* http/tests/xmlhttprequest/zero-length-response.html:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@88709
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-06-13 Nate Chapin <japhet@chromium.org>
+
+ Reviewed by Adam Barth.
+
+ Rewrite a bunch of XHR-based tests to use waitUntilDone()/notifyDone().
+ https://bugs.webkit.org/show_bug.cgi?id=62066
+
+ * fast/xmlhttprequest/xmlhttprequest-gc.html:
+ * fast/xmlhttprequest/xmlhttprequest-get.xhtml:
+ * fast/xmlhttprequest/xmlhttprequest-html-response-encoding.html:
+ * html5lib/runner.html:
+ * html5lib/webkit-resumer.html:
+ * http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache.html:
+ * http/tests/xmlhttprequest/access-control-basic-non-simple-allow-async.html:
+ * http/tests/xmlhttprequest/access-control-preflight-async-header-denied.html:
+ * http/tests/xmlhttprequest/access-control-preflight-async-method-denied.html:
+ * http/tests/xmlhttprequest/access-control-preflight-async-not-supported.html:
+ * http/tests/xmlhttprequest/cross-origin-preflight-get.html:
+ * http/tests/xmlhttprequest/event-listener-gc.html:
+ * http/tests/xmlhttprequest/interactive-state.html:
+ * http/tests/xmlhttprequest/resources/uri-resolution-opera-open-004-iframe.html:
+ * http/tests/xmlhttprequest/resources/uri-resolution-opera-open-005-iframe.html:
+ * http/tests/xmlhttprequest/resources/uri-resolution-opera-open-006-iframe.html:
+ * http/tests/xmlhttprequest/resources/uri-resolution-opera-open-007-iframe.html:
+ * http/tests/xmlhttprequest/resources/uri-resolution-opera-open-008-iframe.html:
+ * http/tests/xmlhttprequest/resources/uri-resolution-opera-open-009-iframe.html:
+ * http/tests/xmlhttprequest/resources/uri-resolution-opera-open-010-iframe.html:
+ * http/tests/xmlhttprequest/response-encoding.html:
+ * http/tests/xmlhttprequest/simple-cross-origin-progress-events.html:
+ * http/tests/xmlhttprequest/uri-resolution-opera-open-004.html:
+ * http/tests/xmlhttprequest/uri-resolution-opera-open-005.html:
+ * http/tests/xmlhttprequest/uri-resolution-opera-open-006.html:
+ * http/tests/xmlhttprequest/uri-resolution-opera-open-007.html:
+ * http/tests/xmlhttprequest/uri-resolution-opera-open-008.html:
+ * http/tests/xmlhttprequest/uri-resolution-opera-open-009.html:
+ * http/tests/xmlhttprequest/uri-resolution-opera-open-010.html:
+ * http/tests/xmlhttprequest/web-apps/001.html:
+ * http/tests/xmlhttprequest/xmlhttprequest-50ms-download-dispatch.html:
+ * http/tests/xmlhttprequest/xmlhttprequest-crlf-getAllResponseHeader.html:
+ * http/tests/xmlhttprequest/xmlhttprequest-unsafe-redirect.html:
+ * http/tests/xmlhttprequest/zero-length-response.html:
+
2011-06-13 Mark Pilgrim <pilgrim@chromium.org>
Reviewed by Eric Seidel.
<script>
function stateChange() {
document.write(this.foo + '<br>');
+ if (this.readyState == 4) {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
function collectGarbage() {
xhr = null;
collectGarbage();
-
- if (window.layoutTestController)
- layoutTestController.notifyDone();
}
</script>
<script type="text/javascript">
var p = new XMLHttpRequest();
-if (window.layoutTestController)
+if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
function myfunc(e)
{
document.getElementById("id7").firstChild.nodeValue =
"Event object: " + e + "\n" +
"Event properties:\n" + eventProperties;
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
p.onload = myfunc;
XMLHttpRequest doesn't use a correct content type for file:// URLs.</p>
<script>
- if (window.layoutTestController)
+ if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
var console_messages = document.createElement("ol");
document.body.appendChild(console_messages);
}
function processStateChange(){
- if (req.readyState == 4)
- log("Async: HTML, charset determined by a META: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
+ if (req.readyState == 4) {
+ log("Async: HTML, charset determined by a META: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
try {
<p>Script did not run</p>
<iframe></iframe>
<script>
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
Markup.noAutoDump();
Markup.useHTML5libOutputFormat();
}
}
xhr.send(null);
+ } else {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
}
<p>Script did not run</p>
<iframe></iframe>
<script>
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
Markup.noAutoDump();
Markup.useHTML5libOutputFormat();
}
}
xhr.send(null);
+ } else {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
}
}
function processStateChange() {
- if (xhr.readyState == 1) {
+ if (xhr.readyState == 1)
log("PASS");
+ else if (xhr.readyState == 4) {
if (window.layoutTestController)
layoutTestController.notifyDone();
}
document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
}
-if (window.layoutTestController)
+if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
function processStateChange()
{
document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
}
-if (window.layoutTestController)
+if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
(function() {
var xhr = new XMLHttpRequest();
}
log(xhr.responseText);
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
xhr.onreadystatechange = function() {
document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
}
-if (window.layoutTestController)
+if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
(function() {
var xhr = new XMLHttpRequest();
}
log(xhr.responseText);
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
xhr.onreadystatechange = function() {
document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
}
-if (window.layoutTestController)
+if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
(function() {
var xhr = new XMLHttpRequest();
}
log(xhr.responseText);
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
xhr.onreadystatechange = function() {
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
}
function log(message)
xhr.onerror = function() { log("onerror") }
xhr.onload = function() {
log(xhr.responseText);
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
xhr.send(null);
}
new String("");
}
-function processStateChange()
+function processStateChange(e)
{
if (didCollect)
write("PASS: event handler fired after garbage collection.\n");
+ if (e.target.readyState == 4) {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
function test()
{
- if (window.layoutTestController)
+ if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
var request = new XMLHttpRequest();
request.onreadystatechange = processStateChange;
GMAIL: XMLHttpRequest does not correctly report "Interactive" state on receipt of load data.</p>
<script>
- if (window.layoutTestController)
+ if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
var console_messages = document.createElement("ol");
document.body.appendChild(console_messages);
}
function processStateChange(){
- if (req.readyState == 3)
- ++count;
- else if (req.readyState == 4)
- log((count > 1) ? "SUCCESS" : "FAILURE (count = " + count + ")");
+ if (req.readyState == 3)
+ ++count;
+ else if (req.readyState == 4) {
+ log((count > 1) ? "SUCCESS" : "FAILURE (count = " + count + ")");
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
// start async steps
function test(client)
{
client.onreadystatechange = function() {
- if (client.readyState == 4)
- p.firstChild.data = client.responseText;
+ if (client.readyState == 4) {
+ p.firstChild.data = client.responseText;
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
- client.send("");
+ client.send("");
}
</script>
</body>
function test(client)
{
client.onreadystatechange = function() {
- if (client.readyState == 4)
- p.firstChild.data = client.responseText;
+ if (client.readyState == 4) {
+ p.firstChild.data = client.responseText;
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
- client.open("GET", "test-uri-resolution.txt");
- client.send("");
+ client.open("GET", "test-uri-resolution.txt");
+ client.send("");
}
</script>
</body>
function test(client)
{
client.onreadystatechange = function() {
- if (client.readyState == 4)
- p.firstChild.data = client.responseText;
+ if (client.readyState == 4) {
+ p.firstChild.data = client.responseText;
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
}
</script>
function test(client)
{
client.onreadystatechange = function() {
- if (client.readyState == 4)
- p.firstChild.data = client.responseText;
+ if (client.readyState == 4) {
+ p.firstChild.data = client.responseText;
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
client.open("GET", "test-uri-resolution.txt");
parent.send(client);
function test(client)
{
p.firstChild.data = client.responseText;
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
</script>
</body>
function client()
{
var client = new XMLHttpRequest();
- client.onreadystatechange = function()
- {
- if (client.readyState == 4)
+ client.onreadystatechange = function() {
+ if (client.readyState == 4) {
p.firstChild.data = client.responseText;
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
client.open("GET", "test-uri-resolution.txt");
return client;
function client()
{
var client = new XMLHttpRequest();
- client.onreadystatechange = function()
- {
- if (client.readyState == 4)
+ client.onreadystatechange = function() {
+ if (client.readyState == 4) {
p.firstChild.data = client.responseText;
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
client.open("GET", "test-uri-resolution.txt");
client.send("");
- correctly determine the encoding of XMLHttpRequest responses.</p>
<script>
- if (window.layoutTestController)
+ if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
var console_messages = document.createElement("ol");
document.body.appendChild(console_messages);
get('resources/utf-8-no-charset.html', true);
} else if (asyncStep == 11) {
log("Async: HTML, UTF-8 as default: " + req.responseText.replace(/\s/g, "").replace(/.*<body>(.*)<\/body>.*/, "$1"));
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
} else {
log("Error loading URL: status " + req.status);
xhr.send(stringToSend);
xhr.upload.onprogress = uploadProgress;
xhr.upload.onload = function() { log("FAIL: upload.onload") }
- xhr.upload.onerror = function() { log("upload.onerror (expected)") }
+ xhr.upload.onerror = function() {
+ log("upload.onerror (expected)")
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
xhr.onerror = function() {
log("onerror (expected)");
log("Response length: " + xhr.responseText.length);
- if (window.layoutTestController)
- layoutTestController.notifyDone();
}
xhr.onload = function() {
log("onload");
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
+ layoutTestController.waitUntilDone();
}
var client = new frame.contentWindow.XMLHttpRequest();
client.open("GET", "test-uri-resolution.txt");
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
+ layoutTestController.waitUntilDone();
}
var client = new frame.contentWindow.XMLHttpRequest();
frame.contentWindow.test(client);
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
+ layoutTestController.waitUntilDone();
}
var client = new frame.contentWindow.XMLHttpRequest();
frame.contentWindow.test(client);
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
+ layoutTestController.waitUntilDone();
}
var client = new frame.contentWindow.XMLHttpRequest();
frame.contentWindow.test(client);
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
+ layoutTestController.waitUntilDone();
}
var client = frame.contentWindow.client();
client.onreadystatechange = function()
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
+ layoutTestController.waitUntilDone();
}
var client = frame.contentWindow.client();
client.send("");
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.dumpChildFramesAsText();
+ layoutTestController.waitUntilDone();
}
</script>
<p><iframe src="resources/uri-resolution-opera-open-010-iframe.html" onload="this.contentWindow.client()"></iframe></p>
<body>
<p>Script did not run.</p>
<script type="text/javascript">
- if (window.layoutTestController)
+ if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
var p = document.getElementsByTagName('p')[0];
p.firstChild.data = 'Test script started.';
// window.XMLHttpRequest = function () { return new ActiveXObject("Microsoft.XMLHTTP"); }
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
- if (r.readyState == 4)
+ if (r.readyState == 4) {
p.firstChild.data = r.responseText;
- else
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ } else
p.firstChild.data = 'Test in progress (' + r.readyState + '/4)';
};
r.open('GET', '001-test.cgi', true);
<p id="console"></p>
<script type="text/javascript">
-if (window.layoutTestController)
+if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
function log(message)
{
document.getElementById("console").appendChild(document.createElement("br"));
}
+var testsCompleted = 0;
+
function test(iteration, delay, compare, testDescription)
{
var count = 0;
sawReadyStateDONE = true;
var passed = compare(count, iteration);
log(passed ? "PASSED" : "FAILED (count was " + count + ") for " + testDescription);
+ ++testsCompleted;
+ if (testsCompleted == 5) {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
}
<p>Test page for the <a href="http://bugs.webkit.org/show_bug.cgi?id=14898">bug 14898</a> : XMLHttpRequest.getAllResponseHeaders should separate headers with CRLF</p>
<script type="text/javascript">
-if (window.layoutTestController)
+if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+}
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
} else {
document.body.appendChild(document.createTextNode("PASS"));
}
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
}
}
xhr.open("GET", "testPage.html", true);
function onReqreadystatechange()
{
log('readyState change ' + req.readyState);
- if (req.readyState == 4)
- didReadFile();
}
function onReqAbort()
log ('Async XHR started.');
req = new XMLHttpRequest();
req.onreadystatechange = onReqreadystatechange;
+ req.onload = didReadFile;
req.onerror = onReqError;
req.onabort = onReqAbort;
req.open('GET', '/xmlhttprequest/resources/redirect.php?url=http://localhost:8080/xmlhttprequest/resources/forbidden.txt');
- zero-length responses to XMLHTTPRequest mishandled.</p>
<script>
- if (window.layoutTestController)
+ if (window.layoutTestController) {
layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ }
var console_messages = document.createElement("ul");
document.body.appendChild(console_messages);
function processStateChange() {
log("onreadystatechange: " + stateName(req.readyState));
dumpResponse();
+ if (req.readyState == 4) {
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+ }
}
// start async steps