Bug 178839

Summary: messageEvent.source can also be a ServiceWorker
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebCore Misc.Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, beidson, buildbot, commit-queue, darin, dbates, esprehn+autocc, ggaren, kangil.han, kondapallykalyan, rniwa, sam, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: https://html.spec.whatwg.org/multipage/comms.html#messageeventsource
See Also: https://bugs.webkit.org/show_bug.cgi?id=174541
Bug Depends on:    
Bug Blocks: 178794    
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2017-10-25 17:46:35 PDT
messageEvent.source can also be a ServiceWorker:
- https://html.spec.whatwg.org/multipage/comms.html#messageeventsource
Comment 1 Chris Dumez 2017-10-25 18:13:11 PDT
Created attachment 324933 [details]
Patch
Comment 2 Brady Eidson 2017-10-25 19:21:57 PDT
Comment on attachment 324933 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=324933&action=review

> Source/WebCore/dom/MessageEvent.h:46
> -using MessageEventSource = Variant<RefPtr<DOMWindow>, RefPtr<MessagePort>>;
> +using MessageEventSource = Variant<RefPtr<DOMWindow>, RefPtr<MessagePort>
> +#if ENABLE(SERVICE_WORKER)
> +    , RefPtr<ServiceWorker>
> +#endif
> +    >;

This is gross. I'd almost prefer a single line duplicating all 3 possibilities for the #if ENABLE() case.

> Source/WebCore/dom/MessageEvent.idl:33
> +#if defined(ENABLE_SERVICE_WORKER) && ENABLE_SERVICE_WORKER
> +typedef (DOMWindow or MessagePort or ServiceWorker) MessageEventSource;
> +#else
> +typedef (DOMWindow or MessagePort) MessageEventSource;
> +#endif

Like this is what I was alluding to up there ^^^
Comment 3 Chris Dumez 2017-10-25 19:35:39 PDT
Created attachment 324944 [details]
Patch
Comment 4 WebKit Commit Bot 2017-10-25 19:57:11 PDT
Comment on attachment 324944 [details]
Patch

Clearing flags on attachment: 324944

Committed r224000: <https://trac.webkit.org/changeset/224000>
Comment 5 WebKit Commit Bot 2017-10-25 19:57:13 PDT
All reviewed patches have been landed.  Closing bug.
Comment 6 Sam Weinig 2017-10-25 20:02:50 PDT
:(. I was getting so close to getting rid of the preprocessor for IDL files. 

Would an alternative approach, where in non-ENABLE(SERVICE_WORKER) we have a dummy ServiceWorker class work in this case (I am considering this for the non-ENABLE(VIDEO) case). Without a way to get a ServiceWorker from script, the fact that it is included in the union should not be observable.
Comment 7 Radar WebKit Bug Importer 2017-11-15 12:44:49 PST
<rdar://problem/35568076>