Service worker port API reference

Note: This Service worker is part of Mozilla's Social API. If you are looking for information on the new W3C ServiceWorker proposal for caching, http response control , etc., go to the ServiceWorker landing page instead.

Summary

The Service Worker is a background worker based on the W3C Worker proposal.  The worker object is returned by calling MozSocial.getWorker and has one property, port.

Attributes

port
Returns an instance of a worker port.

Specification

Not part of any specification.

Port

Method overview

void postMessage(in JSObject message);

void close();

Properties

Property Type Description
onmessage EventListener An event listener that is called whenever a MessageEvent with type message bubbles through the worker. The message is stored in the event's data member.

Methods

postMessage()

Sends a message to the worker's inner scope. This accepts a single parameter, which is the data to send to the worker. The data may be any value or JavaScript object handled by the structured clone algorithm, which includes cyclical references.

void postMessage( Object aMessage );

Parameters

aMessage
The object to deliver to the worker; this will be in the data field in the event delivered to the onmessage handler. This may be any value or JavaScript object handled by the structured clone algorithm, which includes cyclical references.

close()

Immediately closes the port.

void close();

See also

Document Tags and Contributors

 Contributors to this page: Sheppy, chrisdavidmills, Mixedpuppy
 Last updated by: Sheppy,