mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
Issue #2197 - Part 2c: Implement StructuredSerializeOptions for ServiceWorker
Partially based on https://bugzilla.mozilla.org/show_bug.cgi?id=1502802
This commit is contained in:
parent
158784cbed
commit
4d58139fe1
6 changed files with 39 additions and 2 deletions
|
|
@ -15,7 +15,9 @@ interface Client {
|
|||
readonly attribute DOMString id;
|
||||
|
||||
[Throws]
|
||||
void postMessage(any message, optional sequence<object> transfer = []);
|
||||
void postMessage(any message, sequence<object> transferable);
|
||||
[Throws]
|
||||
void postMessage(any message, optional StructuredSerializeOptions options);
|
||||
};
|
||||
|
||||
[Exposed=ServiceWorker]
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ interface ServiceWorker : EventTarget {
|
|||
attribute EventHandler onstatechange;
|
||||
|
||||
[Throws]
|
||||
void postMessage(any message, optional sequence<object> transferable = []);
|
||||
void postMessage(any message, sequence<object> transferable);
|
||||
[Throws]
|
||||
void postMessage(any message, optional StructuredSerializeOptions options);
|
||||
};
|
||||
|
||||
ServiceWorker implements AbstractWorker;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "mozilla/dom/MessagePortBinding.h"
|
||||
#include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
|
@ -97,6 +98,15 @@ ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|||
aRv = workerPrivate->SendMessageEvent(aCx, aMessage, aTransferable, Move(clientInfo));
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorker::PostMessage(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aMessage,
|
||||
const StructuredSerializeOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
PostMessage(aCx, aMessage, aOptions.mTransfer, aRv);
|
||||
}
|
||||
|
||||
} // namespace workers
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ class nsPIDOMWindowInner;
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
struct StructuredSerializeOptions;
|
||||
|
||||
namespace workers {
|
||||
|
||||
class ServiceWorkerInfo;
|
||||
|
|
@ -66,6 +68,12 @@ public:
|
|||
const Sequence<JSObject*>& aTransferable,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void
|
||||
PostMessage(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aMessage,
|
||||
const StructuredSerializeOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
private:
|
||||
// This class can only be created from ServiceWorkerInfo::GetOrCreateInstance().
|
||||
ServiceWorker(nsPIDOMWindowInner* aWindow, ServiceWorkerInfo* aInfo);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "mozilla/dom/Navigator.h"
|
||||
#include "mozilla/dom/ServiceWorkerMessageEvent.h"
|
||||
#include "mozilla/dom/ServiceWorkerMessageEventBinding.h"
|
||||
#include "mozilla/dom/MessagePortBinding.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsIBrowserDOMWindow.h"
|
||||
#include "nsIDocument.h"
|
||||
|
|
@ -220,3 +221,11 @@ ServiceWorkerClient::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerClient::PostMessage(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aMessage,
|
||||
const StructuredSerializeOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
PostMessage(aCx, aMessage, aOptions.mTransfer, aRv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,12 @@ public:
|
|||
const Sequence<JSObject*>& aTransferable,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void
|
||||
PostMessage(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aMessage,
|
||||
const StructuredSerializeOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
protected:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue