Title: [97955] trunk
Revision
97955
Author
hara...@chromium.org
Date
2011-10-20 02:57:28 -0700 (Thu, 20 Oct 2011)

Log Message

Implement a MessageEvent constructor for V8
https://bugs.webkit.org/show_bug.cgi?id=70296

Reviewed by Adam Barth.

Source/WebCore:

Test: fast/events/constructors/message-event-constructor.html

* bindings/v8/OptionsObject.cpp:
(WebCore::OptionsObject::getKeyValue): Returns RefPtr<DOMWindow> corresponding to a given key.
(WebCore::OptionsObject::getKeyValue): Returns MessagePortArray corresponding to a given key.
* bindings/v8/OptionsObject.h:
* bindings/v8/custom/V8EventConstructors.cpp: Added a MessageEvent constructor.
* dom/MessageEvent.idl: Makes MessageEvent constructible for V8.

LayoutTests:

Enabled message-event-constructor.html for chromium,
since now V8 has the MessageEvent constructor.

* platform/chromium/test_expectations.txt:
* platform/chromium/fast/events/constructors/message-event-constructor-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (97954 => 97955)


--- trunk/LayoutTests/ChangeLog	2011-10-20 09:50:22 UTC (rev 97954)
+++ trunk/LayoutTests/ChangeLog	2011-10-20 09:57:28 UTC (rev 97955)
@@ -1,3 +1,16 @@
+2011-10-20  Kentaro Hara  <hara...@chromium.org>
+
+        Implement a MessageEvent constructor for V8
+        https://bugs.webkit.org/show_bug.cgi?id=70296
+
+        Reviewed by Adam Barth.
+
+        Enabled message-event-constructor.html for chromium,
+        since now V8 has the MessageEvent constructor.
+
+        * platform/chromium/test_expectations.txt:
+        * platform/chromium/fast/events/constructors/message-event-constructor-expected.txt: Added.
+
 2011-10-20  Philippe Normand  <pnorm...@igalia.com>
 
         Unreviewed, skip failing test in GTK.

Added: trunk/LayoutTests/platform/chromium/fast/events/constructors/message-event-constructor-expected.txt (0 => 97955)


--- trunk/LayoutTests/platform/chromium/fast/events/constructors/message-event-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/constructors/message-event-constructor-expected.txt	2011-10-20 09:57:28 UTC (rev 97955)
@@ -0,0 +1,108 @@
+This tests the constructor for the MessageEvent DOM class.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new MessageEvent('eventType').bubbles is false
+PASS new MessageEvent('eventType').cancelable is false
+PASS new MessageEvent('eventType').data is null
+PASS new MessageEvent('eventType').origin is ""
+PASS new MessageEvent('eventType').lastEventId is ""
+PASS new MessageEvent('eventType').source is null
+PASS new MessageEvent('eventType').ports is []
+PASS new MessageEvent('eventType', { bubbles: false }).bubbles is false
+PASS new MessageEvent('eventType', { bubbles: true }).bubbles is true
+PASS new MessageEvent('eventType', { cancelable: false }).cancelable is false
+PASS new MessageEvent('eventType', { cancelable: true }).cancelable is true
+PASS new MessageEvent('eventType', { data: test_object }).data is test_object
+PASS new MessageEvent('eventType', { data: document }).data is document
+PASS new MessageEvent('eventType', { data: undefined }).data is undefined
+PASS new MessageEvent('eventType', { data: null }).data is null
+PASS new MessageEvent('eventType', { data: false }).data is false
+PASS new MessageEvent('eventType', { data: true }).data is true
+PASS new MessageEvent('eventType', { data: '' }).data is ""
+PASS new MessageEvent('eventType', { data: 'chocolate' }).data is "chocolate"
+PASS new MessageEvent('eventType', { data: 12345 }).data is 12345
+PASS new MessageEvent('eventType', { data: 18446744073709551615 }).data is 18446744073709552000
+PASS new MessageEvent('eventType', { data: NaN }).data is NaN
+PASS new MessageEvent('eventType', { data: {valueOf: function () { return test_object; } } }).data == test_object is false
+PASS new MessageEvent('eventType', { get data() { return 123; } }).data is 123
+PASS new MessageEvent('eventType', { get data() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
+PASS new MessageEvent('eventType', { origin: 'melancholy' }).origin is "melancholy"
+PASS new MessageEvent('eventType', { origin: '' }).origin is ""
+PASS new MessageEvent('eventType', { origin: undefined }).origin is "undefined"
+PASS new MessageEvent('eventType', { origin: null }).origin is "null"
+PASS new MessageEvent('eventType', { origin: false }).origin is "false"
+PASS new MessageEvent('eventType', { origin: true }).origin is "true"
+PASS new MessageEvent('eventType', { origin: 12345 }).origin is "12345"
+PASS new MessageEvent('eventType', { origin: 18446744073709551615 }).origin is "18446744073709552000"
+PASS new MessageEvent('eventType', { origin: NaN }).origin is "NaN"
+PASS new MessageEvent('eventType', { origin: [] }).origin is ""
+PASS new MessageEvent('eventType', { origin: [1, 2, 3] }).origin is "1,2,3"
+PASS new MessageEvent('eventType', { origin: {melancholy: 12345} }).origin is "[object Object]"
+PASS new MessageEvent('eventType', { origin: {valueOf: function () { return 'melancholy'; } } }).origin is "[object Object]"
+PASS new MessageEvent('eventType', { get origin() { return 123; } }).origin is "123"
+PASS new MessageEvent('eventType', { get origin() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
+PASS new MessageEvent('eventType', { lastEventId: 'melancholy' }).lastEventId is "melancholy"
+PASS new MessageEvent('eventType', { lastEventId: '' }).lastEventId is ""
+PASS new MessageEvent('eventType', { lastEventId: undefined }).lastEventId is "undefined"
+PASS new MessageEvent('eventType', { lastEventId: null }).lastEventId is "null"
+PASS new MessageEvent('eventType', { lastEventId: false }).lastEventId is "false"
+PASS new MessageEvent('eventType', { lastEventId: true }).lastEventId is "true"
+PASS new MessageEvent('eventType', { lastEventId: 12345 }).lastEventId is "12345"
+PASS new MessageEvent('eventType', { lastEventId: 18446744073709551615 }).lastEventId is "18446744073709552000"
+PASS new MessageEvent('eventType', { lastEventId: NaN }).lastEventId is "NaN"
+PASS new MessageEvent('eventType', { lastEventId: [] }).lastEventId is ""
+PASS new MessageEvent('eventType', { lastEventId: [1, 2, 3] }).lastEventId is "1,2,3"
+PASS new MessageEvent('eventType', { lastEventId: {melancholy: 12345} }).lastEventId is "[object Object]"
+PASS new MessageEvent('eventType', { lastEventId: {valueOf: function () { return 'melancholy'; } } }).lastEventId is "[object Object]"
+PASS new MessageEvent('eventType', { get lastEventId() { return 123; } }).lastEventId is "123"
+PASS new MessageEvent('eventType', { get lastEventId() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
+PASS new MessageEvent('eventType', { source: window }).source is window
+PASS new MessageEvent('eventType', { source: this }).source is this
+PASS new MessageEvent('eventType', { source: test_object }).source is null
+PASS new MessageEvent('eventType', { source: document }).source is null
+PASS new MessageEvent('eventType', { source: undefined }).source is null
+PASS new MessageEvent('eventType', { source: null }).source is null
+PASS new MessageEvent('eventType', { source: false }).source is null
+PASS new MessageEvent('eventType', { source: true }).source is null
+PASS new MessageEvent('eventType', { source: '' }).source is null
+PASS new MessageEvent('eventType', { source: 'chocolate' }).source is null
+PASS new MessageEvent('eventType', { source: 12345 }).source is null
+PASS new MessageEvent('eventType', { source: 18446744073709551615 }).source is null
+PASS new MessageEvent('eventType', { source: NaN }).source is null
+PASS new MessageEvent('eventType', { source: {valueOf: function () { return window; } } }).source == window is false
+PASS new MessageEvent('eventType', { get source() { return 123; } }).source is null
+PASS new MessageEvent('eventType', { get source() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
+PASS new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel.port2] }).ports[0] is channel.port1
+PASS new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel.port2] }).ports[1] is channel.port2
+PASS new MessageEvent('eventType', { ports: [channel.port1, channel.port2, channel.port2] }).ports[2] is channel.port2
+PASS new MessageEvent('eventType', { ports: [] }).ports is []
+PASS new MessageEvent('eventType', { ports: undefined }).ports is []
+PASS new MessageEvent('eventType', { ports: null }).ports is []
+PASS new MessageEvent('eventType', { ports: [1, 2, 3] }).ports[2] threw exception TypeError: MessagePortArray argument must contain only MessagePorts.
+PASS new MessageEvent('eventType', { ports: test_object }).ports threw exception TypeError: MessagePortArray argument has no length attribute.
+PASS new MessageEvent('eventType', { ports: document }).ports threw exception TypeError: MessagePortArray argument has no length attribute.
+PASS new MessageEvent('eventType', { ports: false }).ports threw exception TypeError: MessagePortArray argument must be an object.
+PASS new MessageEvent('eventType', { ports: true }).ports threw exception TypeError: MessagePortArray argument must be an object.
+PASS new MessageEvent('eventType', { ports: '' }).ports threw exception TypeError: MessagePortArray argument must be an object.
+PASS new MessageEvent('eventType', { ports: 'chocolate' }).ports threw exception TypeError: MessagePortArray argument must be an object.
+PASS new MessageEvent('eventType', { ports: 12345 }).ports threw exception TypeError: MessagePortArray argument must be an object.
+PASS new MessageEvent('eventType', { ports: 18446744073709551615 }).ports threw exception TypeError: MessagePortArray argument must be an object.
+PASS new MessageEvent('eventType', { ports: NaN }).ports threw exception TypeError: MessagePortArray argument must be an object.
+PASS new MessageEvent('eventType', { get ports() { return 123; } }).ports threw exception TypeError: MessagePortArray argument must be an object.
+PASS new MessageEvent('eventType', { get ports() { throw 'MessageEvent Error'; } }) threw exception MessageEvent Error.
+PASS new MessageEvent('eventType', { ports: {valueOf: function () { return [channel.port1, channel.port2, channel.port2]; } } }).ports[0] threw exception TypeError: MessagePortArray argument has no length attribute.
+PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).bubbles is true
+PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).cancelable is true
+PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).data is test_object
+PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).origin is "wonderful"
+PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).lastEventId is "excellent"
+PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).source is window
+PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).ports[0] is channel.port1
+PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).ports[1] is channel.port2
+PASS new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).ports[2] is channel.port2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (97954 => 97955)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-10-20 09:50:22 UTC (rev 97954)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-10-20 09:57:28 UTC (rev 97955)
@@ -74,9 +74,6 @@
 BUGWK60877 SKIP : loader/navigation-while-deferring-loads.html = FAIL
 BUGWK60877 SKIP : loader/load-defer-resume-crash.html = FAIL
 
-// This will soon be fixed after implementing a MessageEvent constructor for V8.
-BUGWK68883 : fast/events/constructors/message-event-constructor.html = FAIL
-
 // CSS3 Selectors3 test suite
 BUGCR89468 : css3/selectors3 = PASS FAIL
 

Modified: trunk/Source/WebCore/ChangeLog (97954 => 97955)


--- trunk/Source/WebCore/ChangeLog	2011-10-20 09:50:22 UTC (rev 97954)
+++ trunk/Source/WebCore/ChangeLog	2011-10-20 09:57:28 UTC (rev 97955)
@@ -1,3 +1,19 @@
+2011-10-20  Kentaro Hara  <hara...@chromium.org>
+
+        Implement a MessageEvent constructor for V8
+        https://bugs.webkit.org/show_bug.cgi?id=70296
+
+        Reviewed by Adam Barth.
+
+        Test: fast/events/constructors/message-event-constructor.html
+
+        * bindings/v8/OptionsObject.cpp:
+        (WebCore::OptionsObject::getKeyValue): Returns RefPtr<DOMWindow> corresponding to a given key.
+        (WebCore::OptionsObject::getKeyValue): Returns MessagePortArray corresponding to a given key.
+        * bindings/v8/OptionsObject.h:
+        * bindings/v8/custom/V8EventConstructors.cpp: Added a MessageEvent constructor.
+        * dom/MessageEvent.idl: Makes MessageEvent constructible for V8.
+
 2011-10-20  Peter Rybin  <peter.ry...@gmail.com>
 
         Web Inspector: reimplement protocol backend/frontend source generator

Modified: trunk/Source/WebCore/bindings/v8/OptionsObject.cpp (97954 => 97955)


