зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1475599 - part 1 - CookieStore API - WebIDL, r=smaug,edgul
Differential Revision: https://phabricator.services.mozilla.com/D215144
This commit is contained in:
Родитель
6a28b1e440
Коммит
c6b5fb82a2
|
@ -108,6 +108,7 @@
|
|||
#include "mozilla/dom/ClientState.h"
|
||||
#include "mozilla/dom/ClientsBinding.h"
|
||||
#include "mozilla/dom/Console.h"
|
||||
#include "mozilla/dom/CookieStore.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentFrameMessageManager.h"
|
||||
#include "mozilla/dom/ContentMediaController.h"
|
||||
|
@ -1260,6 +1261,7 @@ void nsGlobalWindowInner::FreeInnerObjects() {
|
|||
mScrollbars = nullptr;
|
||||
|
||||
mConsole = nullptr;
|
||||
mCookieStore = nullptr;
|
||||
|
||||
mPaintWorklet = nullptr;
|
||||
|
||||
|
@ -1450,6 +1452,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindowInner)
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mScrollbars)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCrypto)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mConsole)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCookieStore)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPaintWorklet)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExternal)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInstallTrigger)
|
||||
|
@ -1562,6 +1565,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner)
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mScrollbars)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCrypto)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mConsole)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCookieStore)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPaintWorklet)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mExternal)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInstallTrigger)
|
||||
|
@ -7286,6 +7290,14 @@ already_AddRefed<Console> nsGlobalWindowInner::GetConsole(JSContext* aCx,
|
|||
return console.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<CookieStore> nsGlobalWindowInner::CookieStore() {
|
||||
if (!mCookieStore) {
|
||||
mCookieStore = CookieStore::Create(this);
|
||||
}
|
||||
|
||||
return do_AddRef(mCookieStore);
|
||||
}
|
||||
|
||||
bool nsGlobalWindowInner::IsSecureContext() const {
|
||||
JS::Realm* realm = js::GetNonCCWObjectRealm(GetWrapperPreserveColor());
|
||||
return JS::GetIsSecureContext(realm);
|
||||
|
|
|
@ -104,6 +104,7 @@ struct ChannelPixelLayout;
|
|||
class Credential;
|
||||
class ClientSource;
|
||||
class Console;
|
||||
class CookieStore;
|
||||
class Crypto;
|
||||
class CustomElementRegistry;
|
||||
class DataTransfer;
|
||||
|
@ -654,6 +655,8 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
|||
already_AddRefed<mozilla::dom::Console> GetConsole(JSContext* aCx,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<mozilla::dom::CookieStore> CookieStore();
|
||||
|
||||
// https://w3c.github.io/webappsec-secure-contexts/#dom-window-issecurecontext
|
||||
bool IsSecureContext() const;
|
||||
|
||||
|
@ -1374,6 +1377,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
|||
RefPtr<mozilla::dom::Crypto> mCrypto;
|
||||
RefPtr<mozilla::dom::cache::CacheStorage> mCacheStorage;
|
||||
RefPtr<mozilla::dom::Console> mConsole;
|
||||
RefPtr<mozilla::dom::CookieStore> mCookieStore;
|
||||
RefPtr<mozilla::dom::Worklet> mPaintWorklet;
|
||||
RefPtr<mozilla::dom::External> mExternal;
|
||||
RefPtr<mozilla::dom::InstallTriggerImpl> mInstallTrigger;
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/CookieChangeEvent.h"
|
||||
#include "mozilla/dom/CookieChangeEventBinding.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
CookieChangeEvent::CookieChangeEvent(EventTarget* aOwner,
|
||||
nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent)
|
||||
: Event(aOwner, aPresContext, aEvent) {}
|
||||
|
||||
CookieChangeEvent::~CookieChangeEvent() = default;
|
||||
|
||||
JSObject* CookieChangeEvent::WrapObjectInternal(
|
||||
JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
||||
return mozilla::dom::CookieChangeEvent_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
void CookieChangeEvent::GetChanged(nsTArray<CookieListItem>& aList) const {
|
||||
aList = mChanged.Clone();
|
||||
}
|
||||
|
||||
void CookieChangeEvent::GetDeleted(nsTArray<CookieListItem>& aList) const {
|
||||
aList = mDeleted.Clone();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<CookieChangeEvent> CookieChangeEvent::Constructor(
|
||||
const GlobalObject& aGlobal, const nsAString& aType,
|
||||
const CookieChangeEventInit& aEventInit) {
|
||||
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
RefPtr<CookieChangeEvent> event = new CookieChangeEvent(t, nullptr, nullptr);
|
||||
bool trusted = event->Init(t);
|
||||
|
||||
event->InitEvent(aType, aEventInit.mBubbles, aEventInit.mCancelable);
|
||||
event->SetTrusted(trusted);
|
||||
|
||||
if (aEventInit.mChanged.WasPassed()) {
|
||||
event->mChanged = aEventInit.mChanged.Value();
|
||||
}
|
||||
|
||||
if (aEventInit.mDeleted.WasPassed()) {
|
||||
event->mDeleted = aEventInit.mDeleted.Value();
|
||||
}
|
||||
|
||||
return event.forget();
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
|
@ -0,0 +1,41 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_CookieChangeEvent_h
|
||||
#define mozilla_dom_CookieChangeEvent_h
|
||||
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/CookieChangeEventBinding.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
class CookieChangeEvent final : public Event {
|
||||
public:
|
||||
CookieChangeEvent(EventTarget* aOwner, nsPresContext* aPresContext,
|
||||
WidgetEvent* aEvent);
|
||||
|
||||
JSObject* WrapObjectInternal(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
static already_AddRefed<CookieChangeEvent> Constructor(
|
||||
const GlobalObject& aGlobal, const nsAString& aType,
|
||||
const CookieChangeEventInit& aEventInit);
|
||||
|
||||
void GetChanged(nsTArray<CookieListItem>& aList) const;
|
||||
|
||||
void GetDeleted(nsTArray<CookieListItem>& aList) const;
|
||||
|
||||
private:
|
||||
~CookieChangeEvent();
|
||||
|
||||
nsTArray<CookieListItem> mChanged;
|
||||
nsTArray<CookieListItem> mDeleted;
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif /* mozilla_dom_CookieChangeEvent_h */
|
|
@ -0,0 +1,94 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "CookieStore.h"
|
||||
|
||||
#include "mozilla/dom/Promise.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(CookieStore)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(CookieStore,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CookieStore,
|
||||
DOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CookieStore)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(CookieStore, DOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(CookieStore, DOMEventTargetHelper)
|
||||
|
||||
// static
|
||||
already_AddRefed<CookieStore> CookieStore::Create(nsIGlobalObject* aGlobal) {
|
||||
return do_AddRef(new CookieStore(aGlobal));
|
||||
}
|
||||
|
||||
CookieStore::CookieStore(nsIGlobalObject* aGlobal)
|
||||
: DOMEventTargetHelper(aGlobal) {}
|
||||
|
||||
CookieStore::~CookieStore() = default;
|
||||
|
||||
JSObject* CookieStore::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) {
|
||||
return CookieStore_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CookieStore::Get(const nsAString& aName,
|
||||
ErrorResult& aRv) {
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CookieStore::Get(
|
||||
const CookieStoreGetOptions& aOptions, ErrorResult& aRv) {
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CookieStore::GetAll(const nsAString& aName,
|
||||
ErrorResult& aRv) {
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CookieStore::GetAll(
|
||||
const CookieStoreGetOptions& aOptions, ErrorResult& aRv) {
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CookieStore::Set(const nsAString& aName,
|
||||
const nsAString& aValue,
|
||||
ErrorResult& aRv) {
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CookieStore::Set(const CookieInit& aOptions,
|
||||
ErrorResult& aRv) {
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CookieStore::Delete(const nsAString& aName,
|
||||
ErrorResult& aRv) {
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<Promise> CookieStore::Delete(
|
||||
const CookieStoreDeleteOptions& aOptions, ErrorResult& aRv) {
|
||||
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace mozilla::dom
|
|
@ -0,0 +1,61 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_CookieStore_h
|
||||
#define mozilla_dom_CookieStore_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/CookieStoreBinding.h"
|
||||
|
||||
class nsIGlobalObject;
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
class Promise;
|
||||
|
||||
class CookieStore final : public DOMEventTargetHelper {
|
||||
friend class CookieStoreChild;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CookieStore, DOMEventTargetHelper)
|
||||
|
||||
static already_AddRefed<CookieStore> Create(nsIGlobalObject* aGlobalObject);
|
||||
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
already_AddRefed<Promise> Get(const nsAString& aName, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> Get(const CookieStoreGetOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> GetAll(const nsAString& aName, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> GetAll(const CookieStoreGetOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> Set(const nsAString& aName, const nsAString& aValue,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> Set(const CookieInit& aOptions, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> Delete(const nsAString& aName, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<Promise> Delete(const CookieStoreDeleteOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
IMPL_EVENT_HANDLER(change);
|
||||
|
||||
private:
|
||||
explicit CookieStore(nsIGlobalObject* aGlobal);
|
||||
~CookieStore();
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
||||
#endif /* mozilla_dom_CookieStore_h */
|
|
@ -0,0 +1,25 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
with Files("**"):
|
||||
BUG_COMPONENT = ("Core", "Networking: Cookies")
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
"CookieChangeEvent.h",
|
||||
"CookieStore.h",
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
"CookieChangeEvent.cpp",
|
||||
"CookieStore.cpp",
|
||||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
"../base",
|
||||
"../events",
|
||||
]
|
||||
|
||||
include("/ipc/chromium/chromium-config.mozbuild")
|
||||
|
||||
FINAL_LIBRARY = "xul"
|
|
@ -37,6 +37,7 @@ DIRS += [
|
|||
"chrome-webidl",
|
||||
"clients",
|
||||
"commandhandler",
|
||||
"cookiestore",
|
||||
"credentialmanagement",
|
||||
"crypto",
|
||||
"debugger",
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is:
|
||||
* https://wicg.github.io/cookie-store/#CookieChangeEvent
|
||||
*/
|
||||
|
||||
[Exposed=Window,
|
||||
SecureContext,
|
||||
Pref="dom.cookieStore.enabled"]
|
||||
interface CookieChangeEvent : Event {
|
||||
constructor(DOMString type, optional CookieChangeEventInit eventInitDict = {});
|
||||
// TODO: Use FrozenArray once available. (Bug 1236777)
|
||||
// [SameObject] readonly attribute FrozenArray<CookieListItem> changed;
|
||||
// [SameObject] readonly attribute FrozenArray<CookieListItem> deleted;
|
||||
[Frozen, Cached, Constant]
|
||||
readonly attribute sequence<CookieListItem> changed;
|
||||
[Frozen, Cached, Constant]
|
||||
readonly attribute sequence<CookieListItem> deleted;
|
||||
};
|
||||
|
||||
dictionary CookieChangeEventInit : EventInit {
|
||||
CookieList changed;
|
||||
CookieList deleted;
|
||||
};
|
|
@ -0,0 +1,100 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://wicg.github.io/cookie-store/#idl-index
|
||||
*
|
||||
* Copyright © 2024 the Contributors to the Cookie Store API Specification,
|
||||
* published by the Web Platform Incubator Community Group under the W3C
|
||||
* Community Contributor License Agreement (CLA). A human-readable summary is
|
||||
* available.
|
||||
*/
|
||||
|
||||
[Exposed=(ServiceWorker,Window),
|
||||
SecureContext,
|
||||
Pref="dom.cookieStore.enabled"]
|
||||
interface CookieStore : EventTarget {
|
||||
[Throws]
|
||||
Promise<CookieListItem?> get(USVString name);
|
||||
[Throws]
|
||||
Promise<CookieListItem?> get(optional CookieStoreGetOptions options = {});
|
||||
|
||||
[Throws]
|
||||
Promise<CookieList> getAll(USVString name);
|
||||
[Throws]
|
||||
Promise<CookieList> getAll(optional CookieStoreGetOptions options = {});
|
||||
|
||||
[Throws]
|
||||
Promise<undefined> set(USVString name, USVString value);
|
||||
[Throws]
|
||||
Promise<undefined> set(CookieInit options);
|
||||
|
||||
[Throws]
|
||||
Promise<undefined> delete(USVString name);
|
||||
[Throws]
|
||||
Promise<undefined> delete(CookieStoreDeleteOptions options);
|
||||
|
||||
/* Bug 1475599 - By spec, `onchange` should be available only on `Window`,
|
||||
* but because we do not want to implement the ExtendableCookieChangeEvent
|
||||
* for ServiceWorker, we have decided to expose this EventHandler everywhere.
|
||||
*/
|
||||
//[Exposed=Window]
|
||||
attribute EventHandler onchange;
|
||||
};
|
||||
|
||||
dictionary CookieStoreGetOptions {
|
||||
USVString name;
|
||||
USVString url;
|
||||
};
|
||||
|
||||
enum CookieSameSite {
|
||||
"strict",
|
||||
"lax",
|
||||
"none"
|
||||
};
|
||||
|
||||
dictionary CookieInit {
|
||||
required USVString name;
|
||||
required USVString value;
|
||||
DOMHighResTimeStamp? expires = null;
|
||||
USVString? domain = null;
|
||||
USVString path = "/";
|
||||
CookieSameSite sameSite = "strict";
|
||||
boolean partitioned = false;
|
||||
};
|
||||
|
||||
dictionary CookieStoreDeleteOptions {
|
||||
required USVString name;
|
||||
USVString? domain = null;
|
||||
USVString path = "/";
|
||||
boolean partitioned = false;
|
||||
};
|
||||
|
||||
dictionary CookieListItem {
|
||||
USVString name;
|
||||
USVString value;
|
||||
|
||||
/* Bug 1475599 - We decide to do not implement the entire cookie-store spec.
|
||||
* Instead, we implement only the subset that is compatible with document.cookie */
|
||||
// USVString? domain;
|
||||
// USVString path;
|
||||
// DOMHighResTimeStamp? expires;
|
||||
// boolean secure;
|
||||
// CookieSameSite sameSite;
|
||||
// boolean partitioned;
|
||||
};
|
||||
|
||||
typedef sequence<CookieListItem> CookieList;
|
||||
|
||||
/* Bug 1475599 - We decide to do not implement the entire cookie-store spec.
|
||||
* Instead, we implement only the subset that is compatible with document.cookie
|
||||
[Exposed=(ServiceWorker,Window),
|
||||
SecureContext]
|
||||
interface CookieStoreManager {
|
||||
Promise<undefined> subscribe(sequence<CookieStoreGetOptions> subscriptions);
|
||||
Promise<sequence<CookieStoreGetOptions>> getSubscriptions();
|
||||
Promise<undefined> unsubscribe(sequence<CookieStoreGetOptions> subscriptions);
|
||||
};
|
||||
*/
|
|
@ -7,6 +7,7 @@
|
|||
* http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html
|
||||
* http://w3c.github.io/push-api/
|
||||
* https://notifications.spec.whatwg.org/
|
||||
* https://wicg.github.io/cookie-store/#ServiceWorkerGlobalScope
|
||||
*
|
||||
* You are granted a license to use, reproduce and create derivative works of
|
||||
* this document.
|
||||
|
@ -47,3 +48,13 @@ partial interface ServiceWorkerGlobalScope {
|
|||
// Mixin the WebExtensions API globals (the actual properties are only available to
|
||||
// extension service workers, locked behind a Func="extensions::ExtensionAPIAllowed" annotation).
|
||||
ServiceWorkerGlobalScope includes ExtensionGlobalsMixin;
|
||||
|
||||
// https://wicg.github.io/cookie-store/#ServiceWorkerGlobalScope
|
||||
partial interface ServiceWorkerGlobalScope {
|
||||
[SameObject, Pref="dom.cookieStore.enabled"] readonly attribute CookieStore cookieStore;
|
||||
|
||||
/* Bug 1475599 - We decide to do not implement the entire cookie-store spec.
|
||||
* Instead, we implement only the subset that is compatible with document.cookie
|
||||
attribute EventHandler oncookiechange;
|
||||
*/
|
||||
};
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
* http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html
|
||||
* https://w3c.github.io/push-api/
|
||||
* https://notifications.spec.whatwg.org/
|
||||
* https://wicg.github.io/cookie-store/#idl-index
|
||||
*/
|
||||
|
||||
[Func="ServiceWorkerVisible",
|
||||
|
@ -52,3 +53,11 @@ partial interface ServiceWorkerRegistration {
|
|||
[NewObject, Func="mozilla::dom::Notification::PrefEnabled"]
|
||||
Promise<sequence<Notification>> getNotifications(optional GetNotificationOptions filter = {});
|
||||
};
|
||||
|
||||
/* Bug 1475599 - We decide to do not implement the entire cookie-store spec.
|
||||
* Instead, we implement only the subset that is compatible with document.cookie
|
||||
[Exposed=(ServiceWorker,Window)]
|
||||
partial interface ServiceWorkerRegistration {
|
||||
[SameObject] readonly attribute CookieStoreManager cookies;
|
||||
};
|
||||
*/
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
* https://w3c.github.io/requestidlecallback/
|
||||
* https://drafts.css-houdini.org/css-paint-api-1/#dom-window-paintworklet
|
||||
* https://wicg.github.io/visual-viewport/#the-visualviewport-interface
|
||||
* https://wicg.github.io/cookie-store/#Window
|
||||
*/
|
||||
|
||||
interface Principal;
|
||||
|
@ -811,3 +812,9 @@ partial interface Window {
|
|||
dictionary WindowPostMessageOptions : StructuredSerializeOptions {
|
||||
USVString targetOrigin = "/";
|
||||
};
|
||||
|
||||
// https://wicg.github.io/cookie-store/#Window
|
||||
[SecureContext]
|
||||
partial interface Window {
|
||||
[SameObject, Pref="dom.cookieStore.enabled"] readonly attribute CookieStore cookieStore;
|
||||
};
|
||||
|
|
|
@ -480,6 +480,8 @@ WEBIDL_FILES = [
|
|||
"Console.webidl",
|
||||
"ConstantSourceNode.webidl",
|
||||
"ConvolverNode.webidl",
|
||||
"CookieChangeEvent.webidl",
|
||||
"CookieStore.webidl",
|
||||
"CreateOfferRequest.webidl",
|
||||
"CredentialManagement.webidl",
|
||||
"Crypto.webidl",
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "mozilla/dom/ClientSource.h"
|
||||
#include "mozilla/dom/Clients.h"
|
||||
#include "mozilla/dom/Console.h"
|
||||
#include "mozilla/dom/CookieStore.h"
|
||||
#include "mozilla/dom/DOMMozPromiseRequestHolder.h"
|
||||
#include "mozilla/dom/DebuggerNotification.h"
|
||||
#include "mozilla/dom/DebuggerNotificationBinding.h"
|
||||
|
@ -1099,7 +1100,8 @@ void SharedWorkerGlobalScope::Close() {
|
|||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope,
|
||||
mClients, mExtensionBrowser, mRegistration)
|
||||
mClients, mExtensionBrowser, mRegistration,
|
||||
mCookieStore)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ServiceWorkerGlobalScope)
|
||||
NS_INTERFACE_MAP_END_INHERITING(WorkerGlobalScope)
|
||||
|
||||
|
@ -1246,6 +1248,14 @@ ServiceWorkerGlobalScope::AcquireExtensionBrowser() {
|
|||
return mExtensionBrowser.clonePtr();
|
||||
}
|
||||
|
||||
already_AddRefed<CookieStore> ServiceWorkerGlobalScope::CookieStore() {
|
||||
if (!mCookieStore) {
|
||||
mCookieStore = CookieStore::Create(this);
|
||||
}
|
||||
|
||||
return do_AddRef(mCookieStore);
|
||||
}
|
||||
|
||||
bool WorkerDebuggerGlobalScope::WrapGlobalObject(
|
||||
JSContext* aCx, JS::MutableHandle<JSObject*> aReflector) {
|
||||
AssertIsOnWorkerThread();
|
||||
|
|
|
@ -55,6 +55,7 @@ class ClientInfo;
|
|||
class ClientSource;
|
||||
class Clients;
|
||||
class Console;
|
||||
class CookieStore;
|
||||
class Crypto;
|
||||
class DOMString;
|
||||
class DebuggerNotificationManager;
|
||||
|
@ -482,6 +483,8 @@ class ServiceWorkerGlobalScope final : public WorkerGlobalScope {
|
|||
|
||||
void EventListenerAdded(nsAtom* aType) override;
|
||||
|
||||
already_AddRefed<mozilla::dom::CookieStore> CookieStore();
|
||||
|
||||
IMPL_EVENT_HANDLER(message)
|
||||
IMPL_EVENT_HANDLER(messageerror)
|
||||
|
||||
|
@ -491,6 +494,8 @@ class ServiceWorkerGlobalScope final : public WorkerGlobalScope {
|
|||
IMPL_EVENT_HANDLER(push)
|
||||
IMPL_EVENT_HANDLER(pushsubscriptionchange)
|
||||
|
||||
IMPL_EVENT_HANDLER(cookiechange)
|
||||
|
||||
private:
|
||||
~ServiceWorkerGlobalScope();
|
||||
|
||||
|
@ -500,6 +505,7 @@ class ServiceWorkerGlobalScope final : public WorkerGlobalScope {
|
|||
const nsString mScope;
|
||||
RefPtr<ServiceWorkerRegistration> mRegistration;
|
||||
SafeRefPtr<extensions::ExtensionBrowser> mExtensionBrowser;
|
||||
RefPtr<mozilla::dom::CookieStore> mCookieStore;
|
||||
};
|
||||
|
||||
class WorkerDebuggerGlobalScope final : public WorkerGlobalScopeBase {
|
||||
|
|
|
@ -2348,6 +2348,12 @@
|
|||
value: true
|
||||
mirror: always
|
||||
|
||||
# Disable cookie-store API
|
||||
- name: dom.cookieStore.enabled
|
||||
type: RelaxedAtomicBool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
# Is support for CSSPseudoElement enabled?
|
||||
- name: dom.css_pseudo_element.enabled
|
||||
type: bool
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# https://bugzilla.mozilla.org/show_bug.cgi?id=1475599
|
||||
prefs: [dom.cookieStore.enabled:true]
|
||||
implementation-status: backlog
|
||||
lsan-allowed: [Alloc, Malloc, Then, mozilla::BasePrincipal::CreateContentPrincipal, mozilla::dom::DocGroup::Create, mozilla::dom::ServiceWorkerJobQueue::RunJob, mozilla::dom::ServiceWorkerManager::Unregister, mozilla::dom::ServiceWorkerRegistrationMainThread::Unregister, mozilla::dom::UnregisterCallback::UnregisterCallback, mozilla::net::nsStandardURL::TemplatedMutator, operator]
|
||||
|
|
|
@ -800,6 +800,7 @@ STATIC_ATOMS = [
|
|||
Atom("oncontextmenu", "oncontextmenu"),
|
||||
Atom("oncontextlost", "oncontextlost"),
|
||||
Atom("oncontextrestored", "oncontextrestored"),
|
||||
Atom("oncookiechange", "oncookiechange"),
|
||||
Atom("oncopy", "oncopy"),
|
||||
Atom("oncut", "oncut"),
|
||||
Atom("oncurrententrychange", "oncurrententrychange"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче