Changeset 97697 in webkit
- Timestamp:
- Oct 17, 2011 6:50:06 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r97693 r97697 1 2011-10-17 Kentaro Hara <haraken@chromium.org> 2 3 MessageEvent.data can be stored as ScriptValue. 4 https://bugs.webkit.org/show_bug.cgi?id=68978 5 6 Reviewed by Hajime Morita. 7 8 Removed failures and crashes. 9 10 * fast/events/constructors/message-event-constructor-expected.txt: 11 * fast/events/constructors/message-event-constructor.html: 12 1 13 2011-10-12 Ojan Vafai <ojan@chromium.org> 2 14 -
trunk/LayoutTests/fast/events/constructors/message-event-constructor-expected.txt
r96179 r97697 15 15 PASS new MessageEvent('eventType', { cancelable: false }).cancelable is false 16 16 PASS new MessageEvent('eventType', { cancelable: true }).cancelable is true 17 FAIL new MessageEvent('eventType', { data: test_object }).data should be [object Object]. Was [object Object]. 17 PASS new MessageEvent('eventType', { data: test_object }).data is test_object 18 PASS new MessageEvent('eventType', { data: document }).data is document 18 19 PASS new MessageEvent('eventType', { data: undefined }).data is undefined 19 20 PASS new MessageEvent('eventType', { data: null }).data is null … … 95 96 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 96 97 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 97 FAIL new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).data should be [object Object]. Was [object Object]. 98 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 98 99 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" 99 100 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" -
trunk/LayoutTests/fast/events/constructors/message-event-constructor.html
r97566 r97697 30 30 31 31 // data is passed. 32 // FIXME(haraken): This fails because MessageEvent.data cannot handle ScriptValue.33 32 shouldBe("new MessageEvent('eventType', { data: test_object }).data", "test_object"); 34 // FIXME(haraken): When we pass a DOM object, it crashes in DRT (it returns TypeError in non-DRT build). 35 // shouldBe("new MessageEvent('eventType', { data: document }).data", "document"); 33 shouldBe("new MessageEvent('eventType', { data: document }).data", "document"); 36 34 shouldBe("new MessageEvent('eventType', { data: undefined }).data", "undefined"); 37 35 shouldBe("new MessageEvent('eventType', { data: null }).data", "null"); … … 121 119 shouldBe("new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).bubbles", "true"); 122 120 shouldBe("new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).cancelable", "true"); 123 // FIXME(haraken): This fails because MessageEvent.data cannot handle ScriptValue.124 121 shouldBe("new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).data", "test_object"); 125 122 shouldBeEqualToString("new MessageEvent('eventType', { bubbles: true, cancelable: true, data: test_object, origin: 'wonderful', lastEventId: 'excellent', source: window, ports: [channel.port1, channel.port2, channel.port2] }).origin", "wonderful"); -
trunk/Source/WebCore/ChangeLog
r97696 r97697 1 2011-10-17 Kentaro Hara <haraken@chromium.org> 2 3 MessageEvent.data can be stored as ScriptValue. 4 https://bugs.webkit.org/show_bug.cgi?id=68978 5 6 Reviewed by Hajime Morita. 7 8 Currently, the following test cases fail or crash: 9 10 - shouldBe("new MessageEvent('eventType', { data: test_object }).data", "test_object") -> FAIL 11 - new MessageEvent('eventType', { data: document }).data -> CRASH 12 13 This is because MessageEvent.data is implemented just as SerializedScriptValue 14 and it cannot keep ScriptValue passed by JavaScript. This patch makes the following changes: 15 16 - If MessageEvent is constructed with ScriptValue, it is stored as ScriptValue internally. 17 When MessageEvent.data is called, the ScriptValue is returned. 18 - If MessageEvent is constructed with SerializedScriptValue, it is stored as 19 SerializedScriptValue internally (since we cannot deserialize it into ScriptValue 20 at this point because of lack of ExecState). When MessageEvent.data is called, 21 the SerializedScriptValue is deserialized into the corresponding ScriptValue, 22 and the ScriptValue is returned. 23 24 This patch does not make a fix for ObjC bindings code, since we need to first fix 25 the bug 28774, as commented in dom/MessageEvent.h and dom/MessageEvent.cpp. 26 27 Test: fast/events/constructors/message-event-constructor.html 28 29 * bindings/js/JSMessageEventCustom.cpp: 30 (WebCore::JSMessageEvent::data): Custom getter for MessageEvent.data. Supported ScriptValue. 31 (WebCore::JSMessageEvent::initMessageEvent): Changed SerializedScriptValue to ScriptValue. 32 * bindings/v8/custom/V8MessageEventCustom.cpp: 33 (WebCore::V8MessageEvent::dataAccessorGetter): Custom getter for MessageEvent.data. Supported ScriptValue. 34 (WebCore::V8MessageEvent::portsAccessorGetter): Removed extra spaces. 35 (WebCore::V8MessageEvent::initMessageEventCallback): Changed SerializedScriptValue to ScriptValue. 36 * dom/MessageEvent.cpp: 37 (WebCore::MessageEvent::MessageEvent): Supported ScriptValue. 38 (WebCore::MessageEvent::initMessageEvent): Supported ScriptValue. 39 (WebCore::MessageEvent::isMessageEvent): Removed extra spaces. 40 * dom/MessageEvent.h: Added DataType::DataTypeScriptValue. 41 (WebCore::MessageEvent::create): Supported ScriptValue. 42 (WebCore::MessageEvent::dataAsScriptValue): Getter for data. Insert ASSERT() to guarantee that this accessor is not called for unintended type of data. 43 (WebCore::MessageEvent::dataAsSerializedScriptValue): Ditto. 44 (WebCore::MessageEvent::dataAsString): Ditto. 45 (WebCore::MessageEvent::dataAsBlob): Ditto. 46 (WebCore::MessageEvent::dataAsArrayBuffer): Ditto. 47 * dom/MessageEvent.idl: Changed SerializedScriptValue to DOMObject (i.e. ScriptValue). This patch does not touch an ObjC part. 48 1 49 2011-10-17 Shinya Kawanaka <shinyak@google.com> 2 50 -
trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp
r97576 r97697 53 53 JSValue result; 54 54 switch (event->dataType()) { 55 case MessageEvent::DataTypeScriptValue: { 56 ScriptValue scriptValue = event->dataAsScriptValue(); 57 if (scriptValue.hasNoValue()) 58 result = jsNull(); 59 else 60 result = scriptValue.jsValue(); 61 break; 62 } 63 55 64 case MessageEvent::DataTypeSerializedScriptValue: 56 65 if (SerializedScriptValue* serializedValue = event->dataAsSerializedScriptValue()) { -
trunk/Source/WebCore/bindings/v8/custom/V8MessageEventCustom.cpp
r97516 r97697 52 52 v8::Handle<v8::Value> result; 53 53 switch (event->dataType()) { 54 case MessageEvent::DataTypeScriptValue: { 55 ScriptValue scriptValue = event->dataAsScriptValue(); 56 if (scriptValue.hasNoValue()) 57 result = v8::Null(); 58 else 59 result = scriptValue.v8Value(); 60 break; 61 } 62 54 63 case MessageEvent::DataTypeSerializedScriptValue: 55 64 if (SerializedScriptValue* serializedValue = event->dataAsSerializedScriptValue()) … … 89 98 if (!ports) 90 99 return v8::Array::New(0); 91 100 92 101 MessagePortArray portsCopy(*ports); 93 102 … … 106 115 bool canBubbleArg = args[1]->BooleanValue(); 107 116 bool cancelableArg = args[2]->BooleanValue(); 108 RefPtr<SerializedScriptValue> dataArg = SerializedScriptValue::create(args[3]);117 ScriptValue dataArg = ScriptValue(args[3]); 109 118 String originArg = v8ValueToWebCoreString(args[4]); 110 119 String lastEventIdArg = v8ValueToWebCoreString(args[5]); … … 124 133 return v8::Undefined(); 125 134 } 126 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg .release(), originArg, lastEventIdArg, sourceArg, portArray.release());135 event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, sourceArg, portArray.release()); 127 136 v8::PropertyAttribute dataAttr = static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::ReadOnly); 128 137 SerializedScriptValue::deserializeAndSetProperty(args.Holder(), "data", dataAttr, event->dataAsSerializedScriptValue()); -
trunk/Source/WebCore/dom/MessageEvent.cpp
r96179 r97697 35 35 36 36 MessageEventInit::MessageEventInit() 37 : data(SerializedScriptValue::create())38 37 { 39 38 } 40 39 41 40 MessageEvent::MessageEvent() 42 : m_dataType(DataTypeSerializedScriptValue) 43 , m_dataAsSerializedScriptValue(SerializedScriptValue::create()) 41 : m_dataType(DataTypeScriptValue) 44 42 { 45 43 } … … 47 45 MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& initializer) 48 46 : Event(type, initializer) 49 , m_dataType(DataTypeS erializedScriptValue)50 , m_dataAsS erializedScriptValue(initializer.data)47 , m_dataType(DataTypeScriptValue) 48 , m_dataAsScriptValue(initializer.data) 51 49 , m_origin(initializer.origin) 52 50 , m_lastEventId(initializer.lastEventId) 53 51 , m_source(initializer.source) 54 52 , m_ports(adoptPtr(new MessagePortArray(initializer.ports))) 53 { 54 } 55 56 MessageEvent::MessageEvent(const ScriptValue& data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray> ports) 57 : Event(eventNames().messageEvent, false, false) 58 , m_dataType(DataTypeScriptValue) 59 , m_dataAsScriptValue(data) 60 , m_origin(origin) 61 , m_lastEventId(lastEventId) 62 , m_source(source) 63 , m_ports(ports) 55 64 { 56 65 } … … 98 107 } 99 108 109 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const ScriptValue& data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray> ports) 110 { 111 if (dispatched()) 112 return; 113 114 initEvent(type, canBubble, cancelable); 115 116 m_dataType = DataTypeScriptValue; 117 m_dataAsScriptValue = data; 118 m_origin = origin; 119 m_lastEventId = lastEventId; 120 m_source = source; 121 m_ports = ports; 122 } 123 100 124 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray> ports) 101 125 { … … 130 154 } 131 155 156 // FIXME: remove this when we update the ObjC bindings (bug #28774). 132 157 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePort* port) 133 158 { … … 140 165 } 141 166 142 bool MessageEvent::isMessageEvent() const 167 bool MessageEvent::isMessageEvent() const 143 168 { 144 169 return true; -
trunk/Source/WebCore/dom/MessageEvent.h
r96179 r97697 34 34 #include "Event.h" 35 35 #include "MessagePort.h" 36 #include "ScriptValue.h" 36 37 #include "SerializedScriptValue.h" 37 38 … … 43 44 MessageEventInit(); 44 45 45 RefPtr<SerializedScriptValue>data;46 ScriptValue data; 46 47 String origin; 47 48 String lastEventId; … … 56 57 return adoptRef(new MessageEvent); 57 58 } 58 static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, PassRefPtr<SerializedScriptValue> data = 0, const String& origin = "", const String& lastEventId = "", PassRefPtr<DOMWindow> source = 0) 59 static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, const ScriptValue& data = ScriptValue(), const String& origin = "", const String& lastEventId = "", PassRefPtr<DOMWindow> source = 0) 60 { 61 return adoptRef(new MessageEvent(data, origin, lastEventId, source, ports)); 62 } 63 static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, PassRefPtr<SerializedScriptValue> data, const String& origin = "", const String& lastEventId = "", PassRefPtr<DOMWindow> source = 0) 59 64 { 60 65 return adoptRef(new MessageEvent(data, origin, lastEventId, source, ports)); … … 78 83 virtual ~MessageEvent(); 79 84 85 void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const ScriptValue& data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray>); 80 86 void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray>); 81 87 … … 87 93 // FIXME: Remove this when we have custom ObjC binding support. 88 94 SerializedScriptValue* data() const; 89 90 95 // FIXME: remove this when we update the ObjC bindings (bug #28774). 91 96 MessagePort* messagePort(); … … 96 101 97 102 enum DataType { 103 DataTypeScriptValue, 98 104 DataTypeSerializedScriptValue, 99 105 DataTypeString, … … 102 108 }; 103 109 DataType dataType() const { return m_dataType; } 104 SerializedScriptValue* dataAsSerializedScriptValue() const { return m_dataAsSerializedScriptValue.get(); } 105 String dataAsString() const { return m_dataAsString; } 106 Blob* dataAsBlob() const { return m_dataAsBlob.get(); } 107 ArrayBuffer* dataAsArrayBuffer() const { return m_dataAsArrayBuffer.get(); } 110 ScriptValue dataAsScriptValue() const { ASSERT(m_dataType == DataTypeScriptValue); return m_dataAsScriptValue; } 111 SerializedScriptValue* dataAsSerializedScriptValue() const { ASSERT(m_dataType == DataTypeSerializedScriptValue); return m_dataAsSerializedScriptValue.get(); } 112 String dataAsString() const { ASSERT(m_dataType == DataTypeString); return m_dataAsString; } 113 Blob* dataAsBlob() const { ASSERT(m_dataType == DataTypeBlob); return m_dataAsBlob.get(); } 114 ArrayBuffer* dataAsArrayBuffer() const { ASSERT(m_dataType == DataTypeArrayBuffer); return m_dataAsArrayBuffer.get(); } 108 115 109 116 private: 110 117 MessageEvent(); 111 118 MessageEvent(const AtomicString&, const MessageEventInit&); 119 MessageEvent(const ScriptValue& data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray>); 112 120 MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray>); 113 121 … … 117 125 118 126 DataType m_dataType; 127 ScriptValue m_dataAsScriptValue; 119 128 RefPtr<SerializedScriptValue> m_dataAsSerializedScriptValue; 120 129 String m_dataAsString; -
trunk/Source/WebCore/dom/MessageEvent.idl
r96788 r97697 37 37 readonly attribute DOMWindow source; 38 38 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT 39 readonly attribute [CachedAttribute, CustomGetter] anydata;39 readonly attribute [CachedAttribute, CustomGetter] DOMObject data; 40 40 readonly attribute [CustomGetter] Array ports; 41 41 … … 43 43 in [Optional=CallWithDefaultValue] boolean canBubbleArg, 44 44 in [Optional=CallWithDefaultValue] boolean cancelableArg, 45 in [Optional=CallWithDefaultValue] SerializedScriptValuedataArg,45 in [Optional=CallWithDefaultValue] DOMObject dataArg, 46 46 in [Optional=CallWithDefaultValue] DOMString originArg, 47 47 in [Optional=CallWithDefaultValue] DOMString lastEventIdArg, … … 52 52 in [Optional=CallWithDefaultValue] boolean canBubbleArg, 53 53 in [Optional=CallWithDefaultValue] boolean cancelableArg, 54 in [Optional=CallWithDefaultValue] SerializedScriptValuedataArg,54 in [Optional=CallWithDefaultValue] DOMObject dataArg, 55 55 in [Optional=CallWithDefaultValue] DOMString originArg, 56 56 in [Optional=CallWithDefaultValue] DOMString lastEventIdArg,
Note: See TracChangeset
for help on using the changeset viewer.