--- trunk/Source/WebCore/bindings/v8/OptionsObject.cpp	2011-10-20 09:50:22 UTC (rev 97954)
+++ trunk/Source/WebCore/bindings/v8/OptionsObject.cpp	2011-10-20 09:57:28 UTC (rev 97955)
@@ -28,6 +28,8 @@
 
 #include "DOMStringList.h"
 #include "V8Binding.h"
+#include "V8DOMWindow.h"
+#include "V8MessagePortCustom.h"
 #include <limits>
 
 #if ENABLE(INDEXED_DATABASE)
@@ -223,4 +225,30 @@
     return true;
 }
 
+bool OptionsObject::getKeyValue(const String& key, RefPtr<DOMWindow>& value) const
+{
+    v8::Local<v8::Value> v8Value;
+    if (!getKey(key, v8Value))
+        return false;
+
+    DOMWindow* source = 0;
+    if (v8Value->IsObject()) {
+        v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value);
+        v8::Handle<v8::Object> window = V8DOMWrapper::lookupDOMWrapper(V8DOMWindow::GetTemplate(), wrapper);
+        if (!window.IsEmpty())
+            source = V8DOMWindow::toNative(window);
+    }
+    value = source;
+    return true;
+}
+
+bool OptionsObject::getKeyValue(const String& key, MessagePortArray& value) const
+{
+    v8::Local<v8::Value> v8Value;
+    if (!getKey(key, v8Value))
+        return false;
+
+    return getMessagePortArray(v8Value, value);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/OptionsObject.h (97954 => 97955)


--- trunk/Source/WebCore/bindings/v8/OptionsObject.h	2011-10-20 09:50:22 UTC (rev 97954)
+++ trunk/Source/WebCore/bindings/v8/OptionsObject.h	2011-10-20 09:57:28 UTC (rev 97955)
@@ -26,6 +26,7 @@
 #ifndef OptionsObject_h
 #define OptionsObject_h
 
+#include "MessagePort.h"
 #include "PlatformString.h"
 #include "ScriptValue.h"
 #include <v8.h>
@@ -33,6 +34,7 @@
 namespace WebCore {
 
 class DOMStringList;
+class DOMWindow;
 class IDBKeyRange;
 
 class OptionsObject {
@@ -80,6 +82,8 @@
     bool getKeyValue(const String&, unsigned short&) const;
     bool getKeyValue(const String&, unsigned&) const;
     bool getKeyValue(const String&, unsigned long long&) const;
+    bool getKeyValue(const String& key, RefPtr<DOMWindow>& value) const;
+    bool getKeyValue(const String& key, MessagePortArray& value) const;
 
 private:
     bool getKey(const String& key, v8::Local<v8::Value>&) const;

Modified: trunk/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp (97954 => 97955)


--- trunk/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp	2011-10-20 09:50:22 UTC (rev 97954)
+++ trunk/Source/WebCore/bindings/v8/custom/V8EventConstructors.cpp	2011-10-20 09:57:28 UTC (rev 97955)
@@ -38,6 +38,7 @@
 #include "DocumentFragment.h"
 #include "ErrorEvent.h"
 #include "HashChangeEvent.h"
+#include "MessageEvent.h"
 #include "Node.h"
 #include "OverflowEvent.h"
 #include "PageTransitionEvent.h"
@@ -56,6 +57,7 @@
 #include "V8ErrorEvent.h"
 #include "V8Event.h"
 #include "V8HashChangeEvent.h"
+#include "V8MessageEvent.h"
 #include "V8Node.h"
 #include "V8OverflowEvent.h"
 #include "V8PageTransitionEvent.h"
@@ -129,6 +131,7 @@
 INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_WEBKIT_TRANSITION_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY)
 INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_BEFORE_LOAD_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY)
 INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_OVERFLOW_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY)
+INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_MESSAGE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY)
 
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/MessageEvent.idl (97954 => 97955)


--- trunk/Source/WebCore/dom/MessageEvent.idl	2011-10-20 09:50:22 UTC (rev 97954)
+++ trunk/Source/WebCore/dom/MessageEvent.idl	2011-10-20 09:57:28 UTC (rev 97955)
@@ -30,7 +30,7 @@
     interface [
         NoStaticTables,
         CanBeConstructed,
-        JSCustomConstructor
+        CustomConstructor
     ] MessageEvent : Event {
         readonly attribute DOMString origin;
         readonly attribute DOMString lastEventId;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to