<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>23176</bug_id>
          
          <creation_ts>2013-09-06 16:19:48 +0000</creation_ts>
          <short_desc>Figure out what type MessageEvent.ports should be (array? frozen array? dedicated interface?)</short_desc>
          <delta_ts>2016-03-24 10:14:54 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WHATWG</product>
          <component>HTML</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#top</bug_file_loc>
          <status_whiteboard>blocked awaiting response from heycam to comment 6 (please remove this when replying)</status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Unsorted</target_milestone>
          <dependson>23682</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Philip Jägenstedt">philipj</assigned_to>
          <cc>bashi</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>cam</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
          
          <qa_contact>contributor</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>93122</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2013-09-06 16:19:48 +0000</bug_when>
    <thetext>Specification: http://www.w3.org/TR/webmessaging/
Multipage: http://www.whatwg.org/C#top
Complete: http://www.whatwg.org/c#top
Referrer: 

Comment:
In the Event Definitions section, the .ports atribute of a MessageEvent is an
IDL array.  Given the way MessageEventInit is defined, this will be a writable
array if the caller passes in a JS Array.

I don&apos;t think it makes any sense to have a writable array here.

Furthermore, it&apos;s not clear to me that we want an IDL array here at all.

In terms of implementation, at least the Blink implementation doesn&apos;t do
anything resembling what the spec calls for here.

Further, it looks like the test suite simply doesn&apos;t have decent coverage of
this stuff, based on a quick skim through
http://w3c-test.org/webapps/Workers/tests/submissions/Microsoft/ and
https://dvcs.w3.org/hg/webapps/rev/b5a2558005ab

Posted from: 96.233.102.142
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:26.0) Gecko/20100101 Firefox/26.0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93124</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-09-06 16:24:35 +0000</bug_when>
    <thetext>To be clear, in Blink you have:

  var a = new MessageChannel();
  var b = new MessageEvent(&apos;message&apos;, { ports: [a.port1, a.port2] });
  alert(b.ports == b.ports);

alerting false.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93178</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-09-09 22:49:27 +0000</bug_when>
    <thetext>What&apos;s the magic IDL I need to make the dictionary turn the value into a copy rather than a reference?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93179</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-09-09 23:27:21 +0000</bug_when>
    <thetext>For the dictionary, sequence&lt;MessagePort&gt;.  Possibly nullable if you want to allow explicit null (in which case presumably it should have a default value of null).

What should appear in the interface depends on what you want the behavior to be, exactly.  Chrome&apos;s current behavior is, as I said, insane.  In Gecko we&apos;re making .ports on the event return a MessagePortList instance, with the MessagePortList interface defined in the obvious way (but probably NoInterfaceObject and ArrayClass).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95902</commentid>
    <comment_count>4</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-06 22:01:10 +0000</bug_when>
    <thetext>Why wouldn&apos;t we want the array on the event to be mutable?

I agree it should be a copy of the one passed to the event constructor in the dictionary, not the same exact one. That&apos;s fixed by making the MessageEventInit member be a sequence&lt;MessagePort&gt;; that copies on the way in. So I&apos;ve done that.

But I&apos;m not clear on why we can&apos;t just have an array on the way out.

I really don&apos;t want to define a whole interface just to handle this, if we can help it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>95905</commentid>
    <comment_count>5</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2013-11-06 23:18:45 +0000</bug_when>
    <thetext>Bug 23682 suggests that .ports returns a frozen JS Array object, which sounds reasonable.  Marking a dependency on that bug since we&apos;ll need to fix these array-like types before we can do this.

Domenic suggested in IRC having a &quot;frozen&quot; keyword in the attribute definition to indicate this.  So you&apos;d have something like:

  [SameObject] readonly attribute frozen Array&lt;MessagePort&gt; ports;

That&apos;s a lot of words. :)


Still we might need to be careful about the automatic copying of values that the DOM spec does from the dictionary value to the Event object.  I don&apos;t think we would write:

  dictionary MessageEventInit {
    frozen Array&lt;MessagePort&gt; ports;
  };

or at least, we wouldn&apos;t want to require that the object you pass in is already frozen.  Remains to be seen what kinds of conversions this Array&lt;MessagePort&gt; type would do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96267</commentid>
    <comment_count>6</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2013-11-13 22:57:17 +0000</bug_when>
    <thetext>heycam, should I reassign this to you in the meantime?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120471</commentid>
    <comment_count>7</comment_count>
    <who name="">bashi</who>
    <bug_when>2015-05-26 02:15:57 +0000</bug_when>
    <thetext>Should MessageEventInit.ports be nullable?

Currently, https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces says it is sequence&lt;MessagePort&gt;. If I read the the IDL spec correctly (correct me if I&apos;m wrong), when we pass { ports: null } as MessageEventInit, a TypeError should be thrown.

http://heycam.github.io/webidl/#es-dictionary
http://heycam.github.io/webidl/#es-sequence

- Gecko doesn&apos;t throw a TypeError and event.ports is initialized to null.
- Blink doesn&apos;t throw a TypeError and event.ports is initialized to [].

Blink&apos;s current behavior is wrong so I&apos;d like to fix it. But it seems that Gecko doesn&apos;t follow what the spec says.

I&apos;d prefer to make MessageEventInit.ports nullable because MessageEvent.ports is nullable. It also matches the current Gecko&apos;s behavior. WDYT?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120472</commentid>
    <comment_count>8</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2015-05-26 02:33:15 +0000</bug_when>
    <thetext>Looks like in Gecko&apos;s current IDL the &quot;ports&quot; in MessageEventInit is of type &quot;sequence&lt;MessagePort&gt;?&quot;.

I agree that if null is a valid value for MessageEvent.ports then it should also be a valid value for the corresponding member of MessageEventInit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125610</commentid>
    <comment_count>9</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2016-03-24 10:13:50 +0000</bug_when>
    <thetext>https://github.com/whatwg/html/pull/863 will use FrozenArray&lt;&gt; here which solves most of what has been discussed here.

What remains is the nullability of ports. It&apos;s only nullable because of initMessageEvent and MessageEventInit, AFAICT on all other paths it will be initialized to an array. This is a bit silly, but also harmless.

Note that bashi@ made it nullable in https://chromium.googlesource.com/chromium/src/+/789b7be6bafd3d57fd747e0e8afe4218c7f025d7 and from my ad-hoc testing, Firefox Nightly and Chrome Canary now have the same behavior.

If anyone thinks that it&apos;s worth investigating the compat impact of making ports non-nullable, please file a new issue at https://github.com/whatwg/html/issues</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125612</commentid>
    <comment_count>10</comment_count>
    <who name="Philip Jägenstedt">philipj</who>
    <bug_when>2016-03-24 10:14:54 +0000</bug_when>
    <thetext>(Resolved as moved to https://github.com/whatwg/html/pull/863)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>