Title: [236784] trunk
Revision
236784
Author
[email protected]
Date
2018-10-02 18:59:04 -0700 (Tue, 02 Oct 2018)

Log Message

MessageEvent.ports should return the same object
https://bugs.webkit.org/show_bug.cgi?id=190151

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline WPT test now that it is passing.

* web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https-expected.txt:

Source/WebCore:

MessageEvent.ports should return the same object it was initialized to instead of
constructing a new JSValue every time.

No new tests, rebaselined existing test.

* bindings/js/JSMessageEventCustom.cpp:
(WebCore::JSMessageEvent::ports const):
(WebCore::JSMessageEvent::visitAdditionalChildren):
* dom/MessageEvent.cpp:
(WebCore::MessageEvent::initMessageEvent):
* dom/MessageEvent.h:
* dom/MessageEvent.idl:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (236783 => 236784)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-10-03 01:49:05 UTC (rev 236783)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-10-03 01:59:04 UTC (rev 236784)
@@ -1,5 +1,16 @@
 2018-10-02  Chris Dumez  <[email protected]>
 
+        MessageEvent.ports should return the same object
+        https://bugs.webkit.org/show_bug.cgi?id=190151
+
+        Reviewed by Darin Adler.
+
+        Rebaseline WPT test now that it is passing.
+
+        * web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https-expected.txt:
+
+2018-10-02  Chris Dumez  <[email protected]>
+
         radio / checkbox inputs should fire "click, input, change" events in order when clicked
         https://bugs.webkit.org/show_bug.cgi?id=190223
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https-expected.txt (236783 => 236784)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https-expected.txt	2018-10-03 01:49:05 UTC (rev 236783)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https-expected.txt	2018-10-03 01:59:04 UTC (rev 236784)
@@ -2,7 +2,7 @@
 PASS Default event values 
 PASS MessageEventInit dictionary 
 PASS Passing null for ports member 
-FAIL ports attribute should be a FrozenArray assert_true: ev.ports should return the same object expected true got false
+PASS ports attribute should be a FrozenArray 
 PASS initMessageEvent operation 
 PASS Passing null for ports parameter to initMessageEvent 
 PASS initMessageEvent operation default parameter values 

Modified: trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https-expected.txt (236783 => 236784)


--- trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https-expected.txt	2018-10-03 01:49:05 UTC (rev 236783)
+++ trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/webappapis/scripting/events/messageevent-constructor.https-expected.txt	2018-10-03 01:59:04 UTC (rev 236784)
@@ -2,7 +2,7 @@
 PASS Default event values 
 PASS MessageEventInit dictionary 
 PASS Passing null for ports member 
-FAIL ports attribute should be a FrozenArray assert_true: ev.ports should return the same object expected true got false
+PASS ports attribute should be a FrozenArray 
 PASS initMessageEvent operation 
 PASS Passing null for ports parameter to initMessageEvent 
 PASS initMessageEvent operation default parameter values 

Modified: trunk/Source/WebCore/ChangeLog (236783 => 236784)


--- trunk/Source/WebCore/ChangeLog	2018-10-03 01:49:05 UTC (rev 236783)
+++ trunk/Source/WebCore/ChangeLog	2018-10-03 01:59:04 UTC (rev 236784)
@@ -1,3 +1,23 @@
+2018-10-02  Chris Dumez  <[email protected]>
+
+        MessageEvent.ports should return the same object
+        https://bugs.webkit.org/show_bug.cgi?id=190151
+
+        Reviewed by Darin Adler.
+
+        MessageEvent.ports should return the same object it was initialized to instead of
+        constructing a new JSValue every time.
+
+        No new tests, rebaselined existing test.
+
+        * bindings/js/JSMessageEventCustom.cpp:
+        (WebCore::JSMessageEvent::ports const):
+        (WebCore::JSMessageEvent::visitAdditionalChildren):
+        * dom/MessageEvent.cpp:
+        (WebCore::MessageEvent::initMessageEvent):
+        * dom/MessageEvent.h:
+        * dom/MessageEvent.idl:
+
 2018-10-01  Ryosuke Niwa  <[email protected]>
 
         GC can collect JS wrappers of nodes in the mutation records waiting to be delivered

Modified: trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp (236783 => 236784)


--- trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp	2018-10-03 01:49:05 UTC (rev 236783)
+++ trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp	2018-10-03 01:59:04 UTC (rev 236784)
@@ -45,6 +45,15 @@
 
 namespace WebCore {
 
+JSC::JSValue JSMessageEvent::ports(JSC::ExecState& state) const
+{
+    auto throwScope = DECLARE_THROW_SCOPE(state.vm());
+    return cachedPropertyValue(state, *this, wrapped().cachedPorts(), [&] {
+        JSC::JSValue ports = toJS<IDLFrozenArray<IDLInterface<MessagePort>>>(state, *globalObject(), throwScope, wrapped().ports());
+        return ports;
+    });
+}
+
 JSC::JSValue JSMessageEvent::data(JSC::ExecState& state) const
 {
     return cachedPropertyValue(state, *this, wrapped().cachedData(), [this, &state] {
@@ -74,6 +83,7 @@
     });
 
     wrapped().cachedData().visit(visitor);
+    wrapped().cachedPorts().visit(visitor);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/MessageEvent.cpp (236783 => 236784)


--- trunk/Source/WebCore/dom/MessageEvent.cpp	2018-10-03 01:49:05 UTC (rev 236783)
+++ trunk/Source/WebCore/dom/MessageEvent.cpp	2018-10-03 01:59:04 UTC (rev 236784)
@@ -116,6 +116,7 @@
     m_lastEventId = lastEventId;
     m_source = WTFMove(source);
     m_ports = WTFMove(ports);
+    m_cachedPorts = { };
 }
 
 EventInterface MessageEvent::eventInterface() const

Modified: trunk/Source/WebCore/dom/MessageEvent.h (236783 => 236784)


--- trunk/Source/WebCore/dom/MessageEvent.h	2018-10-03 01:49:05 UTC (rev 236783)
+++ trunk/Source/WebCore/dom/MessageEvent.h	2018-10-03 01:59:04 UTC (rev 236784)
@@ -76,6 +76,7 @@
     const DataType& data() const { return m_data; }
 
     JSValueInWrappedObject& cachedData() { return m_cachedData; }
+    JSValueInWrappedObject& cachedPorts() { return m_cachedPorts; }
 
 private:
     MessageEvent();
@@ -92,6 +93,7 @@
     Vector<RefPtr<MessagePort>> m_ports;
 
     JSValueInWrappedObject m_cachedData;
+    JSValueInWrappedObject m_cachedPorts;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/MessageEvent.idl (236783 => 236784)


--- trunk/Source/WebCore/dom/MessageEvent.idl	2018-10-03 01:49:05 UTC (rev 236783)
+++ trunk/Source/WebCore/dom/MessageEvent.idl	2018-10-03 01:59:04 UTC (rev 236784)
@@ -41,7 +41,7 @@
     readonly attribute DOMString lastEventId;
     readonly attribute MessageEventSource? source;
     [CustomGetter] readonly attribute any data;
-    readonly attribute FrozenArray<MessagePort> ports;
+    [CustomGetter] readonly attribute FrozenArray<MessagePort> ports;
 
     void initMessageEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false,
         optional any data = "" optional USVString originArg = "", optional DOMString lastEventId = "", optional MessageEventSource? source = null,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to