зеркало из https://github.com/mozilla/gecko-dev.git
Bug 982726 - Patch 2 - Add postMessage to service worker. r=baku
--HG-- extra : amend_source : e69a2f5438b485ff2819c633047c0cb46f663d01 extra : transplant_source : %96%CE%FC%C8J%EEm%9B%DA%CCZIlK5%9E%EB%99%D3%F3
This commit is contained in:
Родитель
a2d3be8aeb
Коммит
e77acd5d9e
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
// Still unclear what should be subclassed.
|
||||
// https://github.com/slightlyoff/ServiceWorker/issues/189
|
||||
[Pref="dom.serviceWorkers.enabled",
|
||||
// XXXbz I have no idea where this should be exposed. The spec makes
|
||||
// no sense. But since it's got a pref, let's say window.
|
||||
|
@ -20,6 +18,10 @@ interface ServiceWorker : EventTarget {
|
|||
|
||||
readonly attribute ServiceWorkerState state;
|
||||
attribute EventHandler onstatechange;
|
||||
|
||||
// FIXME(catalinb): Bug 1053483 - This should be inherited from MessageUtils
|
||||
[Throws]
|
||||
void postMessage(any message, optional sequence<Transferable> transferable);
|
||||
};
|
||||
|
||||
ServiceWorker implements AbstractWorker;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
||||
using mozilla::ErrorResult;
|
||||
using namespace mozilla::dom;
|
||||
USING_WORKERS_NAMESPACE
|
||||
|
||||
|
@ -46,6 +47,17 @@ ServiceWorker::WrapObject(JSContext* aCx)
|
|||
return ServiceWorkerBinding::Wrap(aCx, this);
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
||||
const Optional<Sequence<JS::Value>>& aTransferable,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
WorkerPrivate* workerPrivate = GetWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
|
||||
workerPrivate->PostMessage(aCx, aMessage, aTransferable, aRv);
|
||||
}
|
||||
|
||||
WorkerPrivate*
|
||||
ServiceWorker::GetWorkerPrivate() const
|
||||
{
|
||||
|
|
|
@ -52,6 +52,11 @@ public:
|
|||
aURL = mURL;
|
||||
}
|
||||
|
||||
void
|
||||
PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
||||
const Optional<Sequence<JS::Value>>& aTransferable,
|
||||
ErrorResult& aRv);
|
||||
|
||||
WorkerPrivate*
|
||||
GetWorkerPrivate() const;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче