mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-26 17:17:31 +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;
|
readonly attribute DOMString id;
|
||||||
|
|
||||||
[Throws]
|
[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]
|
[Exposed=ServiceWorker]
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,9 @@ interface ServiceWorker : EventTarget {
|
||||||
attribute EventHandler onstatechange;
|
attribute EventHandler onstatechange;
|
||||||
|
|
||||||
[Throws]
|
[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;
|
ServiceWorker implements AbstractWorker;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "mozilla/dom/Promise.h"
|
#include "mozilla/dom/Promise.h"
|
||||||
|
#include "mozilla/dom/MessagePortBinding.h"
|
||||||
#include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h"
|
#include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h"
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
|
|
@ -97,6 +98,15 @@ ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
|
||||||
aRv = workerPrivate->SendMessageEvent(aCx, aMessage, aTransferable, Move(clientInfo));
|
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 workers
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ class nsPIDOMWindowInner;
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
|
struct StructuredSerializeOptions;
|
||||||
|
|
||||||
namespace workers {
|
namespace workers {
|
||||||
|
|
||||||
class ServiceWorkerInfo;
|
class ServiceWorkerInfo;
|
||||||
|
|
@ -66,6 +68,12 @@ public:
|
||||||
const Sequence<JSObject*>& aTransferable,
|
const Sequence<JSObject*>& aTransferable,
|
||||||
ErrorResult& aRv);
|
ErrorResult& aRv);
|
||||||
|
|
||||||
|
void
|
||||||
|
PostMessage(JSContext* aCx,
|
||||||
|
JS::Handle<JS::Value> aMessage,
|
||||||
|
const StructuredSerializeOptions& aOptions,
|
||||||
|
ErrorResult& aRv);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This class can only be created from ServiceWorkerInfo::GetOrCreateInstance().
|
// This class can only be created from ServiceWorkerInfo::GetOrCreateInstance().
|
||||||
ServiceWorker(nsPIDOMWindowInner* aWindow, ServiceWorkerInfo* aInfo);
|
ServiceWorker(nsPIDOMWindowInner* aWindow, ServiceWorkerInfo* aInfo);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
#include "mozilla/dom/Navigator.h"
|
#include "mozilla/dom/Navigator.h"
|
||||||
#include "mozilla/dom/ServiceWorkerMessageEvent.h"
|
#include "mozilla/dom/ServiceWorkerMessageEvent.h"
|
||||||
#include "mozilla/dom/ServiceWorkerMessageEventBinding.h"
|
#include "mozilla/dom/ServiceWorkerMessageEventBinding.h"
|
||||||
|
#include "mozilla/dom/MessagePortBinding.h"
|
||||||
#include "nsGlobalWindow.h"
|
#include "nsGlobalWindow.h"
|
||||||
#include "nsIBrowserDOMWindow.h"
|
#include "nsIBrowserDOMWindow.h"
|
||||||
#include "nsIDocument.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,
|
const Sequence<JSObject*>& aTransferable,
|
||||||
ErrorResult& aRv);
|
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;
|
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue