WebCore:
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2009 22:29:54 +0000 (22:29 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2009 22:29:54 +0000 (22:29 +0000)
2009-03-04  David Levin  <levin@chromium.org>

        Reviewed by Alexey Proskuryakov.

        Bug 24337: Assert when doing sync XHR in a worker for a cacheable response.
        <https://bugs.webkit.org/show_bug.cgi?id=24337>

        Tests: http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache.html
               http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found.html

        * loader/mac/ResourceLoaderMac.mm:
        (WebCore::ResourceLoader::willCacheResponse):
        An identifier is only asssigned if resource load callbacks are done.  So don't send
        willCacheResponse which uses identifier if resource load callbacks aren't being sent.

LayoutTests:

2009-03-04  David Levin  <levin@chromium.org>

        Reviewed by Alexey Proskuryakov.

        Bug 24337: Assert when doing sync XHR in a worker for a cacheable response.
        <https://bugs.webkit.org/show_bug.cgi?id=24337>

        * http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache-expected.txt: Added.
        * http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache.html: Added.
        * http/tests/xmlhttprequest/workers/resources/xmlhttprequest-file-not-found.js: Added.
        (log):
        (done):
        * http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found-expected.txt: Added.
        * http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41434 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/workers/resources/xmlhttprequest-file-not-found.js [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/loader/mac/ResourceLoaderMac.mm

index 0c417064e8e2b9eb7e23933bb9c562b7d32a37fb..c2338505c6e629704e52f1937a71ecc3f7b66b66 100644 (file)
@@ -1,3 +1,18 @@
+2009-03-04  David Levin  <levin@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Bug 24337: Assert when doing sync XHR in a worker for a cacheable response.
+        <https://bugs.webkit.org/show_bug.cgi?id=24337>
+
+        * http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache-expected.txt: Added.
+        * http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache.html: Added.
+        * http/tests/xmlhttprequest/workers/resources/xmlhttprequest-file-not-found.js: Added.
+        (log):
+        (done):
+        * http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found-expected.txt: Added.
+        * http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found.html: Added.
+
 2009-03-04  David Levin  <levin@chromium.org>
 
         Reviewed by Alexey Proskuryakov.
diff --git a/LayoutTests/http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache-expected.txt b/LayoutTests/http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache-expected.txt
new file mode 100644 (file)
index 0000000..2e175b9
--- /dev/null
@@ -0,0 +1,3 @@
+Test async xhr preflight cache denial. If this test passes, there should be a single PASS below.
+
+PASS
diff --git a/LayoutTests/http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache.html b/LayoutTests/http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache.html
new file mode 100644 (file)
index 0000000..b35e317
--- /dev/null
@@ -0,0 +1,38 @@
+<html>
+<body>
+<p>Test async xhr preflight cache denial.  If this test passes, there should be a single PASS below.</p>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+
+    var console_messages = document.createElement("ul");
+    document.body.appendChild(console_messages);
+
+    function log(message)
+    {
+        var item = document.createElement("li");
+        item.appendChild(document.createTextNode(message));
+        console_messages.appendChild(item);
+    }
+
+    xhr = new XMLHttpRequest;
+    xhr.onreadystatechange = processStateChange;
+    try {
+        xhr.open("FOO", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-denied.cgi");
+        xhr.send();
+    } catch (e) {
+        log("Got exception.");
+    }
+
+    function processStateChange() {
+        if (xhr.readyState == 1) {
+            log("PASS");
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        }
+    }
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/xmlhttprequest/workers/resources/xmlhttprequest-file-not-found.js b/LayoutTests/http/tests/xmlhttprequest/workers/resources/xmlhttprequest-file-not-found.js
new file mode 100644 (file)
index 0000000..07fea66
--- /dev/null
@@ -0,0 +1,18 @@
+function log(message)
+{
+    postMessage("log " + message);
+}
+
+function done()
+{
+    postMessage("DONE");
+}
+
+req = new XMLHttpRequest;
+try {
+    req.open("GET", "missing-file", false);
+    req.send();
+} catch (e) {
+    log("Exception received.");
+}
+done();
diff --git a/LayoutTests/http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found-expected.txt b/LayoutTests/http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found-expected.txt
new file mode 100644 (file)
index 0000000..1c041d9
--- /dev/null
@@ -0,0 +1,3 @@
+Request a file that isn't present on the server in XMLHttpRequest in a worker. If this test passes, there should be a single PASS below.
+
+PASS
diff --git a/LayoutTests/http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found.html b/LayoutTests/http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found.html
new file mode 100644 (file)
index 0000000..6037d65
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+<body>
+<p>Request a file that isn't present on the server in XMLHttpRequest in a worker.  If this test passes, there should be a single PASS below.</p>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+
+    var console_messages = document.createElement("ul");
+    document.body.appendChild(console_messages);
+
+    function log(message)
+    {
+        var item = document.createElement("li");
+        item.appendChild(document.createTextNode(message));
+        console_messages.appendChild(item);
+    }
+
+    var worker = new Worker('resources/xmlhttprequest-file-not-found.js');
+    worker.onmessage = function(evt)
+    {
+        if (/log .+/.test(evt.data))
+            log(evt.data.substr(4));
+        else if (/DONE/.test(evt.data)) {
+            log("PASS");
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        }
+    }
+</script>
+</body>
+</html>
index 0928b64d857c9aaaece8673300f71bf7c69b2ec9..5ac656e3d82e9ecf2669dc8613e3e5991930ebd7 100644 (file)
@@ -1,3 +1,18 @@
+2009-03-04  David Levin  <levin@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Bug 24337: Assert when doing sync XHR in a worker for a cacheable response.
+        <https://bugs.webkit.org/show_bug.cgi?id=24337>
+
+        Tests: http/tests/xmlhttprequest/access-control-basic-denied-preflight-cache.html
+               http/tests/xmlhttprequest/workers/xmlhttprequest-file-not-found.html
+
+        * loader/mac/ResourceLoaderMac.mm:
+        (WebCore::ResourceLoader::willCacheResponse):
+        An identifier is only asssigned if resource load callbacks are done.  So don't send
+        willCacheResponse which uses identifier if resource load callbacks aren't being sent.
+
 2009-03-04  David Levin  <levin@chromium.org>
 
         Reviewed by Alexey Proskuryakov.
index d6ee9236fcf26696add80b4de47c18b3c2217c3e..25fe7bd65b8680859b35a6074d7ce004a2f50354 100644 (file)
@@ -37,6 +37,8 @@ namespace WebCore {
 
 NSCachedURLResponse* ResourceLoader::willCacheResponse(ResourceHandle*, NSCachedURLResponse* response)
 {
+    if (!m_sendResourceLoadCallbacks)
+        return 0;
     return frameLoader()->client()->willCacheResponse(documentLoader(), identifier(), response);
 }