WebCore:
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Mar 2009 21:09:29 +0000 (21:09 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Mar 2009 21:09:29 +0000 (21:09 +0000)
2009-03-01  David Levin  <levin@chromium.org>

        Reviewed by Alexey Proskuryakov.

        Bug 24271: XMLHttpRequest needs js bindings for Workers.
        <https://bugs.webkit.org/show_bug.cgi?id=24271>

        Tests: http/tests/xmlhttprequest/workers/methods-async.html
               http/tests/xmlhttprequest/workers/methods.html

        * bindings/js/JSWorkerContextBase.cpp:
        (WebCore::JSWorkerContextBase::getOwnPropertySlot):
        (jsWorkerContextBaseXMLHttpRequest):
        (setJSWorkerContextBaseXMLHttpRequest):
        Expose XMLHttpRequest to Workers.

        * bindings/js/JSWorkerContextBase.h:

        * bindings/js/JSXMLHttpRequestConstructor.cpp:
        (WebCore::JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor):
        (WebCore::constructXMLHttpRequest):
        (WebCore::JSXMLHttpRequestConstructor::mark):
        Removed the dependencies on Document.

        * bindings/js/JSXMLHttpRequestConstructor.h:
        (WebCore::JSXMLHttpRequestConstructor::scriptExecutionContext):
        * dom/EventException.idl:
        * dom/EventListener.idl:
        Chnage to have the NoStaticTables attribute since they are used from XHR.

        * loader/WorkerThreadableLoader.cpp:
        (WebCore::workerContextDidFinishLoading):
        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading):
        Fixed identifier to be unsigned long.

        * loader/WorkerThreadableLoader.h:
        * workers/WorkerThread.cpp:
        (WebCore::WorkerThread::workerThread):
        Stop active objects when the thread is getting shutdown so that xhr gets properly shutdown.

        * xml/XMLHttpRequestUpload.cpp:

        * xml/XMLHttpRequest.idl:
        * xml/XMLHttpRequestException.idl:
        * xml/XMLHttpRequestProgressEvent.idl:
        * xml/XMLHttpRequestUpload.idl:
        Chnage to have the NoStaticTables attribute since they are used from XHR.

LayoutTests:

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

        Reviewed by Alexey Proskuryakov.

        Bug 24271: XMLHttpRequest needs js bindings for Workers.
        <https://bugs.webkit.org/show_bug.cgi?id=24271>

        Some sanity checks for xhr done from workers. These are the same as
        tests done for normal workers.

        * http/tests/xmlhttprequest/workers/methods-async-expected.txt: Added.
        * http/tests/xmlhttprequest/workers/methods-async.html: Added.
        * http/tests/xmlhttprequest/workers/methods-expected.txt: Added.
        * http/tests/xmlhttprequest/workers/methods.html: Added.
        * http/tests/xmlhttprequest/workers/resources/methods-async.js: Added.
        (onmessage):
        (log):
        (done):
        (onReqAbort):
        (onSyncReqError):
        (start):
        (processStateChange):
        * http/tests/xmlhttprequest/workers/resources/methods.cgi: Copied from LayoutTests/http/tests/xmlhttprequest/methods.cgi.
        * http/tests/xmlhttprequest/workers/resources/methods.js: Added.
        (log):
        (done):

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

