From 9dd03428fd652875c3e621c0e9d32ddc808921ad Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Mon, 26 Sep 2011 03:30:34 +0000 Subject: [PATCH] Implement a CloseEvent constructor for JSC https://bugs.webkit.org/show_bug.cgi?id=68340 Patch by Kentaro Hara on 2011-09-25 Reviewed by Oliver Hunt. Source/WebCore: The spec of the CloseEvent constructor is here: http://dev.w3.org/html5/websockets/#closeevent Test: fast/events/constructors/close-event-constructor.html * bindings/generic/EventConstructors.h: Added a definition for the CloseEvent constructor. * bindings/js/JSEventConstructors.cpp: Added #includes for CloseEvent. * websockets/CloseEvent.h: Added a definition for CloseEventInit. (WebCore::CloseEventInit::CloseEventInit): (WebCore::CloseEvent::create): (WebCore::CloseEvent::CloseEvent): * websockets/CloseEvent.idl: Makes CloseEvent constructible. LayoutTests: * fast/dom/constructed-objects-prototypes-expected.txt: Now window has CloseEvent. * fast/events/constructors/close-event-constructor-expected.txt: Added. * fast/events/constructors/close-event-constructor.html: Added. * platform/chromium/test_expectations.txt: Skipped close-event-constructor.html, since V8 does not yet have the CloseEvent constructor. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95931 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 12 +++ .../constructed-objects-prototypes-expected.txt | 2 + .../close-event-constructor-expected.txt | 60 ++++++++++++++ .../constructors/close-event-constructor.html | 93 ++++++++++++++++++++++ .../platform/chromium/test_expectations.txt | 3 + Source/WebCore/ChangeLog | 20 +++++ .../WebCore/bindings/generic/EventConstructors.h | 10 +++ Source/WebCore/bindings/js/JSEventConstructors.cpp | 2 + Source/WebCore/websockets/CloseEvent.h | 27 ++++++- Source/WebCore/websockets/CloseEvent.idl | 4 +- 10 files changed, 231 insertions(+), 2 deletions(-) create mode 100644 LayoutTests/fast/events/constructors/close-event-constructor-expected.txt create mode 100644 LayoutTests/fast/events/constructors/close-event-constructor.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 52ca1a5..6a80e54 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,15 @@ +2011-09-25 Kentaro Hara + + Implement a CloseEvent constructor for JSC + https://bugs.webkit.org/show_bug.cgi?id=68340 + + Reviewed by Oliver Hunt. + + * fast/dom/constructed-objects-prototypes-expected.txt: Now window has CloseEvent. + * fast/events/constructors/close-event-constructor-expected.txt: Added. + * fast/events/constructors/close-event-constructor.html: Added. + * platform/chromium/test_expectations.txt: Skipped close-event-constructor.html, since V8 does not yet have the CloseEvent constructor. + 2011-09-25 Dan Bernstein ASSERT in WebCore::FrameView::scheduleRelayoutOfSubtree diff --git a/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt b/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt index ac72434..03dc8c8 100644 --- a/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt +++ b/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt @@ -5,6 +5,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE PASS (new inner.Audio()).isInner is true PASS (new inner.Audio()).constructor.isInner is true +PASS (new inner.CloseEvent()).isInner is true +PASS (new inner.CloseEvent()).constructor.isInner is true PASS (new inner.CustomEvent()).isInner is true PASS (new inner.CustomEvent()).constructor.isInner is true PASS (new inner.DOMParser()).isInner is true diff --git a/LayoutTests/fast/events/constructors/close-event-constructor-expected.txt b/LayoutTests/fast/events/constructors/close-event-constructor-expected.txt new file mode 100644 index 0000000..5c71a10 --- /dev/null +++ b/LayoutTests/fast/events/constructors/close-event-constructor-expected.txt @@ -0,0 +1,60 @@ +This tests the constructor for the CloseEvent DOM class. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS new CloseEvent('eventType').bubbles is false +PASS new CloseEvent('eventType').cancelable is false +PASS new CloseEvent('eventType').wasClean is false +PASS new CloseEvent('eventType').code is 0 +PASS new CloseEvent('eventType').reason is "" +PASS new CloseEvent('eventType', { bubbles: false }).bubbles is false +PASS new CloseEvent('eventType', { bubbles: true }).bubbles is true +PASS new CloseEvent('eventType', { cancelable: false }).cancelable is false +PASS new CloseEvent('eventType', { cancelable: true }).cancelable is true +PASS new CloseEvent('eventType', { wasClean: false }).wasClean is false +PASS new CloseEvent('eventType', { wasClean: true }).wasClean is true +PASS new CloseEvent('eventType', { reason: 'koakuma' }).reason is "koakuma" +PASS new CloseEvent('eventType', { reason: '' }).reason is "" +PASS new CloseEvent('eventType', { reason: undefined }).reason is "undefined" +PASS new CloseEvent('eventType', { reason: null }).reason is "null" +PASS new CloseEvent('eventType', { reason: false }).reason is "false" +PASS new CloseEvent('eventType', { reason: true }).reason is "true" +PASS new CloseEvent('eventType', { reason: 12345 }).reason is "12345" +PASS new CloseEvent('eventType', { reason: 18446744073709551615 }).reason is "18446744073709552000" +PASS new CloseEvent('eventType', { reason: NaN }).reason is "NaN" +PASS new CloseEvent('eventType', { reason: [] }).reason is "" +PASS new CloseEvent('eventType', { reason: [1, 2, 3] }).reason is "1,2,3" +PASS new CloseEvent('eventType', { reason: {koakuma: 12345} }).reason is "[object Object]" +PASS new CloseEvent('eventType', { reason: {valueOf: function () { return 'koakuma'; } } }).reason is "[object Object]" +PASS new CloseEvent('eventType', { code: 0 }).code is 0 +PASS new CloseEvent('eventType', { code: 1 }).code is 1 +PASS new CloseEvent('eventType', { code: 65534 }).code is 65534 +PASS new CloseEvent('eventType', { code: 65535 }).code is 65535 +PASS new CloseEvent('eventType', { code: 9007199254740991 }).code is 65535 +PASS new CloseEvent('eventType', { code: 18446744073709551615 }).code is 0 +PASS new CloseEvent('eventType', { code: 12345678901234567890 }).code is 2048 +PASS new CloseEvent('eventType', { code: -1 }).code is 65535 +PASS new CloseEvent('eventType', { code: 123.45 }).code is 123 +PASS new CloseEvent('eventType', { code: NaN }).code is 0 +PASS new CloseEvent('eventType', { code: undefined }).code is 0 +PASS new CloseEvent('eventType', { code: null }).code is 0 +PASS new CloseEvent('eventType', { code: '' }).code is 0 +PASS new CloseEvent('eventType', { code: '12345' }).code is 12345 +PASS new CloseEvent('eventType', { code: '12345a' }).code is 0 +PASS new CloseEvent('eventType', { code: 'abc' }).code is 0 +PASS new CloseEvent('eventType', { code: [] }).code is 0 +PASS new CloseEvent('eventType', { code: [12345] }).code is 12345 +PASS new CloseEvent('eventType', { code: [12345, 67890] }).code is 0 +PASS new CloseEvent('eventType', { code: {} }).code is 0 +PASS new CloseEvent('eventType', { code: {moemoe: 12345} }).code is 0 +PASS new CloseEvent('eventType', { code: {valueOf: function () { return 12345; }} }).code is 12345 +PASS new CloseEvent('eventType', { bubbles: true, cancelable: true, wasClean: true, code : 12345, reason: 'koakuma' }).bubbles is true +PASS new CloseEvent('eventType', { bubbles: true, cancelable: true, wasClean: true, code : 12345, reason: 'koakuma' }).cancelable is true +PASS new CloseEvent('eventType', { bubbles: true, cancelable: true, wasClean: true, code : 12345, reason: 'koakuma' }).wasClean is true +PASS new CloseEvent('eventType', { bubbles: true, cancelable: true, wasClean: true, code : 12345, reason: 'koakuma' }).code is 12345 +PASS new CloseEvent('eventType', { bubbles: true, cancelable: true, wasClean: true, code : 12345, reason: 'koakuma' }).reason is "koakuma" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/fast/events/constructors/close-event-constructor.html b/LayoutTests/fast/events/constructors/close-event-constructor.html new file mode 100644 index 0000000..38ef0b5 --- /dev/null +++ b/LayoutTests/fast/events/constructors/close-event-constructor.html @@ -0,0 +1,93 @@ + + + + + + + +

