Bug 1502802 - Implement PostMessageOptions for Client and ServiceWorker, r=smaug

This commit is contained in:
Andrea Marchesini 2018-10-29 16:26:30 +01:00
Родитель a1f26d6d31
Коммит 5993c288fc
7 изменённых файлов: 34 добавлений и 6 удалений

Просмотреть файл

@ -12,6 +12,7 @@
#include "mozilla/dom/ClientManager.h"
#include "mozilla/dom/ClientState.h"
#include "mozilla/dom/DOMMozPromiseRequestHolder.h"
#include "mozilla/dom/MessagePortBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h"
@ -142,6 +143,14 @@ Client::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
mHandle->PostMessage(data, workerPrivate->GetServiceWorkerDescriptor());
}
void
Client::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const PostMessageOptions& aOptions,
ErrorResult& aRv)
{
PostMessage(aCx, aMessage, aOptions.mTransfer, aRv);
}
VisibilityState
Client::GetVisibilityState() const
{

Просмотреть файл

@ -22,6 +22,7 @@ namespace dom {
class ClientHandle;
class ClientInfoAndState;
struct PostMessageOptions;
class Promise;
template <typename t> class Sequence;
@ -89,6 +90,11 @@ public:
const Sequence<JSObject*>& aTransferrable,
ErrorResult& aRv);
void
PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const PostMessageOptions& aOptions,
ErrorResult& aRv);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(mozilla::dom::Client)
};

Просмотреть файл

@ -18,6 +18,7 @@
#include "mozilla/dom/ClientIPCTypes.h"
#include "mozilla/dom/ClientState.h"
#include "mozilla/dom/MessagePortBinding.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h"
#include "mozilla/dom/WorkerPrivate.h"
@ -230,6 +231,13 @@ ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
mInner->PostMessage(std::move(data), clientInfo.ref(), clientState.ref());
}
void
ServiceWorker::PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const PostMessageOptions& aOptions,
ErrorResult& aRv)
{
PostMessage(aCx, aMessage, aOptions.mTransfer, aRv);
}
const ServiceWorkerDescriptor&
ServiceWorker::Descriptor() const

Просмотреть файл

@ -21,6 +21,7 @@ class nsIGlobalObject;
namespace mozilla {
namespace dom {
struct PostMessageOptions;
class ServiceWorkerCloneData;
#define NS_DOM_SERVICEWORKER_IID \
@ -99,6 +100,10 @@ public:
PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const Sequence<JSObject*>& aTransferable, ErrorResult& aRv);
void
PostMessage(JSContext* aCx, JS::Handle<JS::Value> aMessage,
const PostMessageOptions& aOptions, ErrorResult& aRv);
const ServiceWorkerDescriptor&
Descriptor() const;

Просмотреть файл

@ -23,7 +23,9 @@ interface Client {
// readonly attribute boolean reserved;
[Throws]
void postMessage(any message, optional sequence<object> transfer = []);
void postMessage(any message, sequence<object> transfer);
[Throws]
void postMessage(any message, optional PostMessageOptions aOptions);
};
[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 PostMessageOptions options);
};
ServiceWorker implements AbstractWorker;

Просмотреть файл

@ -1,4 +0,0 @@
[postmessage.https.html]
[postMessage with dictionary a transferable ArrayBuffer between ServiceWorker and Client]
expected: FAIL