Title: [95262] trunk
Revision
95262
Author
[email protected]
Date
2011-09-15 19:45:55 -0700 (Thu, 15 Sep 2011)

Log Message

Implement a PopStateEvent constructor for JSC
https://bugs.webkit.org/show_bug.cgi?id=67977

Reviewed by Sam Weinig.

Source/WebCore:

Test: fast/events/constructors/pop-state-event-constructor.html

* bindings/generic/EventConstructors.h: Added a definition for the PopStateEvent constructor.
* bindings/js/JSEventConstructors.cpp: Added #includes for PopStateEvent.
* dom/PopStateEvent.cpp:
(WebCore::PopStateEventInit::PopStateEventInit):
(WebCore::PopStateEvent::PopStateEvent):
(WebCore::PopStateEvent::create):
* dom/PopStateEvent.h: Added a definition for PopStateEventInit.
* dom/PopStateEvent.idl: Makes PopStateEvent constructible.

LayoutTests:

pop-state-event-constructor.html checks the behavior of the PopStateEvent constructor.

* fast/events/constructors/pop-state-event-constructor-expected.txt: Added.
* fast/events/constructors/pop-state-event-constructor.html: Added.
* platform/chromium/test_expectations.txt: Skipped pop-state-event-constructor.html, since V8 does not yet have the PopStateEvent constructor.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (95261 => 95262)


--- trunk/LayoutTests/ChangeLog	2011-09-16 02:43:37 UTC (rev 95261)
+++ trunk/LayoutTests/ChangeLog	2011-09-16 02:45:55 UTC (rev 95262)
@@ -1,3 +1,16 @@
+2011-09-15  Kentaro Hara  <[email protected]>
+
+        Implement a PopStateEvent constructor for JSC
+        https://bugs.webkit.org/show_bug.cgi?id=67977
+
+        Reviewed by Sam Weinig.
+
+        pop-state-event-constructor.html checks the behavior of the PopStateEvent constructor.
+
+        * fast/events/constructors/pop-state-event-constructor-expected.txt: Added.
+        * fast/events/constructors/pop-state-event-constructor.html: Added.
+        * platform/chromium/test_expectations.txt: Skipped pop-state-event-constructor.html, since V8 does not yet have the PopStateEvent constructor.
+
 2011-09-15  Keishi Hattori  <[email protected]>
 
         [chromium] remove duplicate entries in test_expectations.txt

Added: trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor-expected.txt (0 => 95262)


--- trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor-expected.txt	2011-09-16 02:45:55 UTC (rev 95262)
@@ -0,0 +1,31 @@
+This tests the constructor for the PopStateEvent DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new PopStateEvent('eventType').bubbles is false
+PASS new PopStateEvent('eventType').cancelable is false
+PASS new PopStateEvent('eventType').state is null
+PASS new PopStateEvent('eventType', { bubbles: false }).bubbles is false
+PASS new PopStateEvent('eventType', { bubbles: true }).bubbles is true
+PASS new PopStateEvent('eventType', { cancelable: false }).cancelable is false
+PASS new PopStateEvent('eventType', { cancelable: true }).cancelable is true
+FAIL new PopStateEvent('eventType', { state: object1 }).state should be [object Object]. Was [object Object].
+PASS new PopStateEvent('eventType', { state: undefined }).state is undefined
+PASS new PopStateEvent('eventType', { state: null }).state is null
+PASS new PopStateEvent('eventType', { state: false }).state is false
+PASS new PopStateEvent('eventType', { state: true }).state is true
+FAIL new PopStateEvent('eventType', { state: '' }).state should be undefined (of type undefined). Was  (of type string).
+PASS new PopStateEvent('eventType', { state: 12345 }).state is 12345
+PASS new PopStateEvent('eventType', { state: 18446744073709551615 }).state is 18446744073709552000
+PASS new PopStateEvent('eventType', { state: NaN }).state is NaN
+FAIL new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state should be [object Object]. Was [object Object].
+PASS new PopStateEvent('eventType', { get state() { return 123; } }).state is 123
+PASS new PopStateEvent('eventType', { get state() { throw 'PopState Error'; } }) threw exception PopState Error.
+PASS new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).bubbles is true
+PASS new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).cancelable is true
+FAIL new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).state should be [object Object]. Was [object Object].
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor.html (0 => 95262)


--- trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/constructors/pop-state-event-constructor.html	2011-09-16 02:45:55 UTC (rev 95262)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("This tests the constructor for the PopStateEvent DOM class.");
+
+// No initializer is passed.
+shouldBe("new PopStateEvent('eventType').bubbles", "false");
+shouldBe("new PopStateEvent('eventType').cancelable", "false");
+shouldBe("new PopStateEvent('eventType').state", "null");
+
+// bubbles is passed.
+shouldBe("new PopStateEvent('eventType', { bubbles: false }).bubbles", "false");
+shouldBe("new PopStateEvent('eventType', { bubbles: true }).bubbles", "true");
+
+// cancelable is passed.
+shouldBe("new PopStateEvent('eventType', { cancelable: false }).cancelable", "false");
+shouldBe("new PopStateEvent('eventType', { cancelable: true }).cancelable", "true");
+
+// state is passed.
+var object1 = {nyannyan: 123};
+shouldBe("new PopStateEvent('eventType', { state: object1 }).state", "object1");
+// FIXME(haraken): When we pass a DOM object, it crashes.
+// shouldBe("new PopStateEvent('eventType', { state: document }).state", "document");
+shouldBe("new PopStateEvent('eventType', { state: undefined }).state", "undefined");
+shouldBe("new PopStateEvent('eventType', { state: null }).state", "null");
+shouldBe("new PopStateEvent('eventType', { state: false }).state", "false");
+shouldBe("new PopStateEvent('eventType', { state: true }).state", "true");
+shouldBe("new PopStateEvent('eventType', { state: '' }).state", "");
+shouldBe("new PopStateEvent('eventType', { state: 12345 }).state", "12345");
+shouldBe("new PopStateEvent('eventType', { state: 18446744073709551615 }).state", "18446744073709552000");
+shouldBe("new PopStateEvent('eventType', { state: NaN }).state", "NaN");
+var object2 = {nyannyan: 456};
+shouldBe("new PopStateEvent('eventType', { state: {valueOf: function () { return object2; } } }).state", "object2");
+shouldBe("new PopStateEvent('eventType', { get state() { return 123; } }).state", "123");
+shouldThrow("new PopStateEvent('eventType', { get state() { throw 'PopState Error'; } })");
+
+// All initializers are passed.
+var object3 = {nyannyan: 789};
+shouldBe("new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).bubbles", "true");
+shouldBe("new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).cancelable", "true");
+shouldBe("new PopStateEvent('eventType', { bubbles: true, cancelable: true, state: object3 }).state", "object3");
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (95261 => 95262)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-09-16 02:43:37 UTC (rev 95261)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-09-16 02:45:55 UTC (rev 95262)
@@ -78,6 +78,9 @@
 // CSS3 Selectors3 test suite
 BUGCR89468 : css3/selectors3 = PASS FAIL
 
+// This will soon be fixed after implementing a PopStateEvent constructor for V8.
+BUGWK67977 : fast/events/constructors/pop-state-event-constructor.html = FAIL
+
 // Tests for WebVTT parser for <track>.  Feature is not yet functional.
 BUGWK43668 SKIP : media/track/ = TIMEOUT
 

Modified: trunk/Source/WebCore/ChangeLog (95261 => 95262)


--- trunk/Source/WebCore/ChangeLog	2011-09-16 02:43:37 UTC (rev 95261)
+++ trunk/Source/WebCore/ChangeLog	2011-09-16 02:45:55 UTC (rev 95262)
@@ -1,3 +1,21 @@
+2011-09-15  Kentaro Hara  <[email protected]>
+
+        Implement a PopStateEvent constructor for JSC
+        https://bugs.webkit.org/show_bug.cgi?id=67977
+
+        Reviewed by Sam Weinig.
+
+        Test: fast/events/constructors/pop-state-event-constructor.html
+
+        * bindings/generic/EventConstructors.h: Added a definition for the PopStateEvent constructor.
+        * bindings/js/JSEventConstructors.cpp: Added #includes for PopStateEvent.
+        * dom/PopStateEvent.cpp:
+        (WebCore::PopStateEventInit::PopStateEventInit):
+        (WebCore::PopStateEvent::PopStateEvent):
+        (WebCore::PopStateEvent::create):
+        * dom/PopStateEvent.h: Added a definition for PopStateEventInit.
+        * dom/PopStateEvent.idl: Makes PopStateEvent constructible.
+
 2011-09-15  Mihai Parparita  <[email protected]>
 
         Fragment navigations should interrupt a provisional load of a different document

Modified: trunk/Source/WebCore/bindings/generic/EventConstructors.h (95261 => 95262)


--- trunk/Source/WebCore/bindings/generic/EventConstructors.h	2011-09-16 02:43:37 UTC (rev 95261)
+++ trunk/Source/WebCore/bindings/generic/EventConstructors.h	2011-09-16 02:45:55 UTC (rev 95262)
@@ -74,7 +74,14 @@
         FILL_PROPERTY(persisted) \
     DICTIONARY_END(PageTransitionEvent)
 
+#define INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_POP_STATE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
+    \
+    DICTIONARY_START(PopStateEvent) \
+        FILL_PARENT_PROPERTIES(Event) \
+        FILL_PROPERTY(state) \
+    DICTIONARY_END(PopStateEvent)
 