+
+ + + + diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt index ef8dd8e..fc49c4b 100644 --- a/LayoutTests/platform/chromium/test_expectations.txt +++ b/LayoutTests/platform/chromium/test_expectations.txt @@ -69,6 +69,9 @@ BUGCR84572 SKIP : storage/storageinfo-query-usage.html = FAIL BUGCR84572 SKIP : storage/storageinfo-request-quota.html = FAIL BUGCR84572 SKIP : storage/storageinfo-no-callbacks.html = FAIL +// This will soon be fixed after implementing a CloseEvent constructor for V8. +BUGWK68340 : fast/events/constructors/close-event-constructor.html = FAIL + // Animation API is disabled. Dean Jackson has promised (as of Aug. 25, 2011) // to re-enable these "in the next few weeks". BUGPKASTING SKIP : animations/animation-api-1.html = TEXT diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index e7964bc..eecad31 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,23 @@ +2011-09-25 Kentaro Hara + + Implement a CloseEvent constructor for JSC + https://bugs.webkit.org/show_bug.cgi?id=68340 + + Reviewed by Oliver Hunt. + + The spec of the CloseEvent constructor is here: + http://dev.w3.org/html5/websockets/#closeevent + + Test: fast/events/constructors/close-event-constructor.html + + * bindings/generic/EventConstructors.h: Added a definition for the CloseEvent constructor. + * bindings/js/JSEventConstructors.cpp: Added #includes for CloseEvent. + * websockets/CloseEvent.h: Added a definition for CloseEventInit. + (WebCore::CloseEventInit::CloseEventInit): + (WebCore::CloseEvent::create): + (WebCore::CloseEvent::CloseEvent): + * websockets/CloseEvent.idl: Makes CloseEvent constructible. + 2011-09-25 Mark Rowe IconDatabase’s use of ThreadCondition leads to assertion failures in the face of spurious wakeups diff --git a/Source/WebCore/bindings/generic/EventConstructors.h b/Source/WebCore/bindings/generic/EventConstructors.h index 7719fa6..e23bf16 100644 --- a/Source/WebCore/bindings/generic/EventConstructors.h +++ b/Source/WebCore/bindings/generic/EventConstructors.h @@ -90,6 +90,15 @@ namespace WebCore { FILL_PROPERTY(lineno) \ DICTIONARY_END(ErrorEvent) +#define INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_CLOSE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \ + \ + DICTIONARY_START(CloseEvent) \ + FILL_PARENT_PROPERTIES(Event) \ + FILL_PROPERTY(wasClean) \ + FILL_PROPERTY(code) \ + FILL_PROPERTY(reason) \ + DICTIONARY_END(CloseEvent) + #define INSTANTIATE_ALL_EVENT_INITIALIZING_CONSTRUCTORS(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \ INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \ @@ -100,6 +109,7 @@ namespace WebCore { INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_PAGE_TRANSITION_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \ INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_POP_STATE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \ INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_ERROR_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \ + INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_CLOSE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \ } // namespace WebCore diff --git a/Source/WebCore/bindings/js/JSEventConstructors.cpp b/Source/WebCore/bindings/js/JSEventConstructors.cpp index 86bbfd2..2ec3445 100644 --- a/Source/WebCore/bindings/js/JSEventConstructors.cpp +++ b/Source/WebCore/bindings/js/JSEventConstructors.cpp @@ -26,10 +26,12 @@ #include "config.h" #include "EventConstructors.h" +#include "CloseEvent.h" #include "CustomEvent.h" #include "ErrorEvent.h" #include "Event.h" #include "HashChangeEvent.h" +#include "JSCloseEvent.h" #include "JSCustomEvent.h" #include "JSDictionary.h" #include "JSErrorEvent.h" diff --git a/Source/WebCore/websockets/CloseEvent.h b/Source/WebCore/websockets/CloseEvent.h index 9bf259c..5015423 100644 --- a/Source/WebCore/websockets/CloseEvent.h +++ b/Source/WebCore/websockets/CloseEvent.h @@ -36,6 +36,18 @@ namespace WebCore { +struct CloseEventInit : public EventInit { + CloseEventInit() + : wasClean(false) + , code(0) + { + }; + + bool wasClean; + unsigned short code; + String reason; +}; + class CloseEvent : public Event { public: virtual bool isCloseEvent() const { return true; } @@ -45,6 +57,11 @@ public: return adoptRef(new CloseEvent()); } + static PassRefPtr create(const AtomicString& type, const CloseEventInit& initializer) + { + return adoptRef(new CloseEvent(type, initializer)); + } + void initCloseEvent(const AtomicString& type, bool canBubble, bool cancelable, bool wasClean, unsigned short code, const String& reason) { if (dispatched()) @@ -66,7 +83,15 @@ private: : Event(eventNames().closeEvent, false, false) , m_wasClean(false) , m_code(0) - { } + { + } + CloseEvent(const AtomicString& type, const CloseEventInit& initializer) + : Event(type, initializer) + , m_wasClean(initializer.wasClean) + , m_code(initializer.code) + , m_reason(initializer.reason) + { + } bool m_wasClean; unsigned short m_code; diff --git a/Source/WebCore/websockets/CloseEvent.idl b/Source/WebCore/websockets/CloseEvent.idl index a2911466..e8d6c93 100644 --- a/Source/WebCore/websockets/CloseEvent.idl +++ b/Source/WebCore/websockets/CloseEvent.idl @@ -31,7 +31,9 @@ module events { interface [ - NoStaticTables + NoStaticTables, + CanBeConstructed, + CustomConstructFunction ] CloseEvent : Event { readonly attribute boolean wasClean; readonly attribute unsigned short code; -- 2.7.4