EventSource should support CORS
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2012 00:19:42 +0000 (00:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2012 00:19:42 +0000 (00:19 +0000)
commitc581bf8d97ca1fc44519d461c679625dab43859c
tree66511c64b7264c8cf9de42d7447250f8dec708d6
parent14e0cb962b23476df2b0e7e2768b999777ad193b
EventSource should support CORS
https://bugs.webkit.org/show_bug.cgi?id=61862

Patch by Per-Erik Brodin <per-erik.brodin@ericsson.com> on 2012-12-18
Reviewed by Alexey Proskuryakov.

Source/WebCore:

Enabled CORS in EventSource with optional constructor argument to
indicate whether credentials should be included or not, as per the spec.
Added didFailAccessControlCheck to ThreadableLoaderClient to be able to
properly distinguish CORS failures from other errors.

Tests: http/tests/eventsource/eventsource-cors-basic.html
       http/tests/eventsource/eventsource-cors-no-server.html
       http/tests/eventsource/eventsource-cors-with-credentials.html

* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::makeSimpleCrossOriginAccessRequest):
(WebCore::DocumentThreadableLoader::didReceiveResponse):
(WebCore::DocumentThreadableLoader::preflightFailure):
* loader/ThreadableLoaderClient.h:
(WebCore::ThreadableLoaderClient::didFailAccessControlCheck):
* loader/ThreadableLoaderClientWrapper.h:
(WebCore::ThreadableLoaderClientWrapper::didFailAccessControlCheck):
(ThreadableLoaderClientWrapper):
* loader/WorkerThreadableLoader.cpp:
(WebCore::workerContextDidFailAccessControlCheck):
(WebCore):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFailAccessControlCheck):
* loader/WorkerThreadableLoader.h:
(MainThreadBridge):
* page/EventSource.cpp:
(WebCore::EventSource::EventSource):
(WebCore::EventSource::create):
(WebCore::EventSource::connect):
(WebCore::EventSource::withCredentials):
(WebCore):
(WebCore::EventSource::didReceiveResponse):
(WebCore::EventSource::didFailAccessControlCheck):
(WebCore::EventSource::didFailRedirectCheck):
(WebCore::EventSource::abortConnectionAttempt):
(WebCore::EventSource::parseEventStreamLine):
(WebCore::EventSource::createMessageEvent):
* page/EventSource.h:
(WebCore):
(EventSource):
(WebCore::EventSource::refEventTarget):
(WebCore::EventSource::derefEventTarget):
* page/EventSource.idl:

LayoutTests:

Added new CORS tests for EventSource. Modified existing test to verify
that the new constructor argument can be passed to the constructor.

* fast/eventsource/eventsource-constructor-expected.txt:
* fast/eventsource/eventsource-constructor.html:
* fast/js/constructor-length.html:
* http/tests/eventsource/eventsource-cors-basic-expected.txt: Added.
* http/tests/eventsource/eventsource-cors-basic.html: Added.
* http/tests/eventsource/eventsource-cors-no-server-expected.txt: Added.
* http/tests/eventsource/eventsource-cors-no-server.html: Added.
* http/tests/eventsource/eventsource-cors-with-credentials-expected.txt: Added.
* http/tests/eventsource/eventsource-cors-with-credentials.html: Added.
* http/tests/eventsource/resources/es-cors-basic.php: Added.
* http/tests/eventsource/resources/es-cors-credentials.php: Added.
* platform/blackberry/fast/js/constructor-length-expected.txt:
* platform/chromium/fast/js/constructor-length-expected.txt:
* platform/gtk/fast/js/constructor-length-expected.txt:
* platform/mac/fast/js/constructor-length-expected.txt:
* platform/qt/fast/js/constructor-length-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138083 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/eventsource/eventsource-constructor-expected.txt
LayoutTests/fast/eventsource/eventsource-constructor.html
LayoutTests/fast/js/constructor-length.html
LayoutTests/http/tests/eventsource/eventsource-cors-basic-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/eventsource/eventsource-cors-basic.html [new file with mode: 0644]
LayoutTests/http/tests/eventsource/eventsource-cors-no-server-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/eventsource/eventsource-cors-no-server.html [new file with mode: 0644]
LayoutTests/http/tests/eventsource/eventsource-cors-with-credentials-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/eventsource/eventsource-cors-with-credentials.html [new file with mode: 0644]
LayoutTests/http/tests/eventsource/resources/es-cors-basic.php [new file with mode: 0644]
LayoutTests/http/tests/eventsource/resources/es-cors-credentials.php [new file with mode: 0644]
LayoutTests/platform/blackberry/fast/js/constructor-length-expected.txt
LayoutTests/platform/chromium/fast/js/constructor-length-expected.txt
LayoutTests/platform/gtk/fast/js/constructor-length-expected.txt
LayoutTests/platform/mac/fast/js/constructor-length-expected.txt
LayoutTests/platform/qt/fast/js/constructor-length-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/ThreadableLoaderClient.h
Source/WebCore/loader/ThreadableLoaderClientWrapper.h
Source/WebCore/loader/WorkerThreadableLoader.cpp
Source/WebCore/loader/WorkerThreadableLoader.h
Source/WebCore/page/EventSource.cpp
Source/WebCore/page/EventSource.h
Source/WebCore/page/EventSource.idl