Closed Bug 913761 Opened 6 years ago Closed 6 years ago

Something is wrong when transferring MessagePort object via MessageChannel

Categories

(Core :: DOM: Core & HTML, defect)

26 Branch
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: sunhaitao, Assigned: baku)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.1; rv:26.0) Gecko/20100101 Firefox/26.0 (Beta/Release)
Build ID: 20130903144150

Steps to reproduce:

0 Make sure 'dom.messageChannel.enabled' is set to true;
1 Open Scratchpad
2 Run the following code:
    var transportChannel = new MessageChannel();
    transportChannel.port1.onmessage = function (event) {
      console.log('Port Returned.');
      var portToService = (event.ports || event.data.ports)[0];
      portToService.onmessage = function (event) {
        console.log(event.data);
      };
      portToService.postMessage('READY?');
    }
    
    var serviceChannel = new MessageChannel();
    serviceChannel.port1.onmessage = function (event) {
      if (event.data == 'READY?') {
        this.postMessage('READY!');
      }
    }
    
    //Actually, this should be (See Bug 912456):
    //transportChannel.port2.postMessage(null, [serviceChannel.port2]);
    transportChannel.port2.postMessage({ports:[serviceChannel.port2]});



Actual results:

Only 'Port Returned.' is printed in console.



Expected results:

Both 'Port Returned.' and 'READY!' are printed.
Attached patch patchSplinter Review
Thanks for this bug and the piece of code for reproducing it.
Attachment #801096 - Flags: review?(bugs)
Comment on attachment 801096 [details] [diff] [review]
patch

Could we someone guarantee that Cloned port without owner window isn't
ever used by JS?
Perhaps add a method to nsDOMEventTargetHelper which sets
mHasOrHasHadOwner to true and call it in Clone()
Attachment #801096 - Flags: review?(bugs) → review+
Keywords: checkin-needed
Assignee: nobody → amarchesini
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 7 → All
Hardware: x86 → All
(Yet another) reminder - your commit message should say what your patch is doing, not restating the bug summary.
https://hg.mozilla.org/integration/mozilla-inbound/rev/1585fa81edfc
Flags: in-testsuite+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/1585fa81edfc
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.