Closed Bug 1154754 Opened 9 years ago Closed 8 years ago

Implement Client.postMessage message source

Categories

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

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1143717
Tracking Status
firefox40 --- affected

People

(Reporter: catalinb, Assigned: catalinb)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Messages dispatched by the service worker to a service worker client should have a source object.
Comment on attachment 8592856 [details] [diff] [review]
Add source to messages dispatched by ServiceWorkerClient.postMessage.

Review of attachment 8592856 [details] [diff] [review]:
-----------------------------------------------------------------

You cannot pass around the worker private to the main thread without ensuring it stays alive. It seems like you only need the ID though, so why not just pass that?
Where was the ID introduced?

::: dom/workers/ServiceWorkerClient.cpp
@@ +142,5 @@
>        xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR);
>        return NS_ERROR_FAILURE;
>      }
>  
> +    nsRefPtr<nsIDOMMessageEvent> event = new MessageEvent(aTargetContainer,

Use nsRefPtr<MessageEvent>...

@@ +156,5 @@
>        xpc::Throw(aCx, rv);
>        return NS_ERROR_FAILURE;
>      }
>  
> +    static_cast<MessageEvent*>(event.get())->SetSource(aSource);

...and you don't need this cast.
Attachment #8592856 - Flags: review?(nsm.nikhil) → review-
(In reply to Nikhil Marathe [:nsm] (needinfo? please) from comment #2)
> Comment on attachment 8592856 [details] [diff] [review]
> Add source to messages dispatched by ServiceWorkerClient.postMessage.
> 
> Review of attachment 8592856 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> You cannot pass around the worker private to the main thread without
> ensuring it stays alive. It seems like you only need the ID though, so why
> not just pass that?
An oversight, I'll fix it.

> Where was the ID introduced?
Please see bug 1130684. I expect you'll have some comments about the id thing.

> ::: dom/workers/ServiceWorkerClient.cpp
> @@ +142,5 @@
> >        xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR);
> >        return NS_ERROR_FAILURE;
> >      }
> >  
> > +    nsRefPtr<nsIDOMMessageEvent> event = new MessageEvent(aTargetContainer,
> 
> Use nsRefPtr<MessageEvent>...
> 
> @@ +156,5 @@
> >        xpc::Throw(aCx, rv);
> >        return NS_ERROR_FAILURE;
> >      }
> >  
> > +    static_cast<MessageEvent*>(event.get())->SetSource(aSource);
> 
> ...and you don't need this cast.

MessageEvent's downcast to nsIDOMMessageEvent is ambiguous (which is the argument type of the dispatch event method). Either way, I'll need a cast.
Depends on: 1130684
Blocks: ServiceWorkers-postv1
No longer blocks: ServiceWorkers-v1
Status: NEW → ASSIGNED
Catalin, are you still planning to work on this?

Thanks!
This was fixed by dimi in bug 1143717.
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: