WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
updated patch
eventsource_r47105_2.patch (text/plain), 91.13 KB, created by
Adam Bergkvist
on 2009-08-13 04:49:08 PDT
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Adam Bergkvist
Created:
2009-08-13 04:49:08 PDT
Size:
91.13 KB
patch
obsolete
>Index: ChangeLog >=================================================================== >--- ChangeLog (revision 47105) >+++ ChangeLog (working copy) >@@ -1,3 +1,12 @@ >+2009-08-12 Adam Bergkvist <adam.bergkvist@ericsson.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ [GTK] Added EventSource to the build (default on). >+ https://bugs.webkit.org/show_bug.cgi?id=14997 >+ >+ * configure.ac: >+ > 2009-08-11 Drew Wilson <atwilson@google.com> > > Reviewed by NOBODY (Build break). >Index: configure.ac >=================================================================== >--- configure.ac (revision 47105) >+++ configure.ac (working copy) >@@ -348,6 +348,14 @@ AC_ARG_ENABLE(database, > [],[enable_database="yes"]) > AC_MSG_RESULT([$enable_database]) > >+# check whether to build with server-sent events support >+AC_MSG_CHECKING([whether to enable HTML5 server-sent events support]) >+AC_ARG_ENABLE(eventsource, >+ AC_HELP_STRING([--enable-eventsource], >+ [enable HTML5 server-sent events support [default=yes]]), >+ [],[enable_eventsource="yes"]) >+AC_MSG_RESULT([$enable_eventsource]) >+ > # check whether to build with icon database support > AC_MSG_CHECKING([whether to enable icon database support]) > AC_ARG_ENABLE(icon_database, >@@ -702,6 +710,7 @@ AM_CONDITIONAL([ENABLE_JAVASCRIPT_DEBUGG > AM_CONDITIONAL([ENABLE_OFFLINE_WEB_APPLICATIONS],[test "$enable_offline_web_applications" = "yes"]) > AM_CONDITIONAL([ENABLE_DOM_STORAGE],[test "$enable_dom_storage" = "yes"]) > AM_CONDITIONAL([ENABLE_DATABASE],[test "$enable_database" = "yes"]) >+AM_CONDITIONAL([ENABLE_EVENTSOURCE],[test "$enable_eventsource" = "yes"]) > AM_CONDITIONAL([ENABLE_ICONDATABASE],[test "$enable_icon_database" = "yes"]) > AM_CONDITIONAL([ENABLE_XPATH],[test "$enable_xpath" = "yes"]) > AM_CONDITIONAL([ENABLE_XSLT],[test "$enable_xslt" = "yes"]) >@@ -759,6 +768,7 @@ Features: > HTML5 client-side session and persistent storage support : $enable_dom_storage > HTML5 client-side database storage support : $enable_database > HTML5 ruby support : $enable_ruby >+ HTML5 server-sent events support : $enable_eventsource > HTML5 video element support : $enable_video > Icon database support : $enable_icon_database > SharedWorkers support : $enable_shared_workers >Index: JavaScriptCore/ChangeLog >=================================================================== >--- JavaScriptCore/ChangeLog (revision 47105) >+++ JavaScriptCore/ChangeLog (working copy) >@@ -1,3 +1,12 @@ >+2009-08-12 Adam Bergkvist <adam.bergkvist@ericsson.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added ENABLE_EVENTSOURCE flag. >+ https://bugs.webkit.org/show_bug.cgi?id=14997 >+ >+ * Configurations/FeatureDefines.xcconfig: >+ > 2009-08-12 Balazs Kelemen <kelemen.balazs.3@stud.u-szeged.hu> > > Reviewed by Ariya Hidayat. >Index: JavaScriptCore/Configurations/FeatureDefines.xcconfig >=================================================================== >--- JavaScriptCore/Configurations/FeatureDefines.xcconfig (revision 47105) >+++ JavaScriptCore/Configurations/FeatureDefines.xcconfig (working copy) >@@ -36,6 +36,7 @@ ENABLE_CHANNEL_MESSAGING = ENABLE_CHANNE > ENABLE_DATABASE = ENABLE_DATABASE; > ENABLE_DATAGRID = ENABLE_DATAGRID; > ENABLE_DOM_STORAGE = ENABLE_DOM_STORAGE; >+ENABLE_EVENTSOURCE = ENABLE_EVENTSOURCE; > ENABLE_FILTERS = ; > ENABLE_GEOLOCATION = ; > ENABLE_ICONDATABASE = ENABLE_ICONDATABASE; >@@ -58,4 +59,4 @@ ENABLE_WORKERS = ENABLE_WORKERS; > ENABLE_XPATH = ENABLE_XPATH; > ENABLE_XSLT = ENABLE_XSLT; > >-FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DOM_STORAGE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_RUBY) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT); >+FEATURE_DEFINES = $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DOM_STORAGE) $(ENABLE_EVENTSOURCE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_RUBY) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT); >Index: WebCore/ChangeLog >=================================================================== >--- WebCore/ChangeLog (revision 47105) >+++ WebCore/ChangeLog (working copy) >@@ -1,3 +1,90 @@ >+2009-08-12 Adam Bergkvist <adam.bergkvist@ericsson.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added implementation of the EventSource object that enables >+ server-sent events from HTML5. >+ http://dev.w3.org/html5/eventsource/ >+ https://bugs.webkit.org/show_bug.cgi?id=14997 >+ >+ Tests: fast/eventsource/eventsource-attribute-listeners.html >+ fast/eventsource/eventsource-constructor.html >+ http/tests/eventsource/eventsource-bad-mime-type.html >+ http/tests/eventsource/eventsource-parse-event-stream.html >+ http/tests/eventsource/eventsource-reconnect.html >+ http/tests/eventsource/eventsource-status-code-states.html >+ http/tests/eventsource/workers/eventsource-simple.html >+ >+ * Configurations/FeatureDefines.xcconfig: >+ * DerivedSources.cpp: >+ * DerivedSources.make: >+ * GNUmakefile.am: >+ * WebCore.pro: >+ * WebCore.vcproj/WebCore.vcproj: >+ * WebCore.xcodeproj/project.pbxproj: >+ * bindings/js/JSDOMWindowCustom.cpp: >+ (WebCore::JSDOMWindow::eventSource): >+ * bindings/js/JSEventSourceConstructor.cpp: Added. >+ (WebCore::): >+ (WebCore::JSEventSourceConstructor::JSEventSourceConstructor): >+ (WebCore::constructEventSource): >+ (WebCore::JSEventSourceConstructor::getConstructData): >+ * bindings/js/JSEventSourceConstructor.h: Added. >+ (WebCore::JSEventSourceConstructor::classInfo): >+ * bindings/js/JSEventSourceCustom.cpp: Added. >+ (WebCore::JSEventSource::markChildren): >+ (WebCore::JSEventSource::addEventListener): >+ (WebCore::JSEventSource::removeEventListener): >+ * bindings/js/JSEventTarget.cpp: >+ (WebCore::toJS): >+ (WebCore::toEventTarget): >+ * bindings/js/JSWorkerContextCustom.cpp: >+ (WebCore::JSWorkerContext::eventSource): >+ * dom/EventNames.h: >+ * dom/EventTarget.cpp: >+ (WebCore::EventTarget::toEventSource): >+ * dom/EventTarget.h: >+ * page/DOMWindow.idl: >+ * page/EventSource.cpp: Added. >+ (WebCore::EventSource::EventSource): >+ (WebCore::EventSource::~EventSource): >+ (WebCore::EventSource::connect): >+ (WebCore::EventSource::endRequest): >+ (WebCore::EventSource::scheduleReconnect): >+ (WebCore::EventSource::reconnectTimerFired): >+ (WebCore::EventSource::url): >+ (WebCore::EventSource::readyState): >+ (WebCore::EventSource::close): >+ (WebCore::EventSource::scriptExecutionContext): >+ (WebCore::EventSource::addEventListener): >+ (WebCore::EventSource::removeEventListener): >+ (WebCore::EventSource::dispatchEvent): >+ (WebCore::EventSource::didReceiveResponse): >+ (WebCore::EventSource::didReceiveData): >+ (WebCore::EventSource::didFinishLoading): >+ (WebCore::EventSource::didFail): >+ (WebCore::EventSource::didFailRedirectCheck): >+ (WebCore::EventSource::parseEventStream): >+ (WebCore::EventSource::parseEventStreamLine): >+ (WebCore::EventSource::dispatchGenericEvent): >+ (WebCore::EventSource::dispatchMessageEvent): >+ (WebCore::EventSource::stop): >+ * page/EventSource.h: Added. >+ (WebCore::EventSource::create): >+ (WebCore::EventSource::): >+ (WebCore::EventSource::setOnopen): >+ (WebCore::EventSource::onopen): >+ (WebCore::EventSource::setOnmessage): >+ (WebCore::EventSource::onmessage): >+ (WebCore::EventSource::setOnerror): >+ (WebCore::EventSource::onerror): >+ (WebCore::EventSource::toEventSource): >+ (WebCore::EventSource::eventListeners): >+ (WebCore::EventSource::refEventTarget): >+ (WebCore::EventSource::derefEventTarget): >+ * page/EventSource.idl: Added. >+ * workers/WorkerContext.idl: >+ > 2009-08-12 Ariya Hidayat <ariya.hidayat@nokia.com> > > Reviewed by Holger Freyther. >Index: WebCore/DerivedSources.cpp >=================================================================== >--- WebCore/DerivedSources.cpp (revision 47105) >+++ WebCore/DerivedSources.cpp (working copy) >@@ -73,6 +73,7 @@ > #include "JSErrorEvent.cpp" > #include "JSEvent.cpp" > #include "JSEventException.cpp" >+#include "JSEventSource.cpp" > #include "JSFile.cpp" > #include "JSFileList.cpp" > #include "JSHistory.cpp" >Index: WebCore/DerivedSources.make >=================================================================== >--- WebCore/DerivedSources.make (revision 47105) >+++ WebCore/DerivedSources.make (working copy) >@@ -100,6 +100,7 @@ DOM_CLASSES = \ > Event \ > EventException \ > EventListener \ >+ EventSource \ > EventTarget \ > File \ > FileList \ >Index: WebCore/GNUmakefile.am >=================================================================== >--- WebCore/GNUmakefile.am (revision 47105) >+++ WebCore/GNUmakefile.am (working copy) >@@ -242,6 +242,7 @@ IDL_BINDINGS += \ > WebCore/page/Coordinates.idl \ > WebCore/page/DOMSelection.idl \ > WebCore/page/DOMWindow.idl \ >+ WebCore/page/EventSource.idl \ > WebCore/page/Geolocation.idl \ > WebCore/page/Geoposition.idl \ > WebCore/page/History.idl \ >@@ -345,6 +346,9 @@ webcore_sources += \ > WebCore/bindings/js/JSEventCustom.cpp \ > WebCore/bindings/js/JSEventListener.cpp \ > WebCore/bindings/js/JSEventListener.h \ >+ WebCore/bindings/js/JSEventSourceConstructor.cpp \ >+ WebCore/bindings/js/JSEventSourceConstructor.h \ >+ WebCore/bindings/js/JSEventSourceCustom.cpp \ > WebCore/bindings/js/JSEventTarget.cpp \ > WebCore/bindings/js/JSEventTarget.h \ > WebCore/bindings/js/JSGeolocationCustom.cpp \ >@@ -1270,6 +1274,8 @@ webcore_sources += \ > WebCore/page/EditorClient.h \ > WebCore/page/EventHandler.cpp \ > WebCore/page/EventHandler.h \ >+ WebCore/page/EventSource.cpp \ >+ WebCore/page/EventSource.h \ > WebCore/page/FocusController.cpp \ > WebCore/page/FocusController.h \ > WebCore/page/FocusDirection.h \ >@@ -2122,6 +2128,20 @@ webcore_cppflags += -DENABLE_DATABASE=0 > endif # END ENABLE_DATABASE > > # ---- >+# HTML5 server-sent events >+# ---- >+if !ENABLE_EVENTSOURCE >+global_cppflags += -DENABLE_EVENTSOURCE=0 >+endif >+ >+if ENABLE_EVENTSOURCE >+FEATURE_DEFINES_JAVASCRIPT += ENABLE_EVENTSOURCE=1 >+ >+webcore_cppflags += \ >+ -DENABLE_EVENTSOURCE=1 >+endif # ENABLE_EVENTSOURCE >+ >+# ---- > # HTML5 client-side session and persistent storage > # ---- > if ENABLE_DOM_STORAGE >Index: WebCore/WebCore.pro >=================================================================== >--- WebCore/WebCore.pro (revision 47105) >+++ WebCore/WebCore.pro (working copy) >@@ -106,6 +106,7 @@ contains(DEFINES, ENABLE_SINGLE_THREADED > > !contains(DEFINES, ENABLE_JAVASCRIPT_DEBUGGER=.): DEFINES += ENABLE_JAVASCRIPT_DEBUGGER=1 > !contains(DEFINES, ENABLE_DATABASE=.): DEFINES += ENABLE_DATABASE=1 >+!contains(DEFINES, ENABLE_EVENTSOURCE=.): DEFINES += ENABLE_EVENTSOURCE=1 > !contains(DEFINES, ENABLE_OFFLINE_WEB_APPLICATIONS=.): DEFINES += ENABLE_OFFLINE_WEB_APPLICATIONS=1 > !contains(DEFINES, ENABLE_DOM_STORAGE=.): DEFINES += ENABLE_DOM_STORAGE=1 > !contains(DEFINES, ENABLE_ICONDATABASE=.): DEFINES += ENABLE_ICONDATABASE=1 >@@ -431,6 +432,7 @@ IDL_BINDINGS += \ > page/Coordinates.idl \ > page/DOMSelection.idl \ > page/DOMWindow.idl \ >+ page/EventSource.idl \ > page/Geolocation.idl \ > page/Geoposition.idl \ > page/History.idl \ >@@ -646,6 +648,8 @@ SOURCES += \ > bindings/js/JSDOMWindowShell.cpp \ > bindings/js/JSElementCustom.cpp \ > bindings/js/JSEventCustom.cpp \ >+ bindings/js/JSEventSourceConstructor.cpp \ >+ bindings/js/JSEventSourceCustom.cpp \ > bindings/js/JSEventTarget.cpp \ > bindings/js/JSGeolocationCustom.cpp \ > bindings/js/JSHTMLAllCollection.cpp \ >@@ -1077,6 +1081,7 @@ SOURCES += \ > page/NavigatorBase.cpp \ > page/DragController.cpp \ > page/EventHandler.cpp \ >+ page/EventSource.cpp \ > page/FocusController.cpp \ > page/Frame.cpp \ > page/FrameTree.cpp \ >@@ -1324,6 +1329,7 @@ HEADERS += \ > bindings/js/JSDOMWindowCustom.h \ > bindings/js/JSDOMWindowShell.h \ > bindings/js/JSEventListener.h \ >+ bindings/js/JSEventSourceConstructor.h \ > bindings/js/JSEventTarget.h \ > bindings/js/JSHistoryCustom.h \ > bindings/js/JSHTMLAllCollection.h \ >@@ -1749,6 +1755,7 @@ HEADERS += \ > page/DOMWindow.h \ > page/DragController.h \ > page/EventHandler.h \ >+ page/EventSource.h \ > page/FocusController.h \ > page/Frame.h \ > page/FrameTree.h \ >@@ -2427,6 +2434,10 @@ contains(DEFINES, ENABLE_DATAGRID=1) { > FEATURE_DEFINES_JAVASCRIPT += ENABLE_DATAGRID=1 > } > >+contains(DEFINES, ENABLE_EVENTSOURCE=1) { >+ FEATURE_DEFINES_JAVASCRIPT += ENABLE_EVENTSOURCE=1 >+} >+ > contains(DEFINES, ENABLE_SQLITE=1) { > !system-sqlite:exists( $${SQLITE3SRCDIR}/sqlite3.c ) { > # Build sqlite3 into WebCore from source >Index: WebCore/Configurations/FeatureDefines.xcconfig >=================================================================== >--- WebCore/Configurations/FeatureDefines.xcconfig (revision 47105) >+++ WebCore/Configurations/FeatureDefines.xcconfig (working copy) >@@ -38,6 +38,7 @@ ENABLE_CHANNEL_MESSAGING = ENABLE_CHANNE > ENABLE_DATABASE = ENABLE_DATABASE; > ENABLE_DATAGRID = ENABLE_DATAGRID; > ENABLE_DOM_STORAGE = ENABLE_DOM_STORAGE; >+ENABLE_EVENTSOURCE = ENABLE_EVENTSOURCE; > ENABLE_FILTERS = ; > ENABLE_GEOLOCATION = ; > ENABLE_ICONDATABASE = ENABLE_ICONDATABASE; >@@ -60,4 +61,4 @@ ENABLE_WORKERS = ENABLE_WORKERS; > ENABLE_XPATH = ENABLE_XPATH; > ENABLE_XSLT = ENABLE_XSLT; > >-FEATURE_DEFINES = $(ENABLE_3D_CANVAS) $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DOM_STORAGE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_RUBY) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT); >+FEATURE_DEFINES = $(ENABLE_3D_CANVAS) $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DOM_STORAGE) $(ENABLE_EVENTSOURCE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_RUBY) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XPATH) $(ENABLE_XSLT); >Index: WebCore/WebCore.vcproj/WebCore.vcproj >=================================================================== >--- WebCore/WebCore.vcproj/WebCore.vcproj (revision 47105) >+++ WebCore/WebCore.vcproj/WebCore.vcproj (working copy) >@@ -2779,6 +2779,54 @@ > > > </File> > <File >+ RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSEventSource.cpp" >+ > >+ <FileConfiguration >+ Name="Debug|Win32" >+ ExcludedFromBuild="true" >+ > >+ <Tool >+ Name="VCCLCompilerTool" >+ /> >+ </FileConfiguration> >+ <FileConfiguration >+ Name="Release|Win32" >+ ExcludedFromBuild="true" >+ > >+ <Tool >+ Name="VCCLCompilerTool" >+ /> >+ </FileConfiguration> >+ <FileConfiguration >+ Name="Debug_Internal|Win32" >+ ExcludedFromBuild="true" >+ > >+ <Tool >+ Name="VCCLCompilerTool" >+ /> >+ </FileConfiguration> >+ <FileConfiguration >+ Name="Debug_Cairo|Win32" >+ ExcludedFromBuild="true" >+ > >+ <Tool >+ Name="VCCLCompilerTool" >+ /> >+ </FileConfiguration> >+ <FileConfiguration >+ Name="Release_Cairo|Win32" >+ ExcludedFromBuild="true" >+ > >+ <Tool >+ Name="VCCLCompilerTool" >+ /> >+ </FileConfiguration> >+ </File> >+ <File >+ RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSEventSource.h" >+ > >+ </File> >+ <File > RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSFile.cpp" > > > <FileConfiguration >@@ -16813,6 +16861,14 @@ > > > </File> > <File >+ RelativePath="..\page\EventSource.cpp" >+ > >+ </File> >+ <File >+ RelativePath="..\page\EventSource.h" >+ > >+ </File> >+ <File > RelativePath="..\page\FocusController.cpp" > > > </File> >@@ -28775,6 +28831,18 @@ > > > </File> > <File >+ RelativePath="..\bindings\js\JSEventSourceConstructor.cpp" >+ > >+ </File> >+ <File >+ RelativePath="..\bindings\js\JSEventSourceConstructor.h" >+ > >+ </File> >+ <File >+ RelativePath="..\bindings\js\JSEventSourceCustom.cpp" >+ > >+ </File> >+ <File > RelativePath="..\bindings\js\JSEventTarget.cpp" > > > </File> >Index: WebCore/WebCore.xcodeproj/project.pbxproj >=================================================================== >--- WebCore/WebCore.xcodeproj/project.pbxproj (revision 47105) >+++ WebCore/WebCore.xcodeproj/project.pbxproj (working copy) >@@ -4402,6 +4402,13 @@ > DD763BB20992C2C900740B8E /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DD763BB10992C2C900740B8E /* libxml2.dylib */; }; > DD7CDF250A23CF9800069928 /* CSSUnknownRule.h in Headers */ = {isa = PBXBuildFile; fileRef = A80E6CCE0A1989CA007FB8C5 /* CSSUnknownRule.h */; }; > DDE63ED50B7D45A800226998 /* DOMTextEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 933A14750B7D1BAF00A53FFD /* DOMTextEvent.h */; }; >+ E0FEF372B17C53EAC1C1FBEE /* EventSource.h in Headers */ = {isa = PBXBuildFile; fileRef = E0FEF371B17C53EAC1C1FBEE /* EventSource.h */; }; >+ E0FEF372B27C53EAC1C1FBEE /* EventSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E0FEF371B27C53EAC1C1FBEE /* EventSource.cpp */; }; >+ E0FEF372B37C53EAC1C1FBEE /* JSEventSource.h in Headers */ = {isa = PBXBuildFile; fileRef = E0FEF371B37C53EAC1C1FBEE /* JSEventSource.h */; }; >+ E0FEF372B47C53EAC1C1FBEE /* JSEventSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E0FEF371B47C53EAC1C1FBEE /* JSEventSource.cpp */; }; >+ E0FEF372B57C53EAC1C1FBEE /* JSEventSourceCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E0FEF371B57C53EAC1C1FBEE /* JSEventSourceCustom.cpp */; }; >+ E0FEF372B67C53EAC1C1FBEE /* JSEventSourceConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = E0FEF371B67C53EAC1C1FBEE /* JSEventSourceConstructor.h */; }; >+ E0FEF372B77C53EAC1C1FBEE /* JSEventSourceConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E0FEF371B77C53EAC1C1FBEE /* JSEventSourceConstructor.cpp */; }; > E107400D0E77BDC00033AF24 /* JSMessageChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E107400B0E77BDC00033AF24 /* JSMessageChannel.cpp */; }; > E107400E0E77BDC00033AF24 /* JSMessageChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = E107400C0E77BDC00033AF24 /* JSMessageChannel.h */; }; > E10743240E7835830033AF24 /* JSMessageChannelConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E10743230E7835830033AF24 /* JSMessageChannelConstructor.cpp */; }; >@@ -9327,6 +9334,14 @@ > DB23C2CA0A508D29002489EB /* IndentOutdentCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IndentOutdentCommand.h; sourceTree = "<group>"; }; > DD05FE0B0B8BA3C6009ACDFE /* WebCoreObjCExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreObjCExtras.h; sourceTree = "<group>"; }; > DD763BB10992C2C900740B8E /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = /usr/lib/libxml2.dylib; sourceTree = "<absolute>"; }; >+ E0FEF371B07C53EAC1C1FBEE /* EventSource.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventSource.idl; sourceTree = "<group>"; }; >+ E0FEF371B17C53EAC1C1FBEE /* EventSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSource.h; sourceTree = "<group>"; }; >+ E0FEF371B27C53EAC1C1FBEE /* EventSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventSource.cpp; sourceTree = "<group>"; }; >+ E0FEF371B37C53EAC1C1FBEE /* JSEventSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventSource.h; sourceTree = "<group>"; }; >+ E0FEF371B47C53EAC1C1FBEE /* JSEventSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEventSource.cpp; sourceTree = "<group>"; }; >+ E0FEF371B57C53EAC1C1FBEE /* JSEventSourceCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEventSourceCustom.cpp; sourceTree = "<group>"; }; >+ E0FEF371B67C53EAC1C1FBEE /* JSEventSourceConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEventSourceConstructor.h; sourceTree = "<group>"; }; >+ E0FEF371B77C53EAC1C1FBEE /* JSEventSourceConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEventSourceConstructor.cpp; sourceTree = "<group>"; }; > E107400B0E77BDC00033AF24 /* JSMessageChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageChannel.cpp; sourceTree = "<group>"; }; > E107400C0E77BDC00033AF24 /* JSMessageChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMessageChannel.h; sourceTree = "<group>"; }; > E10743230E7835830033AF24 /* JSMessageChannelConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMessageChannelConstructor.cpp; sourceTree = "<group>"; }; >@@ -10608,6 +10623,9 @@ > 1AF326770D78B9440068F0C4 /* EditorClient.h */, > 93C09A800B064F00005ABD4D /* EventHandler.cpp */, > 93C09A520B064DB3005ABD4D /* EventHandler.h */, >+ E0FEF371B27C53EAC1C1FBEE /* EventSource.cpp */, >+ E0FEF371B17C53EAC1C1FBEE /* EventSource.h */, >+ E0FEF371B07C53EAC1C1FBEE /* EventSource.idl */, > 14993BE30B2F2B1C0050497F /* FocusController.cpp */, > 14993BE40B2F2B1C0050497F /* FocusController.h */, > 062287830B4DB322000C34DF /* FocusDirection.h */, >@@ -13659,6 +13677,8 @@ > BCBFB53B0DCD29CF0019B3E5 /* JSDOMWindowShell.h */, > 93B70D4D09EB0C7C009D8468 /* JSEventListener.cpp */, > 93B70D4E09EB0C7C009D8468 /* JSEventListener.h */, >+ E0FEF371B67C53EAC1C1FBEE /* JSEventSourceConstructor.h */, >+ E0FEF371B77C53EAC1C1FBEE /* JSEventSourceConstructor.cpp */, > BC60901E0E91B8EC000C68B5 /* JSEventTarget.cpp */, > BC60901D0E91B8EC000C68B5 /* JSEventTarget.h */, > 9350E70C0E87500B00189FFF /* JSHTMLAllCollection.cpp */, >@@ -13824,6 +13844,7 @@ > 652FBBBB0DE27CB60001D386 /* JSDOMWindowCustom.h */, > BC2ED5540C6B9BD300920BFF /* JSElementCustom.cpp */, > BCEFAF4D0C317E6900FA81F6 /* JSEventCustom.cpp */, >+ E0FEF371B57C53EAC1C1FBEE /* JSEventSourceCustom.cpp */, > FE80D7A60E9C1ED2000D6F75 /* JSGeolocationCustom.cpp */, > BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */, > BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */, >@@ -13957,6 +13978,8 @@ > BC5A86B40C3367E800EEA649 /* JSDOMSelection.h */, > 1403BA0B09EB18C700797C7F /* JSDOMWindow.cpp */, > 1403BA0E09EB18F800797C7F /* JSDOMWindow.h */, >+ E0FEF371B37C53EAC1C1FBEE /* JSEventSource.h */, >+ E0FEF371B47C53EAC1C1FBEE /* JSEventSource.cpp */, > BC94D14C0C275C68006BC617 /* JSHistory.cpp */, > BC94D14D0C275C68006BC617 /* JSHistory.h */, > BCE1C4390D9830D3003B02F2 /* JSLocation.cpp */, >@@ -15922,6 +15945,7 @@ > 935FBC4509BA00B900E230B1 /* EventListener.h in Headers */, > 1CA19E160DC255CA0065A994 /* EventLoop.h in Headers */, > 939885C408B7E3D100E707C4 /* EventNames.h in Headers */, >+ E0FEF372B17C53EAC1C1FBEE /* EventSource.h in Headers */, > E12EDB7B0B308A78002704B6 /* EventTarget.h in Headers */, > BC60D8F30D2A11E000B9918F /* ExceptionBase.h in Headers */, > 935FBCF209BA143B00E230B1 /* ExceptionCode.h in Headers */, >@@ -16207,6 +16231,8 @@ > 14E8378E09F85D4F00B85AE4 /* JSEvent.h in Headers */, > BC60D9C00D2A269A00B9918F /* JSEventException.h in Headers */, > 93B70D6A09EB0C7C009D8468 /* JSEventListener.h in Headers */, >+ E0FEF372B37C53EAC1C1FBEE /* JSEventSource.h in Headers */, >+ E0FEF372B67C53EAC1C1FBEE /* JSEventSourceConstructor.h in Headers */, > BC60901F0E91B8EC000C68B5 /* JSEventTarget.h in Headers */, > BC00F0150E0A189500FD04E3 /* JSFile.h in Headers */, > BC00F0170E0A189500FD04E3 /* JSFileList.h in Headers */, >@@ -17982,6 +18008,7 @@ > 93C09A7F0B064EEF005ABD4D /* EventHandlerMac.mm in Sources */, > 1CA19E050DC255950065A994 /* EventLoopMac.mm in Sources */, > 939885C308B7E3D100E707C4 /* EventNames.cpp in Sources */, >+ E0FEF372B27C53EAC1C1FBEE /* EventSource.cpp in Sources */, > E12EDBEA0B308E0B002704B6 /* EventTarget.cpp in Sources */, > BC60D8F20D2A11E000B9918F /* ExceptionBase.cpp in Sources */, > 93831B570D087D6000E5C984 /* ExceptionCode.cpp in Sources */, >@@ -18288,6 +18315,9 @@ > BCEFAF4E0C317E6900FA81F6 /* JSEventCustom.cpp in Sources */, > BC60D9BF0D2A269A00B9918F /* JSEventException.cpp in Sources */, > 93B70D6909EB0C7C009D8468 /* JSEventListener.cpp in Sources */, >+ E0FEF372B47C53EAC1C1FBEE /* JSEventSource.cpp in Sources */, >+ E0FEF372B77C53EAC1C1FBEE /* JSEventSourceConstructor.cpp in Sources */, >+ E0FEF372B57C53EAC1C1FBEE /* JSEventSourceCustom.cpp in Sources */, > BC6090200E91B8EC000C68B5 /* JSEventTarget.cpp in Sources */, > BC00F0140E0A189500FD04E3 /* JSFile.cpp in Sources */, > BC00F0160E0A189500FD04E3 /* JSFileList.cpp in Sources */, >Index: WebCore/bindings/js/JSDOMWindowCustom.cpp >=================================================================== >--- WebCore/bindings/js/JSDOMWindowCustom.cpp (revision 47105) >+++ WebCore/bindings/js/JSDOMWindowCustom.cpp (working copy) >@@ -38,6 +38,7 @@ > #include "JSDOMWindowShell.h" > #include "JSEvent.h" > #include "JSEventListener.h" >+#include "JSEventSourceConstructor.h" > #include "JSHTMLCollection.h" > #include "JSHistory.h" > #include "JSImageConstructor.h" >@@ -425,6 +426,13 @@ JSValue JSDOMWindow::event(ExecState* ex > return toJS(exec, event); > } > >+#if ENABLE(EVENTSOURCE) >+JSValue JSDOMWindow::eventSource(ExecState* exec) const >+{ >+ return getDOMConstructor<JSEventSourceConstructor>(exec, this); >+} >+#endif >+ > JSValue JSDOMWindow::image(ExecState* exec) const > { > return getDOMConstructor<JSImageConstructor>(exec, this); >Index: WebCore/bindings/js/JSEventSourceConstructor.cpp >=================================================================== >--- WebCore/bindings/js/JSEventSourceConstructor.cpp (revision 0) >+++ WebCore/bindings/js/JSEventSourceConstructor.cpp (revision 0) >@@ -0,0 +1,90 @@ >+/* >+ * Copyright (C) 2009 Ericsson AB >+ * All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * 3. Neither the name of Ericsson nor the names of its contributors >+ * may be used to endorse or promote products derived from this >+ * software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(EVENTSOURCE) >+ >+#include "JSEventSourceConstructor.h" >+ >+#include "EventSource.h" >+#include "ExceptionCode.h" >+#include "JSEventSource.h" >+#include "ScriptExecutionContext.h" >+ >+using namespace JSC; >+ >+namespace WebCore { >+ >+ASSERT_CLASS_FITS_IN_CELL(JSEventSourceConstructor); >+ >+const ClassInfo JSEventSourceConstructor::s_info = { "EventSourceContructor", 0, 0, 0 }; >+ >+JSEventSourceConstructor::JSEventSourceConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) >+ : DOMConstructorObject(JSEventSourceConstructor::createStructure(globalObject->objectPrototype()), globalObject) >+{ >+ putDirect(exec->propertyNames().prototype, JSEventSourcePrototype::self(exec, globalObject), None); >+ putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly|DontDelete|DontEnum); >+} >+ >+static JSObject* constructEventSource(ExecState* exec, JSObject* constructor, const ArgList& args) >+{ >+ if (args.size() < 1) >+ return throwError(exec, SyntaxError, "Not enough arguments"); >+ >+ UString url = args.at(0).toString(exec); >+ if (exec->hadException()) >+ return 0; >+ >+ JSEventSourceConstructor* jsConstructor = static_cast<JSEventSourceConstructor*>(constructor); >+ ScriptExecutionContext* context = jsConstructor->scriptExecutionContext(); >+ if (!context) >+ return throwError(exec, ReferenceError, "EventSource constructor associated document is unavailable"); >+ >+ ExceptionCode ec = 0; >+ RefPtr<EventSource> eventSource = EventSource::create(url, context, ec); >+ if (ec) { >+ setDOMException(exec, ec); >+ return 0; >+ } >+ >+ return asObject(toJS(exec, jsConstructor->globalObject(), eventSource.release())); >+} >+ >+ConstructType JSEventSourceConstructor::getConstructData(ConstructData& constructData) >+{ >+ constructData.native.function = constructEventSource; >+ return ConstructTypeHost; >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(EVENTSOURCE) >Index: WebCore/bindings/js/JSEventSourceConstructor.h >=================================================================== >--- WebCore/bindings/js/JSEventSourceConstructor.h (revision 0) >+++ WebCore/bindings/js/JSEventSourceConstructor.h (revision 0) >@@ -0,0 +1,55 @@ >+/* >+ * Copyright (C) 2009 Ericsson AB >+ * All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * 3. Neither the name of Ericsson nor the names of its contributors >+ * may be used to endorse or promote products derived from this >+ * software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef JSEventSourceConstructor_h >+#define JSEventSourceConstructor_h >+ >+#if ENABLE(EVENTSOURCE) >+ >+#include "JSDOMBinding.h" >+ >+namespace WebCore { >+ >+ class JSEventSourceConstructor : public DOMConstructorObject { >+ public: >+ JSEventSourceConstructor(JSC::ExecState*, JSDOMGlobalObject*); >+ static const JSC::ClassInfo s_info; >+ >+ private: >+ virtual JSC::ConstructType getConstructData(JSC::ConstructData&); >+ virtual const JSC::ClassInfo* classInfo() const { return &s_info; } >+ }; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(EVENTSOURCE) >+ >+#endif // JSEventSourceConstructor_h >Index: WebCore/bindings/js/JSEventSourceCustom.cpp >=================================================================== >--- WebCore/bindings/js/JSEventSourceCustom.cpp (revision 0) >+++ WebCore/bindings/js/JSEventSourceCustom.cpp (revision 0) >@@ -0,0 +1,89 @@ >+/* >+ * Copyright (C) 2009 Ericsson AB >+ * All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * 3. Neither the name of Ericsson nor the names of its contributors >+ * may be used to endorse or promote products derived from this >+ * software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(EVENTSOURCE) >+ >+#include "JSEventSource.h" >+ >+#include "EventSource.h" >+#include "JSDOMGlobalObject.h" >+#include "JSEventListener.h" >+ >+using namespace JSC; >+ >+namespace WebCore { >+ >+void JSEventSource::markChildren(MarkStack& markStack) >+{ >+ DOMObject::markChildren(markStack); >+ >+ markIfNotNull(markStack, m_impl->onopen()); >+ markIfNotNull(markStack, m_impl->onmessage()); >+ markIfNotNull(markStack, m_impl->onerror()); >+ >+ typedef EventSource::EventListenersMap EventListenersMap; >+ typedef EventSource::ListenerVector ListenerVector; >+ EventListenersMap& eventListeners = m_impl->eventListeners(); >+ for (EventListenersMap::iterator mapIter = eventListeners.begin(); mapIter != eventListeners.end(); ++mapIter) { >+ for (ListenerVector::iterator vecIter = mapIter->second.begin(); vecIter != mapIter->second.end(); ++vecIter) >+ (*vecIter)->markJSFunction(markStack); >+ } >+} >+ >+JSValue JSEventSource::addEventListener(ExecState* exec, const ArgList& args) >+{ >+ JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); >+ if (!globalObject) >+ return jsUndefined(); >+ RefPtr<JSEventListener> listener = globalObject->findOrCreateJSEventListener(args.at(1)); >+ if (!listener) >+ return jsUndefined(); >+ impl()->addEventListener(args.at(0).toString(exec), listener.release(), args.at(2).toBoolean(exec)); >+ return jsUndefined(); >+} >+ >+JSValue JSEventSource::removeEventListener(ExecState* exec, const ArgList& args) >+{ >+ JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(impl()->scriptExecutionContext()); >+ if (!globalObject) >+ return jsUndefined(); >+ JSEventListener* listener = globalObject->findJSEventListener(args.at(1)); >+ if (!listener) >+ return jsUndefined(); >+ impl()->removeEventListener(args.at(0).toString(exec), listener, args.at(2).toBoolean(exec)); >+ return jsUndefined(); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(EVENTSOURCE) >Index: WebCore/bindings/js/JSEventTarget.cpp >=================================================================== >--- WebCore/bindings/js/JSEventTarget.cpp (revision 47105) >+++ WebCore/bindings/js/JSEventTarget.cpp (working copy) >@@ -43,6 +43,11 @@ > #include "XMLHttpRequest.h" > #include "XMLHttpRequestUpload.h" > >+#if ENABLE(EVENTSOURCE) >+#include "EventSource.h" >+#include "JSEventSource.h" >+#endif >+ > #if ENABLE(OFFLINE_WEB_APPLICATIONS) > #include "DOMApplicationCache.h" > #include "JSDOMApplicationCache.h" >@@ -74,6 +79,11 @@ JSValue toJS(ExecState* exec, JSDOMGloba > if (!target) > return jsNull(); > >+#if ENABLE(EVENTSOURCE) >+ if (EventSource* eventSource = target->toEventSource()) >+ return toJS(exec, globalObject, eventSource); >+#endif >+ > #if ENABLE(SVG) > // SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node. > if (SVGElementInstance* instance = target->toSVGElementInstance()) >@@ -139,6 +149,10 @@ EventTarget* toEventTarget(JSC::JSValue > if (value.isObject(&JSDOMWindowShell::s_info)) > return static_cast<JSDOMWindowShell*>(asObject(value))->impl(); > >+#if ENABLE(EVENTSOURCE) >+ CONVERT_TO_EVENT_TARGET(EventSource) >+#endif >+ > #if ENABLE(OFFLINE_WEB_APPLICATIONS) > CONVERT_TO_EVENT_TARGET(DOMApplicationCache) > #endif >Index: WebCore/bindings/js/JSWorkerContextCustom.cpp >=================================================================== >--- WebCore/bindings/js/JSWorkerContextCustom.cpp (revision 47105) >+++ WebCore/bindings/js/JSWorkerContextCustom.cpp (working copy) >@@ -43,6 +43,10 @@ > #include "WorkerNavigator.h" > #include <interpreter/Interpreter.h> > >+#if ENABLE(EVENTSOURCE) >+#include "JSEventSourceConstructor.h" >+#endif >+ > using namespace JSC; > > namespace WebCore { >@@ -77,6 +81,13 @@ bool JSWorkerContext::getOwnPropertySlot > return false; > } > >+#if ENABLE(EVENTSOURCE) >+JSValue JSWorkerContext::eventSource(ExecState* exec) const >+{ >+ return getDOMConstructor<JSEventSourceConstructor>(exec, this); >+} >+#endif >+ > JSValue JSWorkerContext::xmlHttpRequest(ExecState* exec) const > { > return getDOMConstructor<JSXMLHttpRequestConstructor>(exec, this); >Index: WebCore/dom/EventNames.h >=================================================================== >--- WebCore/dom/EventNames.h (revision 47105) >+++ WebCore/dom/EventNames.h (working copy) >@@ -73,6 +73,7 @@ namespace WebCore { > macro(obsolete) \ > macro(offline) \ > macro(online) \ >+ macro(open) \ > macro(overflowchanged) \ > macro(paste) \ > macro(readystatechange) \ >Index: WebCore/dom/EventTarget.cpp >=================================================================== >--- WebCore/dom/EventTarget.cpp (revision 47105) >+++ WebCore/dom/EventTarget.cpp (working copy) >@@ -44,6 +44,11 @@ EventTarget::~EventTarget() > { > } > >+EventSource* EventTarget::toEventSource() >+{ >+ return 0; >+} >+ > Node* EventTarget::toNode() > { > return 0; >Index: WebCore/dom/EventTarget.h >=================================================================== >--- WebCore/dom/EventTarget.h (revision 47105) >+++ WebCore/dom/EventTarget.h (working copy) >@@ -43,6 +43,7 @@ namespace WebCore { > class DOMWindow; > class Event; > class EventListener; >+ class EventSource; > class MessagePort; > class Node; > class Notification; >@@ -58,6 +59,7 @@ namespace WebCore { > > class EventTarget { > public: >+ virtual EventSource* toEventSource(); > virtual MessagePort* toMessagePort(); > virtual Node* toNode(); > virtual DOMWindow* toDOMWindow(); >Index: WebCore/page/DOMWindow.idl >=================================================================== >--- WebCore/page/DOMWindow.idl (revision 47105) >+++ WebCore/page/DOMWindow.idl (working copy) >@@ -444,6 +444,10 @@ module window { > attribute RangeConstructor Range; > attribute RangeExceptionConstructor RangeException; > >+#if ENABLE_EVENTSOURCE >+ attribute [JSCCustomGetter] EventSourceConstructor EventSource; // Usable with new the operator >+#endif >+ > // Mozilla has a separate XMLDocument object for XML documents. > // We just use Document for this. > attribute DocumentConstructor XMLDocument; >Index: WebCore/page/EventSource.cpp >=================================================================== >--- WebCore/page/EventSource.cpp (revision 0) >+++ WebCore/page/EventSource.cpp (revision 0) >@@ -0,0 +1,365 @@ >+/* >+ * Copyright (C) 2009 Ericsson AB >+ * All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * 3. Neither the name of Ericsson nor the names of its contributors >+ * may be used to endorse or promote products derived from this >+ * software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#if ENABLE(EVENTSOURCE) >+ >+#include "EventSource.h" >+ >+#include "Cache.h" >+#include "DOMWindow.h" >+#include "Event.h" >+#include "EventException.h" >+#include "PlatformString.h" >+#include "MessageEvent.h" >+#include "ResourceError.h" >+#include "ResourceRequest.h" >+#include "ResourceResponse.h" >+#include "ScriptExecutionContext.h" >+#include "TextResourceDecoder.h" >+#include "ThreadableLoader.h" >+ >+namespace WebCore { >+ >+const unsigned long long EventSource::defaultReconnectDelay = 3000; >+ >+EventSource::EventSource(const String& url, ScriptExecutionContext* context, ExceptionCode& ec) >+ : ActiveDOMObject(context, this) >+ , m_state(CONNECTING) >+ , m_reconnectTimer(this, &EventSource::reconnectTimerFired) >+ , m_failSilently(false) >+ , m_requestInFlight(false) >+ , m_reconnectDelay(defaultReconnectDelay) >+{ >+ if (url.isEmpty() || !(m_url = context->completeURL(url)).isValid()) { >+ ec = SYNTAX_ERR; >+ return; >+ } >+ // FIXME: should support cross-origin requests >+ if (!scriptExecutionContext()->securityOrigin()->canRequest(m_url)) { >+ ec = SECURITY_ERR; >+ return; >+ } >+ >+ m_origin = scriptExecutionContext()->securityOrigin()->toString(); >+ m_decoder = TextResourceDecoder::create("text/plain", "UTF-8"); >+ >+ setPendingActivity(this); >+ connect(); >+} >+ >+EventSource::~EventSource() >+{ >+} >+ >+void EventSource::connect() >+{ >+ ResourceRequest request(m_url); >+ request.setHTTPMethod("GET"); >+ request.setHTTPHeaderField("Accept", "text/event-stream"); >+ request.setHTTPHeaderField("Cache-Control", "no-cache"); >+ if (!m_lastEventId.isEmpty()) >+ request.setHTTPHeaderField("Last-Event-ID", m_lastEventId); >+ m_loader = ThreadableLoader::create(scriptExecutionContext(), this, request, SendLoadCallbacks, DoNotSniffContent, AllowStoredCredentials, DenyCrossOriginRedirect); >+ m_requestInFlight = true; >+ >+ if (!scriptExecutionContext()->isWorkerContext()) >+ cache()->loader()->nonCacheRequestInFlight(m_url); >+} >+ >+void EventSource::endRequest() >+{ >+ m_requestInFlight = false; >+ >+ if (!m_failSilently) >+ dispatchGenericEvent(eventNames().errorEvent); >+ >+ if (!scriptExecutionContext()->isWorkerContext()) >+ cache()->loader()->nonCacheRequestComplete(m_url); >+ >+ if (m_state != CLOSED) >+ scheduleReconnect(); >+ else >+ unsetPendingActivity(this); >+} >+ >+void EventSource::scheduleReconnect() >+{ >+ m_state = CONNECTING; >+ m_reconnectTimer.startOneShot(m_reconnectDelay / 1000); >+} >+ >+void EventSource::reconnectTimerFired(Timer<EventSource>*) >+{ >+ connect(); >+} >+ >+String EventSource::url() const >+{ >+ return m_url.string(); >+} >+ >+EventSource::State EventSource::readyState() const >+{ >+ return m_state; >+} >+ >+void EventSource::close() >+{ >+ if (m_state == CLOSED) >+ return; >+ >+ if (m_reconnectTimer.isActive()) { >+ m_reconnectTimer.stop(); >+ unsetPendingActivity(this); >+ } >+ >+ m_state = CLOSED; >+ m_failSilently = true; >+ >+ if (m_requestInFlight) >+ m_loader->cancel(); >+} >+ >+ScriptExecutionContext* EventSource::scriptExecutionContext() const >+{ >+ return ActiveDOMObject::scriptExecutionContext(); >+} >+ >+void EventSource::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> eventListener, bool) >+{ >+ EventListenersMap::iterator iter = m_eventListeners.find(eventType); >+ if (iter == m_eventListeners.end()) { >+ ListenerVector listeners; >+ listeners.append(eventListener); >+ m_eventListeners.add(eventType, listeners); >+ } else { >+ ListenerVector& listeners = iter->second; >+ for (ListenerVector::iterator listenerIter = listeners.begin(); listenerIter != listeners.end(); ++listenerIter) { >+ if (*listenerIter == eventListener) >+ return; >+ } >+ >+ listeners.append(eventListener); >+ m_eventListeners.add(eventType, listeners); >+ } >+} >+ >+void EventSource::removeEventListener(const AtomicString& eventType, EventListener* eventListener, bool) >+{ >+ EventListenersMap::iterator iter = m_eventListeners.find(eventType); >+ if (iter == m_eventListeners.end()) >+ return; >+ >+ ListenerVector& listeners = iter->second; >+ for (ListenerVector::const_iterator listenerIter = listeners.begin(); listenerIter != listeners.end(); ++listenerIter) { >+ if (*listenerIter == eventListener) { >+ listeners.remove(listenerIter - listeners.begin()); >+ return; >+ } >+ } >+} >+ >+bool EventSource::dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec) >+{ >+ if (!event || event->type().isEmpty()) { >+ ec = EventException::UNSPECIFIED_EVENT_TYPE_ERR; >+ return true; >+ } >+ >+ EventListener* attributeListener = m_attributeListeners.get(event->type()).get(); >+ if (attributeListener) { >+ event->setTarget(this); >+ event->setCurrentTarget(this); >+ attributeListener->handleEvent(event.get(), false); >+ } >+ >+ ListenerVector listenersCopy = m_eventListeners.get(event->type()); >+ for (ListenerVector::const_iterator listenerIter = listenersCopy.begin(); listenerIter != listenersCopy.end(); ++listenerIter) { >+ event->setTarget(this); >+ event->setCurrentTarget(this); >+ listenerIter->get()->handleEvent(event.get(), false); >+ } >+ >+ return !event->defaultPrevented(); >+} >+ >+void EventSource::didReceiveResponse(const ResourceResponse& response) >+{ >+ int statusCode = response.httpStatusCode(); >+ if (statusCode == 200 && response.httpHeaderField("Content-Type") == "text/event-stream") { >+ m_state = OPEN; >+ dispatchGenericEvent(eventNames().openEvent); >+ } else { >+ if (statusCode <= 200 || statusCode > 299) >+ m_state = CLOSED; >+ m_loader->cancel(); >+ } >+} >+ >+void EventSource::didReceiveData(const char* data, int length) >+{ >+ append(m_receiveBuf, m_decoder->decode(data, length)); >+ parseEventStream(); >+} >+ >+void EventSource::didFinishLoading(unsigned long) >+{ >+ if (m_receiveBuf.size() > 0 || m_data.size() > 0) { >+ append(m_receiveBuf, "\n\n"); >+ parseEventStream(); >+ } >+ m_state = CONNECTING; >+ endRequest(); >+} >+ >+void EventSource::didFail(const ResourceError& error) >+{ >+ int canceled = error.isCancellation(); >+ if (((m_state == CONNECTING) && !canceled) || ((m_state == OPEN) && canceled)) >+ m_state = CLOSED; >+ endRequest(); >+} >+ >+void EventSource::didFailRedirectCheck() >+{ >+ m_state = CLOSED; >+ m_loader->cancel(); >+} >+ >+void EventSource::parseEventStream() >+{ >+ unsigned int bufPos = 0; >+ unsigned int bufSize = m_receiveBuf.size(); >+ for (;;) { >+ int lineLength = -1; >+ int fieldLength = -1; >+ int carriageReturn = 0; >+ for (unsigned int i = bufPos; lineLength < 0 && i < bufSize; i++) { >+ switch (m_receiveBuf[i]) { >+ case ':': >+ if (fieldLength < 0) >+ fieldLength = i - bufPos; >+ break; >+ case '\n': >+ if (i > bufPos && m_receiveBuf[i - 1] == '\r') { >+ carriageReturn++; >+ i--; >+ } >+ lineLength = i - bufPos; >+ break; >+ } >+ } >+ >+ if (lineLength < 0) >+ break; >+ >+ parseEventStreamLine(bufPos, fieldLength, lineLength); >+ bufPos += lineLength + carriageReturn + 1; >+ } >+ >+ if (bufPos == bufSize) >+ m_receiveBuf.clear(); >+ else if (bufPos) >+ m_receiveBuf.remove(0, bufPos); >+} >+ >+void EventSource::parseEventStreamLine(unsigned int bufPos, int fieldLength, int lineLength) >+{ >+ if (!lineLength) { >+ if (!m_data.isEmpty()) >+ dispatchMessageEvent(); >+ if (!m_eventName.isEmpty()) >+ m_eventName = ""; >+ } else if (fieldLength) { >+ bool noValue = fieldLength < 0; >+ >+ String field(&m_receiveBuf[bufPos], noValue ? lineLength : fieldLength); >+ int step; >+ if (noValue) >+ step = lineLength; >+ else if (m_receiveBuf[bufPos + fieldLength + 1] != ' ') >+ step = fieldLength + 1; >+ else >+ step = fieldLength + 2; >+ bufPos += step; >+ int valueLength = lineLength - step; >+ >+ if (field == "data") { >+ if (m_data.size() > 0) >+ m_data.append('\n'); >+ if (valueLength) >+ m_data.append(&m_receiveBuf[bufPos], valueLength); >+ } else if (field == "event") >+ m_eventName = valueLength ? String(&m_receiveBuf[bufPos], valueLength) : ""; >+ else if (field == "id") >+ m_lastEventId = valueLength ? String(&m_receiveBuf[bufPos], valueLength) : ""; >+ else if (field == "retry") { >+ if (!valueLength) >+ m_reconnectDelay = defaultReconnectDelay; >+ else { >+ String value(&m_receiveBuf[bufPos], valueLength); >+ bool ok; >+ unsigned long long retry = value.toUInt64(&ok); >+ if (ok) >+ m_reconnectDelay = retry; >+ } >+ } >+ } >+} >+ >+void EventSource::dispatchGenericEvent(const AtomicString& type) >+{ >+ RefPtr<Event> evt = Event::create(type, false, false); >+ ExceptionCode ec = 0; >+ dispatchEvent(evt.release(), ec); >+ ASSERT(!ec); >+} >+ >+void EventSource::dispatchMessageEvent() >+{ >+ RefPtr<MessageEvent> evt = MessageEvent::create(); >+ String eventName = m_eventName.isEmpty() ? eventNames().messageEvent.string() : m_eventName; >+ evt->initMessageEvent(eventName, false, false, String::adopt(m_data), m_origin, m_lastEventId, 0, 0); >+ ExceptionCode ec = 0; >+ dispatchEvent(evt.release(), ec); >+ ASSERT(!ec); >+} >+ >+void EventSource::stop() >+{ >+ close(); >+} >+ >+} // namespace WebCore >+ >+#endif // ENABLE(EVENTSOURCE) >Index: WebCore/page/EventSource.h >=================================================================== >--- WebCore/page/EventSource.h (revision 0) >+++ WebCore/page/EventSource.h (revision 0) >@@ -0,0 +1,146 @@ >+/* >+ * Copyright (C) 2009 Ericsson AB >+ * All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * 3. Neither the name of Ericsson nor the names of its contributors >+ * may be used to endorse or promote products derived from this >+ * software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef EventSource_h >+#define EventSource_h >+ >+#if ENABLE(EVENTSOURCE) >+ >+#include "ActiveDOMObject.h" >+#include "AtomicStringHash.h" >+#include "EventListener.h" >+#include "EventNames.h" >+#include "EventTarget.h" >+#include "KURL.h" >+#include "ThreadableLoaderClient.h" >+#include "Timer.h" >+ >+#include <wtf/HashMap.h> >+#include <wtf/PassRefPtr.h> >+#include <wtf/RefPtr.h> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+ class ResourceResponse; >+ class TextResourceDecoder; >+ class ThreadableLoader; >+ >+ class EventSource : public RefCounted<EventSource>, public EventTarget, private ThreadableLoaderClient, public ActiveDOMObject { >+ public: >+ static PassRefPtr<EventSource> create(const String& url, ScriptExecutionContext* context, ExceptionCode& ec) { return adoptRef(new EventSource(url, context, ec)); } >+ virtual ~EventSource(); >+ >+ static const unsigned long long defaultReconnectDelay; >+ >+ String url() const; >+ >+ enum State { >+ CONNECTING = 0, >+ OPEN = 1, >+ CLOSED = 2, >+ }; >+ >+ State readyState() const; >+ >+ void setOnopen(PassRefPtr<EventListener> eventListener) { m_attributeListeners.set(eventNames().openEvent, eventListener); } >+ EventListener* onopen() const { return m_attributeListeners.get(eventNames().openEvent).get(); } >+ >+ void setOnmessage(PassRefPtr<EventListener> eventListener) { m_attributeListeners.set(eventNames().messageEvent, eventListener); } >+ EventListener* onmessage() const { return m_attributeListeners.get(eventNames().messageEvent).get(); } >+ >+ void setOnerror(PassRefPtr<EventListener> eventListener) { m_attributeListeners.set(eventNames().errorEvent, eventListener); } >+ EventListener* onerror() const { return m_attributeListeners.get(eventNames().errorEvent).get(); } >+ >+ void close(); >+ >+ using RefCounted<EventSource>::ref; >+ using RefCounted<EventSource>::deref; >+ >+ virtual EventSource* toEventSource() { return this; } >+ virtual ScriptExecutionContext* scriptExecutionContext() const; >+ >+ typedef Vector<RefPtr<EventListener> > ListenerVector; >+ typedef HashMap<AtomicString, ListenerVector> EventListenersMap; >+ >+ virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); >+ virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture); >+ virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&); >+ EventListenersMap& eventListeners() { return m_eventListeners; } >+ >+ virtual void stop(); >+ >+ private: >+ EventSource(const String& url, ScriptExecutionContext* context, ExceptionCode& ec); >+ >+ virtual void refEventTarget() { ref(); } >+ virtual void derefEventTarget() { deref(); } >+ >+ virtual void didReceiveResponse(const ResourceResponse& response); >+ virtual void didReceiveData(const char* data, int length); >+ virtual void didFinishLoading(unsigned long); >+ virtual void didFail(const ResourceError& error); >+ virtual void didFailRedirectCheck(); >+ >+ void connect(); >+ void endRequest(); >+ void scheduleReconnect(); >+ void reconnectTimerFired(Timer<EventSource>*); >+ void parseEventStream(); >+ void parseEventStreamLine(unsigned int pos, int fieldLength, int lineLength); >+ void dispatchGenericEvent(const AtomicString& type); >+ void dispatchMessageEvent(); >+ >+ KURL m_url; >+ State m_state; >+ >+ HashMap<AtomicString, RefPtr<EventListener> > m_attributeListeners; >+ EventListenersMap m_eventListeners; >+ >+ RefPtr<TextResourceDecoder> m_decoder; >+ RefPtr<ThreadableLoader> m_loader; >+ Timer<EventSource> m_reconnectTimer; >+ Vector<UChar> m_receiveBuf; >+ bool m_failSilently; >+ bool m_requestInFlight; >+ >+ String m_eventName; >+ Vector<UChar> m_data; >+ String m_lastEventId; >+ unsigned long long m_reconnectDelay; >+ String m_origin; >+ }; >+ >+} // namespace WebCore >+ >+#endif // ENABLE(EVENTSOURCE) >+ >+#endif // EventSource_h >Index: WebCore/page/EventSource.idl >=================================================================== >--- WebCore/page/EventSource.idl (revision 0) >+++ WebCore/page/EventSource.idl (revision 0) >@@ -0,0 +1,65 @@ >+/* >+ * Copyright (C) 2009 Ericsson AB >+ * All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * 3. Neither the name of Ericsson nor the names of its contributors >+ * may be used to endorse or promote products derived from this >+ * software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+module window { >+ >+ interface [ >+ Conditional=EVENTSOURCE, >+ CustomMarkFunction, >+ NoStaticTables >+ ] EventSource { >+ >+ readonly attribute DOMString URL; >+ >+ // ready state >+ const unsigned short CONNECTING = 0; >+ const unsigned short OPEN = 1; >+ const unsigned short CLOSED = 2; >+ readonly attribute unsigned short readyState; >+ >+ // networking >+ attribute EventListener onopen; >+ attribute EventListener onmessage; >+ attribute EventListener onerror; >+ void close(); >+ >+ // EventTarget interface >+ [Custom] void addEventListener(in DOMString type, >+ in EventListener listener, >+ in boolean useCapture); >+ [Custom] void removeEventListener(in DOMString type, >+ in EventListener listener, >+ in boolean useCapture); >+ boolean dispatchEvent(in Event evt) >+ raises(EventException); >+ >+ }; >+} >Index: WebCore/workers/WorkerContext.idl >=================================================================== >--- WebCore/workers/WorkerContext.idl (revision 47105) >+++ WebCore/workers/WorkerContext.idl (working copy) >@@ -81,6 +81,9 @@ module threads { > #if ENABLE_CHANNEL_MESSAGING > attribute [JSCCustomGetter] MessageChannelConstructor MessageChannel; > #endif >+#if ENABLE_EVENTSOURCE >+ attribute [JSCCustomGetter] EventSourceConstructor EventSource; >+#endif > attribute [JSCCustomGetter] XMLHttpRequestConstructor XMLHttpRequest; > }; > >Index: WebKitTools/ChangeLog >=================================================================== >--- WebKitTools/ChangeLog (revision 47105) >+++ WebKitTools/ChangeLog (working copy) >@@ -1,3 +1,12 @@ >+2009-08-12 Adam Bergkvist <adam.bergkvist@ericsson.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added EventSource to the build script (default on). >+ https://bugs.webkit.org/show_bug.cgi?id=14997 >+ >+ * Scripts/build-webkit: >+ > 2009-08-11 John Gregg <johnnyg@google.com> > > Reviewed by Maciej Stachowiak. >Index: WebKitTools/Scripts/build-webkit >=================================================================== >--- WebKitTools/Scripts/build-webkit (revision 47105) >+++ WebKitTools/Scripts/build-webkit (working copy) >@@ -46,7 +46,7 @@ my $minimal = 0; > my $makeArgs; > > my ($threeDCanvasSupport, $threeDRenderingSupport, $channelMessagingSupport, $databaseSupport, $datagridSupport, $domStorageSupport, >- $filtersSupport, $geolocationSupport, $gnomeKeyringSupport, $iconDatabaseSupport, >+ $eventsourceSupport, $filtersSupport, $geolocationSupport, $gnomeKeyringSupport, $iconDatabaseSupport, > $javaScriptDebuggerSupport, $offlineWebApplicationSupport, $rubySupport, $sharedWorkersSupport, > $svgSupport, $svgAnimationSupport, $svgAsImageSupport, $svgDOMObjCBindingsSupport, $svgFontsSupport, > $svgForeignObjectSupport, $svgUseSupport, $videoSupport, $webSocketsSupport, $wmlSupport, $workersSupport, >@@ -74,6 +74,9 @@ my @features = ( > { option => "dom-storage", desc => "Toggle DOM Storage Support", > define => "ENABLE_DOM_STORAGE", default => 1, value => \$domStorageSupport }, > >+ { option => "eventsource", desc => "Toggle server-sent events support", >+ define => "ENABLE_EVENTSOURCE", default => 1, value => \$eventsourceSupport }, >+ > { option => "filters", desc => "Toggle Filters support", > define => "ENABLE_FILTERS", default => 0, value => \$filtersSupport }, > >Index: LayoutTests/ChangeLog >=================================================================== >--- LayoutTests/ChangeLog (revision 47105) >+++ LayoutTests/ChangeLog (working copy) >@@ -1,3 +1,38 @@ >+2009-08-12 Adam Bergkvist <adam.bergkvist@ericsson.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests for EventSource. >+ https://bugs.webkit.org/show_bug.cgi?id=14997 >+ >+ * fast/eventsource: Added. >+ * fast/eventsource/eventsource-attribute-listeners-expected.txt: Added. >+ * fast/eventsource/eventsource-attribute-listeners.html: Added. >+ * fast/eventsource/eventsource-constructor-expected.txt: Added. >+ * fast/eventsource/eventsource-constructor.html: Added. >+ * http/tests/eventsource: Added. >+ * http/tests/eventsource/eventsource-bad-mime-type-expected.txt: Added. >+ * http/tests/eventsource/eventsource-bad-mime-type.html: Added. >+ * http/tests/eventsource/eventsource-parse-event-stream-expected.txt: Added. >+ * http/tests/eventsource/eventsource-parse-event-stream.html: Added. >+ * http/tests/eventsource/eventsource-reconnect-expected.txt: Added. >+ * http/tests/eventsource/eventsource-reconnect.html: Added. >+ * http/tests/eventsource/eventsource-status-code-states-expected.txt: Added. >+ * http/tests/eventsource/eventsource-status-code-states.html: Added. >+ * http/tests/eventsource/resources: Added. >+ * http/tests/eventsource/resources/bad-mime-type.asis: Added. >+ * http/tests/eventsource/resources/event-stream.php: Added. >+ * http/tests/eventsource/resources/reconnect.php: Added. >+ * http/tests/eventsource/resources/simple-event-stream.asis: Added. >+ * http/tests/eventsource/resources/status-codes.php: Added. >+ * http/tests/eventsource/workers: Added. >+ * http/tests/eventsource/workers/eventsource-simple-expected.txt: Added. >+ * http/tests/eventsource/workers/eventsource-simple.html: Added. >+ * http/tests/eventsource/workers/resources: Added. >+ * http/tests/eventsource/workers/resources/simple-worker.js: Added. >+ (es.onmessage): >+ (es.onerror): >+ > 2009-08-12 Ariya Hidayat <ariya.hidayat@nokia.com> > > Reviewed by Holger Hans Peter Freyther. >Index: LayoutTests/fast/dom/prototype-inheritance-2-expected.txt >=================================================================== >--- LayoutTests/fast/dom/prototype-inheritance-2-expected.txt (revision 47105) >+++ LayoutTests/fast/dom/prototype-inheritance-2-expected.txt (working copy) >@@ -77,6 +77,7 @@ PASS DataGridColumnListConstructor from > PASS DataGridColumnListPrototype from inner.document.activeElement.childNodes.14.columns.__proto__ > PASS DocumentPrototype from inner.document.__proto__.__proto__ > PASS ElementPrototype from inner.document.activeElement.lastElementChild.__proto__.__proto__ >+PASS EventSourceContructor from inner.EventSource > FAIL Function from inner.document.location.pathname.constructor > PASS HTMLAnchorElement from inner.document.activeElement.firstElementChild > PASS HTMLAnchorElementConstructor from inner.document.activeElement.firstElementChild.constructor >Index: LayoutTests/fast/dom/prototype-inheritance-expected.txt >=================================================================== >--- LayoutTests/fast/dom/prototype-inheritance-expected.txt (revision 47105) >+++ LayoutTests/fast/dom/prototype-inheritance-expected.txt (working copy) >@@ -77,6 +77,8 @@ PASS inner.Event.isInner is true > PASS inner.Event.constructor.isInner is true > PASS inner.EventException.isInner is true > PASS inner.EventException.constructor.isInner is true >+PASS inner.EventSource.isInner is true >+PASS inner.EventSource.constructor.isInner is true > PASS inner.File.isInner is true > PASS inner.File.constructor.isInner is true > PASS inner.FileList.isInner is true >Index: LayoutTests/fast/dom/Window/window-properties-expected.txt >=================================================================== >--- LayoutTests/fast/dom/Window/window-properties-expected.txt (revision 47105) >+++ LayoutTests/fast/dom/Window/window-properties-expected.txt (working copy) >@@ -857,6 +857,15 @@ window.EventException [object EventExcep > window.EventException.UNSPECIFIED_EVENT_TYPE_ERR [number] > window.EventException.prototype [object EventExceptionPrototype] > window.EventException.prototype.UNSPECIFIED_EVENT_TYPE_ERR [number] >+window.EventSource [object EventSourceContructor] >+window.EventSource.prototype [object EventSourcePrototype] >+window.EventSource.prototype.CLOSED [number] >+window.EventSource.prototype.CONNECTING [number] >+window.EventSource.prototype.OPEN [number] >+window.EventSource.prototype.addEventListener [function] >+window.EventSource.prototype.close [function] >+window.EventSource.prototype.dispatchEvent [function] >+window.EventSource.prototype.removeEventListener [function] > window.File [object FileConstructor] > window.File.prototype [object FilePrototype] > window.FileList [object FileListConstructor] >Index: LayoutTests/fast/eventsource/eventsource-attribute-listeners-expected.txt >=================================================================== >--- LayoutTests/fast/eventsource/eventsource-attribute-listeners-expected.txt (revision 0) >+++ LayoutTests/fast/eventsource/eventsource-attribute-listeners-expected.txt (revision 0) >@@ -0,0 +1,8 @@ >+Test EventSource attribute listener functionality. Should print a series of PASS messages followed by DONE. >+ >+PASS: attribute listeners are initially null >+PASS: setting and getting attribute listener works >+PASS: resetting attribute listener works >+PASS: dispatching event on an EventSource triggers attribute listener >+DONE >+ >Index: LayoutTests/fast/eventsource/eventsource-attribute-listeners.html >=================================================================== >--- LayoutTests/fast/eventsource/eventsource-attribute-listeners.html (revision 0) >+++ LayoutTests/fast/eventsource/eventsource-attribute-listeners.html (revision 0) >@@ -0,0 +1,53 @@ >+<html> >+<body> >+<p>Test EventSource attribute listener functionality. Should print a series of PASS messages followed by DONE.</p> >+<div id="result"></div> >+<script> >+function log(msg) { >+ document.getElementById("result").innerHTML += msg + "<br>"; >+} >+ >+if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+} >+ >+var es = new EventSource("eventsource"); >+ >+if (es.onopen == null && es.onmessage == null && es.onerror == null) >+ log("PASS: attribute listeners are initially null"); >+else >+ log("FAIL: attribute listeners are not null initially"); >+ >+var a = function () {}; >+es.onopen = a; >+if (es.onopen == a) >+ log("PASS: setting and getting attribute listener works"); >+else >+ log("FAIL: setting/getting attribute listener does not work"); >+ >+var b = function () {}; >+es.onopen = b; >+if (es.onopen == b) >+ log("PASS: resetting attribute listener works"); >+else >+ log("FAIL: resetting attribute listener does not work"); >+ >+var flag = false; >+es.onmessage = function (e) { flag = (e.data == "hello"); }; >+var evt = document.createEvent("MessageEvent"); >+evt.initMessageEvent("message", false, false, "hello", null, null, null, null); >+es.dispatchEvent(evt); >+if (flag) { >+ log("PASS: dispatching event on an EventSource triggers attribute listener"); >+ log("DONE"); >+} >+else >+ log("FAIL: dispatching event on an EventSource does not trigger attribute listener"); >+ >+if (window.layoutTestController) >+ layoutTestController.notifyDone(); >+ >+</script> >+</body> >+</html> >Index: LayoutTests/fast/eventsource/eventsource-constructor-expected.txt >=================================================================== >--- LayoutTests/fast/eventsource/eventsource-constructor-expected.txt (revision 0) >+++ LayoutTests/fast/eventsource/eventsource-constructor-expected.txt (revision 0) >@@ -0,0 +1,7 @@ >+Test EventSource constructor functionality. Should print a series of PASS messages followed by DONE. >+ >+PASS: missing argument to EventSource constructor resulted in an exception (SyntaxError: Not enough arguments) >+PASS: passing an empty string to the EventSource constructor resulted in an exception (Error: SYNTAX_ERR: DOM Exception 12) >+PASS: passing an invalid URL to the EventSource constructor resulted in an exception (Error: SYNTAX_ERR: DOM Exception 12) >+DONE >+ >Index: LayoutTests/fast/eventsource/eventsource-constructor.html >=================================================================== >--- LayoutTests/fast/eventsource/eventsource-constructor.html (revision 0) >+++ LayoutTests/fast/eventsource/eventsource-constructor.html (revision 0) >@@ -0,0 +1,45 @@ >+<html> >+<body> >+<p>Test EventSource constructor functionality. Should print a series of PASS messages followed by DONE.</p> >+<div id="result"></div> >+<script> >+function log(msg) { >+ document.getElementById("result").innerHTML += msg + "<br>"; >+} >+ >+if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+} >+ >+try { >+ new EventSource(); >+ log("FAIL: no exception when trying to construct an EventSource without argument"); >+} >+catch (ex) { >+ log("PASS: missing argument to EventSource constructor resulted in an exception (" + ex + ")"); >+} >+ >+try { >+ new EventSource(""); >+ log("FAIL: no exception when passing an empty string to the EventSource constructor"); >+} >+catch (ex) { >+ log("PASS: passing an empty string to the EventSource constructor resulted in an exception (" + ex + ")"); >+} >+ >+try { >+ new EventSource("http://webserver:eighty/"); >+ log("FAIL: no exception when passing an invalid URL to the EventSource constructor"); >+} >+catch (ex) { >+ log("PASS: passing an invalid URL to the EventSource constructor resulted in an exception (" + ex + ")"); >+ log("DONE"); >+} >+ >+if (window.layoutTestController) >+ layoutTestController.notifyDone(); >+ >+</script> >+</body> >+</html> >Index: LayoutTests/http/tests/eventsource/eventsource-bad-mime-type-expected.txt >=================================================================== >--- LayoutTests/http/tests/eventsource/eventsource-bad-mime-type-expected.txt (revision 0) >+++ LayoutTests/http/tests/eventsource/eventsource-bad-mime-type-expected.txt (revision 0) >@@ -0,0 +1,4 @@ >+Test EventSource with an event-stream with incorrect mime-type. >+ >+PASS >+ >Index: LayoutTests/http/tests/eventsource/eventsource-bad-mime-type.html >=================================================================== >--- LayoutTests/http/tests/eventsource/eventsource-bad-mime-type.html (revision 0) >+++ LayoutTests/http/tests/eventsource/eventsource-bad-mime-type.html (revision 0) >@@ -0,0 +1,43 @@ >+<html> >+<body> >+<p>Test EventSource with an event-stream with incorrect mime-type.</p> >+<div id="result"></div> >+<script> >+function log(msg) { >+ document.getElementById("result").innerHTML += msg + "<br>"; >+} >+ >+if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+} >+ >+var es = new EventSource("resources/bad-mime-type.asis"); >+ >+es.onopen = function (evt) { >+ log("FAIL: got unexpected open event"); >+ end(); >+}; >+ >+es.onmessage = function (evt) { >+ log("FAIL: got unexpected message event"); >+ end(); >+}; >+ >+es.onerror = function () { >+ if (es.readyState == es.CLOSED) >+ log("PASS"); >+ else >+ log("FAIL: invalid state"); >+ end(); >+}; >+ >+function end() { >+ es.close(); >+ if (window.layoutTestController) >+ layoutTestController.notifyDone(); >+} >+ >+</script> >+</body> >+</html> >Index: LayoutTests/http/tests/eventsource/eventsource-parse-event-stream-expected.txt >=================================================================== >--- LayoutTests/http/tests/eventsource/eventsource-parse-event-stream-expected.txt (revision 0) >+++ LayoutTests/http/tests/eventsource/eventsource-parse-event-stream-expected.txt (revision 0) >@@ -0,0 +1,13 @@ >+Test EventSource text/event-stream parsing. Should print a series of PASS messages followed by DONE. >+ >+PASS: got open event >+PASS: received event with data "simple" >+PASS: received event with data spanning multiple lines >+PASS: received event and lastEventId is "1" >+PASS: received event and lastEventId is still "1" >+PASS: received event and lastEventId has been cleared >+PASS: got open event from server >+PASS: received event and the event name has been reset >+PASS: received event with data that contains a colon and a carriage return >+DONE >+ >Index: LayoutTests/http/tests/eventsource/eventsource-parse-event-stream.html >=================================================================== >--- LayoutTests/http/tests/eventsource/eventsource-parse-event-stream.html (revision 0) >+++ LayoutTests/http/tests/eventsource/eventsource-parse-event-stream.html (revision 0) >@@ -0,0 +1,74 @@ >+<html> >+<body> >+<p>Test EventSource text/event-stream parsing. Should print a series of PASS messages followed by DONE.</p> >+<div id="result"></div> >+<script> >+function log(msg) { >+ document.getElementById("result").innerHTML += msg + "<br>"; >+} >+ >+if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+} >+ >+var count = 0; >+var es = new EventSource("resources/event-stream.php"); >+ >+es.onopen = function (evt) { >+ if (!evt.data) >+ log("PASS: got open event"); >+ else >+ log("PASS: got open event from server"); >+}; >+ >+es.onmessage = function (evt) { >+ switch(count++) { >+ case 0: >+ if (evt.data == "simple") >+ log("PASS: received event with data \"simple\""); >+ break; >+ case 1: >+ if (evt.data == "spanning\nmultiple\n\nlines\n") >+ log("PASS: received event with data spanning multiple lines"); >+ break; >+ case 2: >+ if (evt.data == "id is 1" && evt.lastEventId == "1") >+ log("PASS: received event and lastEventId is \"1\""); >+ break >+ case 3: >+ if (evt.data == "id is still 1" && evt.lastEventId == "1") >+ log("PASS: received event and lastEventId is still \"1\""); >+ break; >+ case 4: >+ if (evt.data == "no id" && evt.lastEventId == "") >+ log("PASS: received event and lastEventId has been cleared"); >+ break; >+ case 5: >+ if (evt.data == "a message event with the name \"message\"") >+ log("PASS: received event and the event name has been reset"); >+ break; >+ case 6: >+ if (evt.data == "a line ending with crlf\na line with a : (colon)\na line with a \r (carriage return)") >+ log("PASS: received event with data that contains a colon and a carriage return"); >+ break; >+ default: >+ log("FAIL: got unexpected event"); >+ es.close(); >+ } >+}; >+ >+es.onerror = function () { >+ es.close(); >+ >+ if (count != 7) >+ log("FAIL: got unexpected error event"); >+ else >+ log("DONE"); >+ >+ if (window.layoutTestController) >+ layoutTestController.notifyDone(); >+}; >+</script> >+</body> >+</html> >Index: LayoutTests/http/tests/eventsource/eventsource-reconnect-expected.txt >=================================================================== >--- LayoutTests/http/tests/eventsource/eventsource-reconnect-expected.txt (revision 0) >+++ LayoutTests/http/tests/eventsource/eventsource-reconnect-expected.txt (revision 0) >@@ -0,0 +1,11 @@ >+Test EventSource reconnect after end of event stream. Should print a series of PASS messages followed by DONE. >+ >+PASS: state is CONNECTING >+PASS: state is OPEN >+PASS: got lastEventId "77" >+PASS: state is CONNECTING >+PASS: state is OPEN >+PASS: Last-Event-ID header was correct >+PASS: state is CLOSED >+DONE >+ >Index: LayoutTests/http/tests/eventsource/eventsource-reconnect.html >=================================================================== >--- LayoutTests/http/tests/eventsource/eventsource-reconnect.html (revision 0) >+++ LayoutTests/http/tests/eventsource/eventsource-reconnect.html (revision 0) >@@ -0,0 +1,77 @@ >+<html> >+<body> >+<p>Test EventSource reconnect after end of event stream. Should print a series of PASS messages followed by DONE.</p> >+<div id="result"></div> >+<script> >+function log(msg) { >+ document.getElementById("result").innerHTML += msg + "<br>"; >+} >+ >+var stateNames = ["CONNECTING", "OPEN", "CLOSED"]; >+for (var i in stateNames) >+ eval("var " + stateNames[i] + " = " + i); >+var retryTimeout; >+ >+function checkReadyState(es, desiredState) { >+ var currState = es.readyState; >+ if (currState == desiredState) >+ log("PASS: state is " + stateNames[desiredState]); >+ else >+ log("FAIL: bad state (" + stateNames[currState] + ", should be " + stateNames[desiredState] + ")"); >+} >+ >+if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+} >+ >+var errCount = 0; >+var es = new EventSource("resources/reconnect.php"); >+ >+checkReadyState(es, CONNECTING); >+ >+es.onopen = function (evt) { >+ checkReadyState(es, OPEN); >+}; >+ >+es.onmessage = function (evt) { >+ if (!errCount) { >+ if (evt.lastEventId == "77") >+ log("PASS: got lastEventId \"77\""); >+ else >+ log("FAIL: unexpected lastEventId \"" + evt.lastEventId + "\""); >+ } else { >+ if (evt.data == "77") >+ log("PASS: Last-Event-ID header was correct"); >+ else >+ log("FAIL: Last-Event-ID header was incorrect/missing"); >+ } >+}; >+ >+es.onerror = function () { >+ errCount++; >+ if (errCount < 2) { >+ checkReadyState(es, CONNECTING); >+ retryTimeout = setTimeout(end, 1000); >+ return; >+ } >+ clearTimeout(retryTimeout); >+ retryTimeout = null; >+ end(); >+}; >+ >+function end() { >+ es.close(); >+ if (retryTimeout) >+ log("FAIL: did not reconnect in time"); >+ else { >+ checkReadyState(es, CLOSED); >+ log("DONE"); >+ } >+ >+ if (window.layoutTestController) >+ layoutTestController.notifyDone(); >+} >+</script> >+</body> >+</html> >Index: LayoutTests/http/tests/eventsource/eventsource-status-code-states-expected.txt >=================================================================== >--- LayoutTests/http/tests/eventsource/eventsource-status-code-states-expected.txt (revision 0) >+++ LayoutTests/http/tests/eventsource/eventsource-status-code-states-expected.txt (revision 0) >@@ -0,0 +1,13 @@ >+Test EventSource states for different status codes. Should print a series of PASS messages followed by DONE. >+ >+PASS: status code 200 resulted in states CONNECTING, OPEN, OPEN, CONNECTING, CLOSED >+PASS: status code 204 resulted in states CONNECTING, CONNECTING, CLOSED >+PASS: status code 205 resulted in states CONNECTING, CONNECTING, CLOSED >+PASS: status code 202 resulted in states CONNECTING, CONNECTING, CLOSED >+PASS: status code 301 resulted in states CONNECTING, OPEN, OPEN, CONNECTING, CLOSED >+PASS: status code 302 resulted in states CONNECTING, OPEN, OPEN, CONNECTING, CLOSED >+PASS: status code 303 resulted in states CONNECTING, OPEN, OPEN, CONNECTING, CLOSED >+PASS: status code 307 resulted in states CONNECTING, OPEN, OPEN, CONNECTING, CLOSED >+PASS: status code 404 resulted in states CONNECTING, CLOSED, CLOSED >+DONE >+ >Index: LayoutTests/http/tests/eventsource/eventsource-status-code-states.html >=================================================================== >--- LayoutTests/http/tests/eventsource/eventsource-status-code-states.html (revision 0) >+++ LayoutTests/http/tests/eventsource/eventsource-status-code-states.html (revision 0) >@@ -0,0 +1,78 @@ >+<html> >+<body> >+<p>Test EventSource states for different status codes. Should print a series of PASS messages followed by DONE.</p> >+<div id="result"></div> >+<script> >+function log(msg) { >+ document.getElementById("result").innerHTML += msg + "<br>"; >+} >+ >+function arrayCompare(a1, a2) { >+ if (a1.length != a2.length) >+ return false; >+ for (var i = 0; i < a1.length; i++) >+ if (a1[i] != a2[i]) >+ return false; >+ return true; >+} >+ >+var stateNames = ["CONNECTING", "OPEN", "CLOSED"]; >+for (var i in stateNames) >+ eval("var " + stateNames[i] + " = " + i); >+ >+var tests = [{"code": 200, "expectedStates": [CONNECTING, OPEN, OPEN, CONNECTING, CLOSED]}, >+ {"code": 204, "expectedStates": [CONNECTING,,, CONNECTING, CLOSED]}, >+ {"code": 205, "expectedStates": [CONNECTING,,, CONNECTING, CLOSED]}, >+ {"code": 202, "expectedStates": [CONNECTING,,, CONNECTING, CLOSED]}, // other 2xx >+ {"code": 301, "expectedStates": [CONNECTING, OPEN, OPEN, CONNECTING, CLOSED]}, >+ {"code": 302, "expectedStates": [CONNECTING, OPEN, OPEN, CONNECTING, CLOSED]}, >+ {"code": 303, "expectedStates": [CONNECTING, OPEN, OPEN, CONNECTING, CLOSED]}, >+ {"code": 307, "expectedStates": [CONNECTING, OPEN, OPEN, CONNECTING, CLOSED]}, >+ {"code": 404, "expectedStates": [CONNECTING,,, CLOSED, CLOSED]}]; // any other >+var count = 0; >+ >+function runTest() { >+ if (count >= tests.length) { >+ log("DONE"); >+ if (window.layoutTestController) >+ layoutTestController.notifyDone(); >+ return; >+ } >+ >+ var states = []; >+ var es = new EventSource("resources/status-codes.php?status-code=" + tests[count].code); >+ states[0] = es.readyState; >+ >+ es.onopen = function () { >+ states[1] = es.readyState; >+ }; >+ >+ es.onmessage = function (evt) { >+ states[2] = es.readyState; >+ }; >+ >+ es.onerror = function () { >+ states[3] = es.readyState; >+ es.close(); >+ states[4] = es.readyState; >+ >+ var result = arrayCompare(states, tests[count].expectedStates) ? "PASS" : "FAIL"; >+ result += ": status code " + tests[count].code + " resulted in states "; >+ for (var i in states) >+ result += (i != 0 ? ", " : "") + stateNames[states[i]]; >+ log(result); >+ >+ setTimeout(runTest, 0); >+ count++; >+ }; >+} >+ >+if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+} >+ >+runTest(); >+</script> >+</body> >+</html> >Index: LayoutTests/http/tests/eventsource/resources/bad-mime-type.asis >=================================================================== >--- LayoutTests/http/tests/eventsource/resources/bad-mime-type.asis (revision 0) >+++ LayoutTests/http/tests/eventsource/resources/bad-mime-type.asis (revision 0) >@@ -0,0 +1,3 @@ >+Content-Type: text/bogus >+ >+data: should not trigger an event >Index: LayoutTests/http/tests/eventsource/resources/event-stream.php >=================================================================== >--- LayoutTests/http/tests/eventsource/resources/event-stream.php (revision 0) >+++ LayoutTests/http/tests/eventsource/resources/event-stream.php (revision 0) >@@ -0,0 +1,51 @@ >+<?php >+header("Content-Type: text/event-stream"); >+?> >+ >+: a comment (ignored) >+this line will be ignored since there is no field and the line itself is not a field >+field: an unknown field that will be ignored >+:another commment >+ >+data : this line will be ignored since there is a space after data >+ >+data >+data: >+data >+: no dispatch since data buffer is empty >+ >+data: simple >+ >+data: spanning >+data:multiple >+data >+data: lines >+data >+ >+id: 1 >+data: id is 1 >+ >+data: id is still 1 >+ >+id >+data: no id >+ >+event: open >+data: a message event with the name "open" >+ >+<?php flush(); echo "da"; flush(); ?> >+ta: a message event with the name "message" >+ >+<?php echo "data: a line ending with crlf\r\n"; ?> >+data: a line with a : (colon) >+<?php echo "data: a line with a \r (carriage return)\n"; ?> >+ >+retry: 10000 >+: reconnection time set to 10 seconds >+ >+retry: one thousand >+: ignored invalid reconnection time value >+ >+retry >+: reset to ua default >+ >Index: LayoutTests/http/tests/eventsource/resources/reconnect.php >=================================================================== >--- LayoutTests/http/tests/eventsource/resources/reconnect.php (revision 0) >+++ LayoutTests/http/tests/eventsource/resources/reconnect.php (revision 0) >@@ -0,0 +1,12 @@ >+<?php >+header("Content-Type: text/event-stream"); >+$lastEventId = $_SERVER['HTTP_LAST_EVENT_ID']; >+ >+if ($lastEventId) >+ echo "data: $lastEventId\n\n"; >+else { >+ echo "id: 77\n"; >+ echo "retry: 300\n"; >+ echo "data: hello\n\n"; >+} >+?> >Index: LayoutTests/http/tests/eventsource/resources/simple-event-stream.asis >=================================================================== >--- LayoutTests/http/tests/eventsource/resources/simple-event-stream.asis (revision 0) >+++ LayoutTests/http/tests/eventsource/resources/simple-event-stream.asis (revision 0) >@@ -0,0 +1,3 @@ >+Content-Type: text/event-stream >+ >+data: hello >Index: LayoutTests/http/tests/eventsource/resources/status-codes.php >=================================================================== >--- LayoutTests/http/tests/eventsource/resources/status-codes.php (revision 0) >+++ LayoutTests/http/tests/eventsource/resources/status-codes.php (revision 0) >@@ -0,0 +1,18 @@ >+<?php >+$status_code = $_GET['status-code']; >+header("HTTP/1.1 $status_code OK"); >+ >+switch ($status_code) { >+case 200: >+ header("Content-Type: text/event-stream"); >+ echo "data: hello\n\n"; >+ break; >+case 301: >+case 302: >+case 303: >+case 307: >+ $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/simple-event-stream.asis"; >+ header("Location: http://" . $_SERVER['HTTP_HOST'] . $uri); >+ break; >+} >+?> >Index: LayoutTests/http/tests/eventsource/workers/eventsource-simple-expected.txt >=================================================================== >--- LayoutTests/http/tests/eventsource/workers/eventsource-simple-expected.txt (revision 0) >+++ LayoutTests/http/tests/eventsource/workers/eventsource-simple-expected.txt (revision 0) >@@ -0,0 +1,4 @@ >+Test EventSource in a worker. >+ >+PASS >+ >Index: LayoutTests/http/tests/eventsource/workers/eventsource-simple.html >=================================================================== >--- LayoutTests/http/tests/eventsource/workers/eventsource-simple.html (revision 0) >+++ LayoutTests/http/tests/eventsource/workers/eventsource-simple.html (revision 0) >@@ -0,0 +1,37 @@ >+<html> >+<body> >+<p>Test EventSource in a worker.</p> >+<div id="result"></div> >+<script> >+function log(msg) { >+ document.getElementById("result").innerHTML += msg + "<br>"; >+} >+ >+if (window.layoutTestController) { >+ layoutTestController.dumpAsText(); >+ layoutTestController.waitUntilDone(); >+} >+ >+var worker = new Worker("resources/simple-worker.js"); >+ >+worker.onmessage = function (evt) { >+ if (evt.data == "hello") >+ log("PASS"); >+ else >+ log("FAIL"); >+ end(); >+} >+ >+worker.onerror = function () { >+ log("FAIL"); >+ end(); >+} >+ >+function end() { >+ if (window.layoutTestController) >+ layoutTestController.notifyDone(); >+} >+ >+</script> >+</body> >+</html> >Index: LayoutTests/http/tests/eventsource/workers/resources/simple-worker.js >=================================================================== >--- LayoutTests/http/tests/eventsource/workers/resources/simple-worker.js (revision 0) >+++ LayoutTests/http/tests/eventsource/workers/resources/simple-worker.js (revision 0) >@@ -0,0 +1,12 @@ >+var es = new EventSource("../../resources/simple-event-stream.asis"); >+ >+es.onmessage = function (evt) { >+ postMessage(evt.data); >+ es.close(); >+} >+ >+es.onerror = function () { >+ postMessage("error"); >+ es.close(); >+} >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 14997
:
16003
|
16038
|
29828
|
30050
|
30778
|
31160
|
34139
|
34665
| 34732