Changeset 96179 in webkit


Ignore:
Timestamp:
Sep 27, 2011 7:02:18 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Kentaro Hara <haraken@chromium.org> on 2011-09-27
Reviewed by Adam Barth.

Source/WebCore:

The spec for MessageEvent is here:
http://www.whatwg.org/specs/web-apps/current-work/#messageevent

Currently, some tests in fast/events/constructors/message-event-constructor.html
are failing or crashing in DRT, as we commented in the test file.
This is because MessageEvent.data is implemented as SerializedScriptValue,
and thus it cannot keep ScriptValue passed by JavaScript.
This is the same issue as the bug (https://bugs.webkit.org/show_bug.cgi?id=68345).
We will soon make a follow-up patch to fix these failures, after this
patch is landed.

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

  • bindings/generic/EventConstructors.h: Added a definition for the MessageEvent constructor.
  • bindings/js/JSDictionary.cpp:

(WebCore::JSDictionary::convertValue): Generates MessagePortArray from the list of message ports in the format of JSValues.

  • bindings/js/JSDictionary.h:
  • bindings/js/JSEventConstructors.cpp: Added #includes for MessageEvent.
  • dom/MessageEvent.cpp:

(WebCore::MessageEventInit::MessageEventInit):
(WebCore::MessageEvent::MessageEvent):
(WebCore::MessageEvent::initMessageEvent):

  • dom/MessageEvent.h: Added a definition for MessageEvent. Removed an extra leading spaces.

(WebCore::MessageEvent::create):
(WebCore::MessageEvent::origin):
(WebCore::MessageEvent::lastEventId):
(WebCore::MessageEvent::source):
(WebCore::MessageEvent::ports):
(WebCore::MessageEvent::dataType):
(WebCore::MessageEvent::dataAsSerializedScriptValue):
(WebCore::MessageEvent::dataAsString):
(WebCore::MessageEvent::dataAsBlob):
(WebCore::MessageEvent::dataAsArrayBuffer):

  • dom/MessageEvent.idl: Makes MessageEvent constructible.

LayoutTests:

message-event-constructor.html checks the behavior of the MessageEvent constructor.

  • fast/dom/constructed-objects-prototypes-expected.txt: Now window has MessageEvent.
  • fast/events/constructors/message-event-constructor-expected.txt: Added.
  • fast/events/constructors/message-event-constructor.html: Added.
  • platform/chromium/test_expectations.txt: Skipped message-event-constructor.html, since V8 does not yet have the MessageEvent constructor.
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96177 r96179  
     12011-09-27  Kentaro Hara  <haraken@chromium.org>
     2
     3        Implement a MessageEvent constructor for JSC
     4        https://bugs.webkit.org/show_bug.cgi?id=68883
     5
     6        Reviewed by Adam Barth.
     7
     8        message-event-constructor.html checks the behavior of the MessageEvent constructor.
     9
     10        * fast/dom/constructed-objects-prototypes-expected.txt: Now window has MessageEvent.
     11        * fast/events/constructors/message-event-constructor-expected.txt: Added.
     12        * fast/events/constructors/message-event-constructor.html: Added.
     13        * platform/chromium/test_expectations.txt: Skipped message-event-constructor.html, since V8 does not yet have the MessageEvent constructor.
     14
    1152011-09-27  Eric Uhrhane  <ericu@chromium.org>
    216
  • trunk/LayoutTests/fast/dom/constructed-objects-prototypes-expected.txt

    r95931 r96179  
    2424PASS (new inner.MessageChannel()).isInner is true
    2525PASS (new inner.MessageChannel()).constructor.isInner is true
     26PASS (new inner.MessageEvent()).isInner is true
     27PASS (new inner.MessageEvent()).constructor.isInner is true
    2628PASS (new inner.Option()).isInner is true
    2729PASS (new inner.Option()).constructor.isInner is true
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r96158 r96179  
    8181BUGWK60877 SKIP : loader/navigation-while-deferring-loads.html = FAIL
    8282BUGWK60877 SKIP : loader/load-defer-resume-crash.html = FAIL
     83
     84// This will soon be fixed after implementing a MessageEvent constructor for V8.
     85BUGWK68883 : fast/events/constructors/message-event-constructor.html = FAIL
    8386
    8487// CSS3 Selectors3 test suite
  • trunk/Source/WebCore/ChangeLog

    r96177 r96179  
     12011-09-27  Kentaro Hara  <haraken@chromium.org>
     2
     3        Implement a MessageEvent constructor for JSC
     4        https://bugs.webkit.org/show_bug.cgi?id=68883
     5
     6        Reviewed by Adam Barth.
     7
     8        The spec for MessageEvent is here:
     9        http://www.whatwg.org/specs/web-apps/current-work/#messageevent
     10
     11        Currently, some tests in fast/events/constructors/message-event-constructor.html
     12        are failing or crashing in DRT, as we commented in the test file.
     13        This is because MessageEvent.data is implemented as SerializedScriptValue,
     14        and thus it cannot keep ScriptValue passed by JavaScript.
     15        This is the same issue as the bug (https://bugs.webkit.org/show_bug.cgi?id=68345).
     16        We will soon make a follow-up patch to fix these failures, after this
     17        patch is landed.
     18
     19        Test: fast/events/constructors/message-event-constructor.html
     20
     21        * bindings/generic/EventConstructors.h: Added a definition for the MessageEvent constructor.
     22        * bindings/js/JSDictionary.cpp:
     23        (WebCore::JSDictionary::convertValue): Generates MessagePortArray from the list of message ports in the format of JSValues.
     24        * bindings/js/JSDictionary.h:
     25        * bindings/js/JSEventConstructors.cpp: Added #includes for MessageEvent.
     26        * dom/MessageEvent.cpp:
     27        (WebCore::MessageEventInit::MessageEventInit):
     28        (WebCore::MessageEvent::MessageEvent):
     29        (WebCore::MessageEvent::initMessageEvent):
     30        * dom/MessageEvent.h: Added a definition for MessageEvent. Removed an extra leading spaces.
     31        (WebCore::MessageEvent::create):
     32        (WebCore::MessageEvent::origin):
     33        (WebCore::MessageEvent::lastEventId):
     34        (WebCore::MessageEvent::source):
     35        (WebCore::MessageEvent::ports):
     36        (WebCore::MessageEvent::dataType):
     37        (WebCore::MessageEvent::dataAsSerializedScriptValue):
     38        (WebCore::MessageEvent::dataAsString):
     39        (WebCore::MessageEvent::dataAsBlob):
     40        (WebCore::MessageEvent::dataAsArrayBuffer):
     41        * dom/MessageEvent.idl: Makes MessageEvent constructible.
     42
    1432011-09-27  Eric Uhrhane  <ericu@chromium.org>
    244
  • trunk/Source/WebCore/bindings/generic/EventConstructors.h

    r95931 r96179  
    100100    DICTIONARY_END(CloseEvent)
    101101
     102#define INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_MESSAGE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
     103    \
     104    DICTIONARY_START(MessageEvent) \
     105        FILL_PARENT_PROPERTIES(Event) \
     106        FILL_PROPERTY(data) \
     107        FILL_PROPERTY(origin) \
     108        FILL_PROPERTY(lastEventId) \
     109        FILL_PROPERTY(source) \
     110        FILL_PROPERTY(ports) \
     111    DICTIONARY_END(MessageEvent)
     112
    102113
    103114#define INSTANTIATE_ALL_EVENT_INITIALIZING_CONSTRUCTORS(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
     
    111122    INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_ERROR_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
    112123    INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_CLOSE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
     124    INSTANTIATE_INITIALIZING_CONSTRUCTOR_FOR_MESSAGE_EVENT(DICTIONARY_START, DICTIONARY_END, FILL_PARENT_PROPERTIES, FILL_PROPERTY) \
    113125
    114126} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSDictionary.cpp

    r95901 r96179  
    1 
    21/*
    32 * Copyright (C) 2011 Apple Inc. All rights reserved.
     
    3029#include "JSDOMWindow.h"
    3130#include "JSEventTarget.h"
     31#include "JSMessagePortCustom.h"
    3232#include "JSNode.h"
    3333#include "SerializedScriptValue.h"
     
    120120}
    121121
     122void JSDictionary::convertValue(ExecState* exec, JSValue value, MessagePortArray& result)
     123{
     124    fillMessagePortArray(exec, value, result);
     125}
     126
    122127} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSDictionary.h

    r95901 r96179  
    2727#define JSDictionary_h
    2828
     29#include "MessagePort.h"
    2930#include <interpreter/CallFrame.h>
    3031#include <wtf/Forward.h>
     
    7273    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<EventTarget>& result);
    7374    static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Node>& result);
     75    static void convertValue(JSC::ExecState*, JSC::JSValue, MessagePortArray& result);
    7476
    7577    JSC::ExecState* m_exec;
  • trunk/Source/WebCore/bindings/js/JSEventConstructors.cpp

    r95931 r96179  
    3838#include "JSEvent.h"
    3939#include "JSHashChangeEvent.h"
     40#include "JSMessageEvent.h"
    4041#include "JSPageTransitionEvent.h"
    4142#include "JSPopStateEvent.h"
    4243#include "JSProgressEvent.h"
    4344#include "JSWebKitAnimationEvent.h"
     45#include "MessageEvent.h"
    4446#include "PageTransitionEvent.h"
    4547#include "PopStateEvent.h"
  • trunk/Source/WebCore/dom/MessageEvent.cpp

    r94161 r96179  
    3434namespace WebCore {
    3535
     36MessageEventInit::MessageEventInit()
     37    : data(SerializedScriptValue::create())
     38{
     39}
     40
    3641MessageEvent::MessageEvent()
    3742    : m_dataType(DataTypeSerializedScriptValue)
    3843    , m_dataAsSerializedScriptValue(SerializedScriptValue::create())
     44{
     45}
     46
     47MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& initializer)
     48    : Event(type, initializer)
     49    , m_dataType(DataTypeSerializedScriptValue)
     50    , m_dataAsSerializedScriptValue(initializer.data)
     51    , m_origin(initializer.origin)
     52    , m_lastEventId(initializer.lastEventId)
     53    , m_source(initializer.source)
     54    , m_ports(adoptPtr(new MessagePortArray(initializer.ports)))
    3955{
    4056}
     
    86102    if (dispatched())
    87103        return;
    88        
     104
    89105    initEvent(type, canBubble, cancelable);
    90106
  • trunk/Source/WebCore/dom/MessageEvent.h

    r94161 r96179  
    3838namespace WebCore {
    3939
    40     class DOMWindow;
     40class DOMWindow;
    4141
    42     class MessageEvent : public Event {
    43     public:
    44         static PassRefPtr<MessageEvent> create()
    45         {
    46             return adoptRef(new MessageEvent);
    47         }
    48         static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, PassRefPtr<SerializedScriptValue> data = 0, const String& origin = "", const String& lastEventId = "", PassRefPtr<DOMWindow> source = 0)
    49         {
    50             return adoptRef(new MessageEvent(data, origin, lastEventId, source, ports));
    51         }
    52         static PassRefPtr<MessageEvent> create(const String& data)
    53         {
    54             return adoptRef(new MessageEvent(data));
    55         }
    56         static PassRefPtr<MessageEvent> create(PassRefPtr<Blob> data)
    57         {
    58             return adoptRef(new MessageEvent(data));
    59         }
    60         static PassRefPtr<MessageEvent> create(PassRefPtr<ArrayBuffer> data)
    61         {
    62             return adoptRef(new MessageEvent(data));
    63         }
    64         virtual ~MessageEvent();
     42struct MessageEventInit : public EventInit {
     43    MessageEventInit();
    6544
    66         void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray>);
     45    RefPtr<SerializedScriptValue> data;
     46    String origin;
     47    String lastEventId;
     48    RefPtr<DOMWindow> source;
     49    MessagePortArray ports;
     50};
    6751
    68         const String& origin() const { return m_origin; }
    69         const String& lastEventId() const { return m_lastEventId; }
    70         DOMWindow* source() const { return m_source.get(); }
    71         MessagePortArray* ports() const { return m_ports.get(); }
     52class MessageEvent : public Event {
     53public:
     54    static PassRefPtr<MessageEvent> create()
     55    {
     56        return adoptRef(new MessageEvent);
     57    }
     58    static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, PassRefPtr<SerializedScriptValue> data = 0, const String& origin = "", const String& lastEventId = "", PassRefPtr<DOMWindow> source = 0)
     59    {
     60        return adoptRef(new MessageEvent(data, origin, lastEventId, source, ports));
     61    }
     62    static PassRefPtr<MessageEvent> create(const String& data)
     63    {
     64        return adoptRef(new MessageEvent(data));
     65    }
     66    static PassRefPtr<MessageEvent> create(PassRefPtr<Blob> data)
     67    {
     68        return adoptRef(new MessageEvent(data));
     69    }
     70    static PassRefPtr<MessageEvent> create(PassRefPtr<ArrayBuffer> data)
     71    {
     72        return adoptRef(new MessageEvent(data));
     73    }
     74    static PassRefPtr<MessageEvent> create(const AtomicString& type, const MessageEventInit& initializer)
     75    {
     76        return adoptRef(new MessageEvent(type, initializer));
     77    }
     78    virtual ~MessageEvent();
    7279
    73         // FIXME: Remove this when we have custom ObjC binding support.
    74         SerializedScriptValue* data() const;
     80    void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray>);
    7581
    76         // FIXME: remove this when we update the ObjC bindings (bug #28774).
    77         MessagePort* messagePort();
    78         // FIXME: remove this when we update the ObjC bindings (bug #28774).
    79         void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePort*);
     82    const String& origin() const { return m_origin; }
     83    const String& lastEventId() const { return m_lastEventId; }
     84    DOMWindow* source() const { return m_source.get(); }
     85    MessagePortArray* ports() const { return m_ports.get(); }
    8086
    81         virtual bool isMessageEvent() const;
     87    // FIXME: Remove this when we have custom ObjC binding support.
     88    SerializedScriptValue* data() const;
    8289
    83         enum DataType {
    84             DataTypeSerializedScriptValue,
    85             DataTypeString,
    86             DataTypeBlob,
    87             DataTypeArrayBuffer
    88         };
    89         DataType dataType() const { return m_dataType; }
    90         SerializedScriptValue* dataAsSerializedScriptValue() const { return m_dataAsSerializedScriptValue.get(); }
    91         String dataAsString() const { return m_dataAsString; }
    92         Blob* dataAsBlob() const { return m_dataAsBlob.get(); }
    93         ArrayBuffer* dataAsArrayBuffer() const { return m_dataAsArrayBuffer.get(); }
     90    // FIXME: remove this when we update the ObjC bindings (bug #28774).
     91    MessagePort* messagePort();
     92    // FIXME: remove this when we update the ObjC bindings (bug #28774).
     93    void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePort*);
    9494
    95     private:
    96         MessageEvent();
    97         MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray>);
    98         explicit MessageEvent(const String& data);
    99         explicit MessageEvent(PassRefPtr<Blob> data);
    100         explicit MessageEvent(PassRefPtr<ArrayBuffer> data);
     95    virtual bool isMessageEvent() const;
    10196
    102         DataType m_dataType;
    103         RefPtr<SerializedScriptValue> m_dataAsSerializedScriptValue;
    104         String m_dataAsString;
    105         RefPtr<Blob> m_dataAsBlob;
    106         RefPtr<ArrayBuffer> m_dataAsArrayBuffer;
    107         String m_origin;
    108         String m_lastEventId;
    109         RefPtr<DOMWindow> m_source;
    110         OwnPtr<MessagePortArray> m_ports;
     97    enum DataType {
     98        DataTypeSerializedScriptValue,
     99        DataTypeString,
     100        DataTypeBlob,
     101        DataTypeArrayBuffer
    111102    };
     103    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(); }
     108
     109private:
     110    MessageEvent();
     111    MessageEvent(const AtomicString&, const MessageEventInit&);
     112    MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortArray>);
     113
     114    explicit MessageEvent(const String& data);
     115    explicit MessageEvent(PassRefPtr<Blob> data);
     116    explicit MessageEvent(PassRefPtr<ArrayBuffer> data);
     117
     118    DataType m_dataType;
     119    RefPtr<SerializedScriptValue> m_dataAsSerializedScriptValue;
     120    String m_dataAsString;
     121    RefPtr<Blob> m_dataAsBlob;
     122    RefPtr<ArrayBuffer> m_dataAsArrayBuffer;
     123    String m_origin;
     124    String m_lastEventId;
     125    RefPtr<DOMWindow> m_source;
     126    OwnPtr<MessagePortArray> m_ports;
     127};
    112128
    113129} // namespace WebCore
  • trunk/Source/WebCore/dom/MessageEvent.idl

    r95362 r96179  
    2929
    3030    interface [
    31         NoStaticTables
     31        NoStaticTables,
     32        CanBeConstructed,
     33        CustomConstructFunction
    3234    ] MessageEvent : Event {
    3335        readonly attribute DOMString origin;
Note: See TracChangeset for help on using the changeset viewer.