Skip to content
  • commit-queue@webkit.org's avatar
    EventSource should support CORS · 2df44228
    commit-queue@webkit.org authored
    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: http://svn.webkit.org/repository/webkit/trunk@138083 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    2df44228