24 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/workers/methods-async-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/workers/methods-async.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/workers/methods-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/workers/methods.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/workers/resources/methods-async.js [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/workers/resources/methods.cgi [new file with mode: 0755]
LayoutTests/http/tests/xmlhttprequest/workers/resources/methods.js [new file with mode: 0644]
LayoutTests/platform/qt/Skipped
WebCore/ChangeLog
WebCore/bindings/js/JSWorkerContextBase.cpp
WebCore/bindings/js/JSWorkerContextBase.h
WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp
WebCore/bindings/js/JSXMLHttpRequestConstructor.h
WebCore/dom/EventException.idl
WebCore/dom/EventListener.idl
WebCore/loader/WorkerThreadableLoader.cpp
WebCore/loader/WorkerThreadableLoader.h
WebCore/workers/WorkerThread.cpp
WebCore/xml/XMLHttpRequest.idl
WebCore/xml/XMLHttpRequestException.idl
WebCore/xml/XMLHttpRequestProgressEvent.idl
WebCore/xml/XMLHttpRequestUpload.cpp
WebCore/xml/XMLHttpRequestUpload.idl

index 979b4525350bd412cc48b82de60ad6ebd21bdb06..41a044fd7973da9bf50c4710ebc1dd6ce196efd6 100644 (file)
@@ -1,3 +1,30 @@
+2009-03-01  David Levin  <levin@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Bug 24271: XMLHttpRequest needs js bindings for Workers.
+        <https://bugs.webkit.org/show_bug.cgi?id=24271>
+
+        Some sanity checks for xhr done from workers. These are the same as
+        tests done for normal workers.
+
+        * http/tests/xmlhttprequest/workers/methods-async-expected.txt: Added.
+        * http/tests/xmlhttprequest/workers/methods-async.html: Added.
+        * http/tests/xmlhttprequest/workers/methods-expected.txt: Added.
+        * http/tests/xmlhttprequest/workers/methods.html: Added.
+        * http/tests/xmlhttprequest/workers/resources/methods-async.js: Added.
+        (onmessage):
+        (log):
+        (done):
+        (onReqAbort):
+        (onSyncReqError):
+        (start):
+        (processStateChange):
+        * http/tests/xmlhttprequest/workers/resources/methods.cgi: Copied from LayoutTests/http/tests/xmlhttprequest/methods.cgi.
+        * http/tests/xmlhttprequest/workers/resources/methods.js: Added.
+        (log):
+        (done):
+
 2009-02-28  Jan Michael Alonzo  <jmalonzo@webkit.org>
 
         Reviewed by Holger Freyther.
diff --git a/LayoutTests/http/tests/xmlhttprequest/workers/methods-async-expected.txt b/LayoutTests/http/tests/xmlhttprequest/workers/methods-async-expected.txt
new file mode 100644 (file)
index 0000000..1a2d207
--- /dev/null
@@ -0,0 +1,24 @@
+GET and POST should not be the only HTTP methods implemented in XMLHttpRequest for Workers.
+
+GET(""): GET(null bytes), Content-Type: null
+GET(null): GET(null bytes), Content-Type: null
+GET("123"): GET(null bytes), Content-Type: null
+POST(""): POST(0 bytes), Content-Type: application/xml
+POST(null): POST(0 bytes), Content-Type: null
+POST("123"): POST(3 bytes), Content-Type: application/xml
+PUT(""): PUT(0 bytes), Content-Type: application/xml
+PUT(null): PUT(0 bytes), Content-Type: null
+PUT("123"): PUT(3 bytes), Content-Type: application/xml
+DELETE(""): DELETE(0 bytes), Content-Type: application/xml
+DELETE(null): DELETE(0 bytes), Content-Type: null
+DELETE("123"): DELETE(3 bytes), Content-Type: application/xml
+HEAD(""): HEAD(0 bytes), Content-Type: null
+HEAD(null): HEAD(0 bytes), Content-Type: null
+HEAD("123"): HEAD(0 bytes), Content-Type: null
+WKFOOBAR(""): WKFOOBAR(0 bytes), Content-Type: application/xml
+WKFOOBAR(null): WKFOOBAR(0 bytes), Content-Type: null
+WKFOOBAR("123"): WKFOOBAR(3 bytes), Content-Type: application/xml
+SEARCH(""): SEARCH(0 bytes), Content-Type: application/xml
+SEARCH(null): SEARCH(0 bytes), Content-Type: null
+SEARCH("123"): SEARCH(3 bytes), Content-Type: application/xml
+DONE
diff --git a/LayoutTests/http/tests/xmlhttprequest/workers/methods-async.html b/LayoutTests/http/tests/xmlhttprequest/workers/methods-async.html
new file mode 100644 (file)
index 0000000..10f401e
--- /dev/null
@@ -0,0 +1,39 @@
+<body>
+<p>GET and POST should not be the only HTTP methods implemented in XMLHttpRequest for Workers.</p>
+<div id=result></div>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    
+    var console_messages = document.createElement("ol");
+    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/methods-async.js');
+    worker.postMessage("START");
+
+    worker.onmessage = function(evt)
+    {
+        if (/log .+/.test(evt.data))
+            log(evt.data.substr(4));
+        else if (/DONE/.test(evt.data)) {
+            log("DONE");
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        } else {
+            log("ERROR");
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        }
+    }
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/xmlhttprequest/workers/methods-expected.txt b/LayoutTests/http/tests/xmlhttprequest/workers/methods-expected.txt
new file mode 100644 (file)
index 0000000..1a2d207
--- /dev/null
@@ -0,0 +1,24 @@
+GET and POST should not be the only HTTP methods implemented in XMLHttpRequest for Workers.
+
+GET(""): GET(null bytes), Content-Type: null
+GET(null): GET(null bytes), Content-Type: null
+GET("123"): GET(null bytes), Content-Type: null
+POST(""): POST(0 bytes), Content-Type: application/xml
+POST(null): POST(0 bytes), Content-Type: null
+POST("123"): POST(3 bytes), Content-Type: application/xml
+PUT(""): PUT(0 bytes), Content-Type: application/xml
+PUT(null): PUT(0 bytes), Content-Type: null
+PUT("123"): PUT(3 bytes), Content-Type: application/xml
+DELETE(""): DELETE(0 bytes), Content-Type: application/xml
+DELETE(null): DELETE(0 bytes), Content-Type: null
+DELETE("123"): DELETE(3 bytes), Content-Type: application/xml
+HEAD(""): HEAD(0 bytes), Content-Type: null
+HEAD(null): HEAD(0 bytes), Content-Type: null
+HEAD("123"): HEAD(0 bytes), Content-Type: null
+WKFOOBAR(""): WKFOOBAR(0 bytes), Content-Type: application/xml
+WKFOOBAR(null): WKFOOBAR(0 bytes), Content-Type: null
+WKFOOBAR("123"): WKFOOBAR(3 bytes), Content-Type: application/xml
+SEARCH(""): SEARCH(0 bytes), Content-Type: application/xml
+SEARCH(null): SEARCH(0 bytes), Content-Type: null
+SEARCH("123"): SEARCH(3 bytes), Content-Type: application/xml
+DONE
diff --git a/LayoutTests/http/tests/xmlhttprequest/workers/methods.html b/LayoutTests/http/tests/xmlhttprequest/workers/methods.html
new file mode 100644 (file)
index 0000000..a925d97
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+<body>
+<p>GET and POST should not be the only HTTP methods implemented in XMLHttpRequest for Workers.</p>
+<script>
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    
+    var console_messages = document.createElement("ol");
+    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/methods.js');
+    worker.onmessage = function(evt)
+    {
+        if (/log .+/.test(evt.data))
+            log(evt.data.substr(4));
+        else if (/DONE/.test(evt.data)) {
+            log("DONE");
+            if (window.layoutTestController)
+                layoutTestController.notifyDone();
+        }
+    }
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/xmlhttprequest/workers/resources/methods-async.js b/LayoutTests/http/tests/xmlhttprequest/workers/resources/methods-async.js
new file mode 100644 (file)
index 0000000..26ef538
--- /dev/null
@@ -0,0 +1,154 @@
+onmessage = function(evt)
+{
+    if (evt.data == "START")
+        start();
+}
+
+function log(message)
+{
+    postMessage("log " + message);
+}
+
+function done()
+{
+    postMessage("DONE");
+}
+
+function onReqAbort()
+{
+    log('Abort event.');
+}
+
+function onSyncReqError()
+{
+    log('Error event.');
+}
+
+// async
+    
+var asyncStep = 1;
+
+function start() 
+{
+    req = new XMLHttpRequest();
+    req.onreadystatechange = processStateChange;
+    req.onerror = onSyncReqError;
+    req.onabort = onReqAbort;
+    req.open("GET", "methods.cgi", true);
+    req.send("");
+}
+
+function processStateChange()
+{
+    if (req.readyState == 4){
+        if (req.status == 200){
+            if (asyncStep == 1) {
+                asyncStep = 2;
+                log('GET(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("GET", "methods.cgi", true);
+                req.send(null);
+            } else if (asyncStep == 2) {
+                asyncStep = 3;
+                log('GET(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("GET", "methods.cgi", true);
+                req.send("123");
+            } else if (asyncStep == 3) {
+                asyncStep = 4;
+                log('GET("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("POST", "methods.cgi", true);
+                req.send("");
+            } else if (asyncStep == 4) {
+                asyncStep = 5;
+                log('POST(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("POST", "methods.cgi", true);
+                req.send(null);
+            } else if (asyncStep == 5) {
+                asyncStep = 6;
+                log('POST(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("POST", "methods.cgi", true);
+                req.send("123");
+            } else if (asyncStep == 6) {
+                asyncStep = 7;
+                log('POST("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("PUT", "methods.cgi", true);
+                req.send("");
+            } else if (asyncStep == 7) {
+                asyncStep = 8;
+                log('PUT(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("PUT", "methods.cgi", true);
+                req.send(null);
+            } else if (asyncStep == 8) {
+                asyncStep = 9;
+                log('PUT(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("PUT", "methods.cgi", true);
+                req.send("123");
+            } else if (asyncStep == 9) {
+                asyncStep = 10;
+                log('PUT("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("DELETE", "methods.cgi", true);
+                req.send("");
+            } else if (asyncStep == 10) {
+                asyncStep = 11;
+                log('DELETE(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("DELETE", "methods.cgi", true);
+                req.send(null);
+            } else if (asyncStep == 11) {
+                asyncStep = 12;
+                log('DELETE(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("DELETE", "methods.cgi", true);
+                req.send("123");
+            } else if (asyncStep == 12) {
+                asyncStep = 13;
+                log('DELETE("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("HEAD", "methods.cgi", true);
+                req.send("");
+            } else if (asyncStep == 13) {
+                asyncStep = 14;
+                log('HEAD(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("HEAD", "methods.cgi", true);
+                req.send(null);
+            } else if (asyncStep == 14) {
+                asyncStep = 15;
+                log('HEAD(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("HEAD", "methods.cgi", true);
+                req.send("123");
+            } else if (asyncStep == 15) {
+                asyncStep = 16;
+                log('HEAD("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("WKFOOBAR", "methods.cgi", true);
+                req.send("");
+            } else if (asyncStep == 16) {
+                asyncStep = 17;
+                log('WKFOOBAR(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("WKFOOBAR", "methods.cgi", true);
+                req.send(null);
+            } else if (asyncStep == 17) {
+                asyncStep = 18;
+                log('WKFOOBAR(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("WKFOOBAR", "methods.cgi", true);
+                req.send("123");
+            } else if (asyncStep == 18) {
+                asyncStep = 19;
+                log('WKFOOBAR("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("SEARCH", "methods.cgi", true);
+                req.send("");
+            } else if (asyncStep == 19) {
+                asyncStep = 20;
+                log('SEARCH(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("SEARCH", "methods.cgi", true);
+                req.send(null);
+            } else if (asyncStep == 20) {
+                asyncStep = 21;
+                log('SEARCH(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                req.open("SEARCH", "methods.cgi", true);
+                req.send("123");
+            } else if (asyncStep == 21) {
+                log('SEARCH("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+                done();
+            }
+        } else {
+            log("Error loading URL: status " + req.status);
+            done();
+        }
+    }
+}
diff --git a/LayoutTests/http/tests/xmlhttprequest/workers/resources/methods.cgi b/LayoutTests/http/tests/xmlhttprequest/workers/resources/methods.cgi
new file mode 100755 (executable)
index 0000000..4413ffe
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/perl -w
+
+print "Content-type: text/plain\n"; 
+print "Content-Length: 0\n";
+my $cl = $ENV{'CONTENT_LENGTH'};
+my $ct = $ENV{'CONTENT_TYPE'};
+my $method = $ENV{'REQUEST_METHOD'};
+if (defined $cl) {
+    print "REQLENGTH: $cl\n";
+}
+if (defined $ct) {
+    print "REQTYPE: $ct\n";
+}
+print "REQMETHOD: $method\n";
+
+print "\n";
diff --git a/LayoutTests/http/tests/xmlhttprequest/workers/resources/methods.js b/LayoutTests/http/tests/xmlhttprequest/workers/resources/methods.js
new file mode 100644 (file)
index 0000000..feb96b7
--- /dev/null
@@ -0,0 +1,96 @@
+function log(message)
+{
+    postMessage("log " + message);
+}
+
+function done()
+{
+    postMessage("DONE");
+}
+
+// sync
+req = new XMLHttpRequest;
+req.open("GET", "methods.cgi", false);
+req.send("");
+log('GET(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("GET", "methods.cgi", false);
+req.send(null);
+log('GET(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("GET", "methods.cgi", false);
+req.send("123");
+log('GET("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("POST", "methods.cgi", false);
+req.send("");
+log('POST(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("POST", "methods.cgi", false);
+req.send(null);
+log('POST(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("POST", "methods.cgi", false);
+req.send("123");
+log('POST("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("PUT", "methods.cgi", false);
+req.send("");
+log('PUT(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("PUT", "methods.cgi", false);
+req.send(null);
+log('PUT(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("PUT", "methods.cgi", false);
+req.send("123");
+log('PUT("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("DELETE", "methods.cgi", false);
+req.send("");
+log('DELETE(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("DELETE", "methods.cgi", false);
+req.send(null);
+log('DELETE(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("DELETE", "methods.cgi", false);
+req.send("123");
+log('DELETE("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("HEAD", "methods.cgi", false);
+req.send("");
+log('HEAD(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("HEAD", "methods.cgi", false);
+req.send(null);
+log('HEAD(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("HEAD", "methods.cgi", false);
+req.send("123");
+log('HEAD("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("WKFOOBAR", "methods.cgi", false);
+req.send("");
+log('WKFOOBAR(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("WKFOOBAR", "methods.cgi", false);
+req.send(null);
+log('WKFOOBAR(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("WKFOOBAR", "methods.cgi", false);
+req.send("123");
+log('WKFOOBAR("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("SEARCH", "methods.cgi", false);
+req.send("");
+log('SEARCH(""): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("SEARCH", "methods.cgi", false);
+req.send(null);
+log('SEARCH(null): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+
+req.open("SEARCH", "methods.cgi", false);
+req.send("123");
+log('SEARCH("123"): ' + req.getResponseHeader("REQMETHOD") + "(" + req.getResponseHeader("REQLENGTH") + " bytes), Content-Type: " + req.getResponseHeader("REQTYPE"));
+done();
index c272e37993be8650d1f346b84262cc64e1ad5fe1..1d921e2e6694dd726511bfaeb5f5965058fce47a 100644 (file)
@@ -902,6 +902,7 @@ fast/text/monospace-width-cache.html
 # Disabled worker threads
 fast/workers
 fast/events/dispatchEvent-crash.html
+http/tests/xmlhttprequest/workers
 
 # Tests that fail randomly. Is this style related?
 fast/forms/listbox-width-change.html
index de1867682ef4faa96a29bbdedc3a3b052edd65f5..c79b8b38a64d67e97f88a201b16dd8bae14cf728 100644 (file)
@@ -1,3 +1,51 @@
+2009-03-01  David Levin  <levin@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        Bug 24271: XMLHttpRequest needs js bindings for Workers.
+        <https://bugs.webkit.org/show_bug.cgi?id=24271>
+
+        Tests: http/tests/xmlhttprequest/workers/methods-async.html
+               http/tests/xmlhttprequest/workers/methods.html
+
+        * bindings/js/JSWorkerContextBase.cpp:
+        (WebCore::JSWorkerContextBase::getOwnPropertySlot):
+        (jsWorkerContextBaseXMLHttpRequest):
+        (setJSWorkerContextBaseXMLHttpRequest):
+        Expose XMLHttpRequest to Workers.
+
+        * bindings/js/JSWorkerContextBase.h:
+
+        * bindings/js/JSXMLHttpRequestConstructor.cpp:
+        (WebCore::JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor):
+        (WebCore::constructXMLHttpRequest):
+        (WebCore::JSXMLHttpRequestConstructor::mark):
+        Removed the dependencies on Document.
+
+        * bindings/js/JSXMLHttpRequestConstructor.h:
+        (WebCore::JSXMLHttpRequestConstructor::scriptExecutionContext):
+        * dom/EventException.idl:
+        * dom/EventListener.idl:
+        Chnage to have the NoStaticTables attribute since they are used from XHR.
+
+        * loader/WorkerThreadableLoader.cpp:
+        (WebCore::workerContextDidFinishLoading):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading):
+        Fixed identifier to be unsigned long.
+
+        * loader/WorkerThreadableLoader.h:
+        * workers/WorkerThread.cpp:
+        (WebCore::WorkerThread::workerThread):
+        Stop active objects when the thread is getting shutdown so that xhr gets properly shutdown.
+
+        * xml/XMLHttpRequestUpload.cpp:
+
+        * xml/XMLHttpRequest.idl:
+        * xml/XMLHttpRequestException.idl:
+        * xml/XMLHttpRequestProgressEvent.idl:
+        * xml/XMLHttpRequestUpload.idl:
+        Chnage to have the NoStaticTables attribute since they are used from XHR.
+
 2009-03-01  Horia Olaru  <olaru@adobe.com>
 
         Adding manual debugger test cases for bug.
index 24dd50f4462826560acee08b4a78eb0d8b3e6a97..1093322623068df0278885d51c9f093e4c5de215 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2009 Google Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,6 +39,7 @@
 #include "JSMessagePort.h"
 #include "JSWorkerLocation.h"
 #include "JSWorkerNavigator.h"
+#include "JSXMLHttpRequestConstructor.h"
 #include "WorkerContext.h"
 #include "WorkerLocation.h"
 
@@ -45,9 +47,14 @@ using namespace JSC;
 
 /*
 @begin JSWorkerContextBaseTable
+# -- Constructors --
+  XMLHttpRequest                jsWorkerContextBaseXMLHttpRequest               DontDelete
 @end
 */
 
+static JSValuePtr jsWorkerContextBaseXMLHttpRequest(ExecState*, const Identifier&, const PropertySlot&);
+static void setJSWorkerContextBaseXMLHttpRequest(ExecState*, JSObject*, JSValuePtr);
+
 #include "JSWorkerContextBase.lut.h"
 
 namespace WebCore {
@@ -81,6 +88,33 @@ void JSWorkerContextBase::put(ExecState* exec, const Identifier& propertyName, J
     lookupPut<JSWorkerContextBase, Base>(exec, propertyName, value, getJSWorkerContextBaseTable(exec), this, slot);
 }
 
+bool JSWorkerContextBase::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+{
+    const HashEntry* entry = getJSWorkerContextBaseTable(exec)->entry(exec, propertyName);
+    if (entry) {
+        if (entry->attributes() & Function)
+            setUpStaticFunctionSlot(exec, entry, this, propertyName, slot);
+        else
+            slot.setCustom(this, entry->propertyGetter());
+        return true;
+    }
+
+    return Base::getOwnPropertySlot(exec, propertyName, slot);
+}
+
 } // namespace WebCore
 
+using namespace WebCore;
+
+JSValuePtr jsWorkerContextBaseXMLHttpRequest(ExecState* exec, const Identifier&, const PropertySlot& slot)
+{
+    return getDOMConstructor<JSXMLHttpRequestConstructor>(exec, static_cast<JSWorkerContextBase*>(asObject(slot.slotBase())));
+}
+
+void setJSWorkerContextBaseXMLHttpRequest(ExecState* exec, JSObject* thisObject, JSValuePtr value)
+{
+    // Shadowing a built-in constructor
+    static_cast<JSWorkerContextBase*>(thisObject)->putDirect(Identifier(exec, "XMLHttpRequest"), value);
+}
+
 #endif // ENABLE(WORKERS)
index d2d5bd29cdb02034f57a9d16692dc78c82033193..5dc1921d4259f9da5031ee3cf68576ffca438ee0 100644 (file)
@@ -48,6 +48,8 @@ namespace WebCore {
         WorkerContext* impl() const { return m_impl.get(); }
         virtual ScriptExecutionContext* scriptExecutionContext() const;
 
+        bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
+
     private:
         RefPtr<WorkerContext> m_impl;
     };
index d7f54dead72bac05c571ebef447e454f379ee1e8..f72daf4018da6a562773da06bf8d305d9dd08478 100644 (file)
@@ -32,18 +32,17 @@ ASSERT_CLASS_FITS_IN_CELL(JSXMLHttpRequestConstructor)
 
 const ClassInfo JSXMLHttpRequestConstructor::s_info = { "XMLHttpRequestConstructor", 0, 0, 0 };
 
-JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor(ExecState* exec, ScriptExecutionContext* context)
+JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor(ExecState* exec, ScriptExecutionContext* scriptExecutionContext)
     : DOMObject(JSXMLHttpRequestConstructor::createStructure(exec->lexicalGlobalObject()->objectPrototype()))
+    , m_scriptExecutionContext(scriptExecutionContext)
+    , m_contextWrapper(toJSDOMGlobalObject(scriptExecutionContext))
 {
-    ASSERT(context->isDocument());
-    m_document = static_cast<JSDocument*>(asObject(toJS(exec, static_cast<Document*>(context))));
-
     putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec), None);
 }
 
 static JSObject* constructXMLHttpRequest(ExecState* exec, JSObject* constructor, const ArgList&)
 {
-    RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(static_cast<JSXMLHttpRequestConstructor*>(constructor)->document());
+    RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(static_cast<JSXMLHttpRequestConstructor*>(constructor)->scriptExecutionContext());
     return CREATE_DOM_OBJECT_WRAPPER(exec, XMLHttpRequest, xmlHttpRequest.get());
 }
 
@@ -56,8 +55,8 @@ ConstructType JSXMLHttpRequestConstructor::getConstructData(ConstructData& const
 void JSXMLHttpRequestConstructor::mark()
 {
     DOMObject::mark();
-    if (!m_document->marked())
-        m_document->mark();
+    if (!m_contextWrapper.marked())
+        m_contextWrapper.mark();
 }
 
 } // namespace WebCore
index f235af63604fa3c87461a77bc33185d3c65ea2e4..715eb8ff2d973ce7a6906d677feed5aacf250272 100644 (file)
 #define JSXMLHttpRequestConstructor_h
 
 #include "JSDOMBinding.h"
-#include "JSDocument.h"
 
 namespace WebCore {
 
 class JSXMLHttpRequestConstructor : public DOMObject {
 public:
     JSXMLHttpRequestConstructor(JSC::ExecState*, ScriptExecutionContext*);
-    Document* document() const { return m_document->impl(); }
+    ScriptExecutionContext* scriptExecutionContext() { return m_scriptExecutionContext; }
     static const JSC::ClassInfo s_info;
 
     virtual void mark();
@@ -36,7 +35,8 @@ private:
     virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
     virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
 
-    JSDocument* m_document;
+    ScriptExecutionContext* m_scriptExecutionContext;
+    JSC::JSValuePtr m_contextWrapper;
 };
 
 } // namespace WebCore
index 61cfd65d858ea2d73794e5b5d78c698b8f611a50..f9480782c3d597e481ed67ffdd0af63a2116449a 100644 (file)
@@ -30,7 +30,8 @@ module events {
 
     // Introduced in DOM Level 2:
     interface [
-        GenerateConstructor
+        GenerateConstructor,
+        NoStaticTables
     ] EventException {
 
         readonly attribute unsigned short   code;
index 9d28703438b70d26703bfa3ac292623c1e8372c5..9dc2e0af338cf0a6140e10e4c96024a5d4e35856 100644 (file)
@@ -22,6 +22,7 @@ module events {
 
     // Introduced in DOM Level 2:
     interface [
+        NoStaticTables,
         ObjCProtocol,
         InterfaceUUID=B04F2AE3-71E2-4ebe-ABFE-EF4938354082,
         ImplementationUUID=DDFDD342-A78B-4f19-8F32-A5DF51B56E08
index 2fa3203cd5fcec2af8424838e0ac97bbcec03fed..7d6e7cf9d8828175828f4b91807b3194d42f03c9 100644 (file)
@@ -198,13 +198,13 @@ void WorkerThreadableLoader::MainThreadBridge::didReceiveData(const char* data,
     m_messagingProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidReceiveData, m_workerClientWrapper, vector), m_taskMode);
 }
 
-static void workerContextDidFinishLoading(ScriptExecutionContext* context, RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, int identifier)
+static void workerContextDidFinishLoading(ScriptExecutionContext* context, RefPtr<ThreadableLoaderClientWrapper> workerClientWrapper, unsigned long identifier)
 {
     ASSERT_UNUSED(context, context->isWorkerContext());
     workerClientWrapper->didFinishLoading(identifier);
 }
 
-void WorkerThreadableLoader::MainThreadBridge::didFinishLoading(int identifier)
+void WorkerThreadableLoader::MainThreadBridge::didFinishLoading(unsigned long identifier)
 {
     m_messagingProxy.postTaskForModeToWorkerContext(createCallbackTask(&workerContextDidFinishLoading, m_workerClientWrapper, identifier), m_taskMode);
 }
index b4d2fcba884c54aa4613abf597f3d963b9d886fc..5462a977fc9bcd926e39753590724f8f5d4d6474 100644 (file)
@@ -114,7 +114,7 @@ namespace WebCore {
             virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
             virtual void didReceiveResponse(const ResourceResponse&);
             virtual void didReceiveData(const char*, int lengthReceived);
-            virtual void didFinishLoading(int identifier);
+            virtual void didFinishLoading(unsigned long identifier);
             virtual void didFail(const ResourceError&);
             virtual void didFailRedirectCheck();
             virtual void didReceiveAuthenticationCancellation(const ResourceResponse&);
index 3d6586fbeb5936544567170b3f8110fb7319e3dc..9a5ee214ee948be48ab5f3d48f54bfb9f7b41f31 100644 (file)
@@ -122,6 +122,7 @@ void* WorkerThread::workerThread()
 
     ThreadIdentifier threadID = m_threadID;
 
+    m_workerContext->stopActiveDOMObjects();
     m_workerContext->clearScript();
     ASSERT(m_workerContext->hasOneRef());
     // The below assignment will destroy the context, which will in turn notify messaging proxy.
index 315d95c4c4ddeb0242a96d5bbcf69549bb2181f5..3187160a888dc5c6901bb7c0191b06e165600216 100644 (file)
@@ -29,7 +29,8 @@
 module xml {
 
     interface [
-        CustomMarkFunction
+        CustomMarkFunction,
+        NoStaticTables
     ] XMLHttpRequest {
         // From XMLHttpRequestEventTarget
         // event handler attributes
index 2feb57459e5d368fb36da63f31094aaa18cc1cdf..706beb260ba41c884d0ea7782381171bcd6bd85f 100644 (file)
@@ -29,7 +29,8 @@
 module xml {
 
     interface [
-        GenerateConstructor
+        GenerateConstructor,
+        NoStaticTables
     ] XMLHttpRequestException {
 
         readonly attribute unsigned short   code;
index 6de9690045a1c5265837e047441ced0dc65514a0..549308babf7b28aaade8f097772d8b0b38a78030 100644 (file)
@@ -26,7 +26,8 @@
 module events {
 
     interface [
-        GenerateConstructor
+        GenerateConstructor,
+        NoStaticTables
     // We should also inherit from LSProgressEvent when the idl is added.
     ] XMLHttpRequestProgressEvent : ProgressEvent {
          readonly attribute unsigned long   position;
index a58c2716daf414600b1f1820e3cf6b8f3bb8efaf..42918ea9ad2e37fb7682985fff55d6d80891900f 100644 (file)
@@ -30,7 +30,6 @@
 #include "Event.h"
 #include "EventException.h"
 #include "EventNames.h"
-#include "Frame.h"
 #include "XMLHttpRequest.h"
 #include "XMLHttpRequestProgressEvent.h"
 #include <wtf/Assertions.h>
index c06671018cd3e9e26779dde6d424f48229e65561..3172f68ec1050a33110866da47faf6f202ab4e2b 100644 (file)
@@ -30,7 +30,8 @@ module xml {
 
     interface [
         GenerateConstructor,
-        CustomMarkFunction
+        CustomMarkFunction,
+        NoStaticTables
     ] XMLHttpRequestUpload {
         // From XMLHttpRequestEventTarget
         // event handler attributes