+
 #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) \
     INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_CUSTOM_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
@@ -82,6 +89,7 @@
     INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_WEBKIT_ANIMATION_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
     INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_HASH_CHANGE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
     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) \
 
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/bindings/js/JSEventConstructors.cpp (95261 => 95262)


--- trunk/Source/WebCore/bindings/js/JSEventConstructors.cpp	2011-09-16 02:43:37 UTC (rev 95261)
+++ trunk/Source/WebCore/bindings/js/JSEventConstructors.cpp	2011-09-16 02:45:55 UTC (rev 95262)
@@ -34,9 +34,11 @@
 #include "JSEvent.h"
 #include "JSHashChangeEvent.h"
 #include "JSPageTransitionEvent.h"
+#include "JSPopStateEvent.h"
 #include "JSProgressEvent.h"
 #include "JSWebKitAnimationEvent.h"
 #include "PageTransitionEvent.h"
+#include "PopStateEvent.h"
 #include "ProgressEvent.h"
 #include "WebKitAnimationEvent.h"
 #include <runtime/Error.h>

Modified: trunk/Source/WebCore/dom/PopStateEvent.cpp (95261 => 95262)


--- trunk/Source/WebCore/dom/PopStateEvent.cpp	2011-09-16 02:43:37 UTC (rev 95261)
+++ trunk/Source/WebCore/dom/PopStateEvent.cpp	2011-09-16 02:45:55 UTC (rev 95262)
@@ -31,11 +31,22 @@
 
 namespace WebCore {
 
+PopStateEventInit::PopStateEventInit()
+{
+    state = SerializedScriptValue::create();
+}
+
 PopStateEvent::PopStateEvent()
     : Event(eventNames().popstateEvent, false, true)
 {
 }
 
+PopStateEvent::PopStateEvent(const AtomicString& type, const PopStateEventInit& initializer)
+    : Event(type, initializer)
+    , m_stateObject(initializer.state)
+{
+}
+
 PopStateEvent::PopStateEvent(PassRefPtr<SerializedScriptValue> stateObject)
     : Event(eventNames().popstateEvent, false, true)
     , m_stateObject(stateObject)
@@ -56,6 +67,11 @@
     return adoptRef(new PopStateEvent(stateObject));
 }
 
+PassRefPtr<PopStateEvent> PopStateEvent::create(const AtomicString& type, const PopStateEventInit& initializer)
+{
+    return adoptRef(new PopStateEvent(type, initializer));
+}
+
 void PopStateEvent::initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> stateObject)
 {
     if (dispatched())

Modified: trunk/Source/WebCore/dom/PopStateEvent.h (95261 => 95262)


--- trunk/Source/WebCore/dom/PopStateEvent.h	2011-09-16 02:43:37 UTC (rev 95261)
+++ trunk/Source/WebCore/dom/PopStateEvent.h	2011-09-16 02:45:55 UTC (rev 95262)
@@ -34,11 +34,18 @@
 
 class SerializedScriptValue;
 
+struct PopStateEventInit : public EventInit {
+    PopStateEventInit();
+
+    RefPtr<SerializedScriptValue> state;
+};
+
 class PopStateEvent : public Event {
 public:
     virtual ~PopStateEvent();
     static PassRefPtr<PopStateEvent> create();
     static PassRefPtr<PopStateEvent> create(PassRefPtr<SerializedScriptValue>);
+    static PassRefPtr<PopStateEvent> create(const AtomicString&, const PopStateEventInit&);
     void initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue>);
     bool isPopStateEvent() const { return true; }
 
@@ -46,7 +53,9 @@
 
 private:
     PopStateEvent();
+    PopStateEvent(const AtomicString&, const PopStateEventInit&);
     explicit PopStateEvent(PassRefPtr<SerializedScriptValue>);
+
     RefPtr<SerializedScriptValue> m_stateObject;
 };
 

Modified: trunk/Source/WebCore/dom/PopStateEvent.idl (95261 => 95262)


--- trunk/Source/WebCore/dom/PopStateEvent.idl	2011-09-16 02:43:37 UTC (rev 95261)
+++ trunk/Source/WebCore/dom/PopStateEvent.idl	2011-09-16 02:45:55 UTC (rev 95262)
@@ -27,7 +27,10 @@
 module events {
 
 #if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
-    interface PopStateEvent : Event {
+    interface [
+        CanBeConstructed,
+        CustomConstructFunction
+    ] PopStateEvent : Event {
         void initPopStateEvent(in [Optional=CallWithDefaultValue] DOMString typeArg, 
                                in [Optional=CallWithDefaultValue] boolean canBubbleArg, 
                                in [Optional=CallWithDefaultValue] boolean cancelableArg, 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to