Closed Bug 1347739 Opened 6 years ago Closed 6 years ago

ExtendableMessageEvent `source` accessor crashes tab


(Core :: DOM: Service Workers, defect)

Not set



Tracking Status
firefox-esr45 --- wontfix
firefox52 --- wontfix
firefox-esr52 --- wontfix
firefox53 --- fixed
firefox54 --- fixed
firefox55 --- fixed


(Reporter: jugglinmike, Assigned: bkelly)


(Blocks 1 open bug)



(1 file)

Accessing the `source` attribute of a user-created `ExtendableMessageEvent`
object causes the browser tab of the current client to crash.

Steps to reproduce:

1. Execute the following code in the global scope of a service worker:

       new ExtendableMessageEvent('type').source;

Expected result: the expression should evaluate to `null` [1]

Actual result: the browser tab crashes

This appears to originate from the accessor function itself (rather than the
property access). The following code does *not* cause a crash:

    var e = new ExtendableMessageEvent('type');
    var desc = Object.getOwnPropertyDescriptor(ExtendableMessageEvent.prototype, 'source');
    var getter = desc.get;

However, invoking the accessor directly also causes a crash:;

No crash occurs for `ExtendableMessageEvent` objects that have been constructed
internally, i.e. for `message` event handlers.

The only open bug report I can find for the `source` attribute is bug 1196097,
but that does not seem related to this issue.

Operating System: Ubuntu 16.04 (x86_64)
Browser: Firefox Nightly
Contents of `platform.ini` file:


> 4.8.4. `event.source`
> The `source` attribute must return the value it was initialized to. When the
> object is created, this attribute must be initialized to null. It represents
> the Client object from which the message is sent.
We're hitting this MOZ_CRASH:

I guess we should just return nullptr instead.
Assignee: nobody → bkelly
Mike, do you have a test for this already written?
Flags: needinfo?(mike)
This fixes the crash locally for me.  I'll wait for Mike to respond before writing a test.  If he has one I can either import it or just wait for it to merge from upstream.
Attachment #8848073 - Flags: review?(bugmail)
I also checked MessageEvent.  It does not have this problem:
Attachment #8848073 - Flags: review?(bugmail) → review+
(In reply to Ben Kelly [not reviewing due to deadline][:bkelly] from comment #2)
> Mike, do you have a test for this already written?

Sure do--it's on its way to Web Platform Tests via the Chromium project's automated "upstreaming" process. Currently under review at
Flags: needinfo?(mike)
Ok.  I'm just going to land this then.  We'll get the test when it merges around.  Thanks!
Pushed by
Don't crash if an ExtendableMessageEvent object has a null source. r=asuth
We might as well uplift this to beta/aurora since its such an easy fix.
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Comment on attachment 8848073 [details] [diff] [review]
Don't crash if an ExtendableMessageEvent object has a null source. r=asuth

Approval Request Comment
[Feature/Bug causing the regression]: Service workers
[User impact if declined]: Crash if certain uncommon javascript is execute by a site.
[Is this code covered by automated tests?]: WPT tests are upstream, but not in our tree yet.
[Has the fix been verified in Nightly?]: I verified the fix locally.
[Needs manual test from QE? If yes, steps to reproduce]:  No
[List of other uplifts needed for the feature/fix]: None
[Is the change risky?]: Minimal risk.
[Why is the change risky/not risky?]: This basically removes an incorrect explicit MOZ_CRASH() from the code.  No other logic was changed.
[String changes made/needed]: None
Attachment #8848073 - Flags: approval-mozilla-beta?
Attachment #8848073 - Flags: approval-mozilla-aurora?
Comment on attachment 8848073 [details] [diff] [review]
Don't crash if an ExtendableMessageEvent object has a null source. r=asuth

Fix a potential crash. Aurora54+ & Beta53+.
Attachment #8848073 - Flags: approval-mozilla-beta?
Attachment #8848073 - Flags: approval-mozilla-beta+
Attachment #8848073 - Flags: approval-mozilla-aurora?
Attachment #8848073 - Flags: approval-mozilla-aurora+
Setting qe-verify- based on comment 10.
Flags: qe-verify-
You need to log in before you can comment on or make changes to this bug.