Skip to content

Commit 3cb97fc

Browse files
authored
script: Move cookie_store from GlobalScope into Window (servo#44115)
Push GlobalScope::cookie_store down into Window Testing: ./mach test-wpt tests/wpt/tests/cookiestore Fixes: servo#44107 Signed-off-by: Kelechi Ebiri <ebiritg@gmail.com>
1 parent d8cc8f3 commit 3cb97fc

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

components/script/dom/globalscope.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ use crate::dom::serviceworker::ServiceWorker;
130130
use crate::dom::serviceworkerregistration::ServiceWorkerRegistration;
131131
use crate::dom::stream::underlyingsourcecontainer::UnderlyingSourceType;
132132
use crate::dom::stream::writablestream::CrossRealmTransformWritable;
133-
use crate::dom::types::{AbortSignal, CookieStore, DebuggerGlobalScope, MessageEvent};
133+
use crate::dom::types::{AbortSignal, DebuggerGlobalScope, MessageEvent};
134134
#[cfg(feature = "webgpu")]
135135
use crate::dom::webgpu::gpudevice::GPUDevice;
136136
#[cfg(feature = "webgpu")]
@@ -230,9 +230,6 @@ pub(crate) struct GlobalScope {
230230
>,
231231
>,
232232

233-
/// <https://cookiestore.spec.whatwg.org/#globals>
234-
cookie_store: MutNullableDom<CookieStore>,
235-
236233
/// <https://w3c.github.io/IndexedDB/#factory-interface>
237234
indexeddb: MutNullableDom<IDBFactory>,
238235

@@ -780,7 +777,6 @@ impl GlobalScope {
780777
eventtarget: EventTarget::new_inherited(),
781778
crypto: Default::default(),
782779
registration_map: DomRefCell::new(HashMapTracedValues::new_fx()),
783-
cookie_store: Default::default(),
784780
indexeddb: Default::default(),
785781
worker_map: DomRefCell::new(HashMapTracedValues::new_fx()),
786782
pipeline_id,
@@ -2418,10 +2414,6 @@ impl GlobalScope {
24182414
self.crypto.or_init(|| Crypto::new(self, can_gc))
24192415
}
24202416

2421-
pub(crate) fn cookie_store(&self, can_gc: CanGc) -> DomRoot<CookieStore> {
2422-
self.cookie_store.or_init(|| CookieStore::new(self, can_gc))
2423-
}
2424-
24252417
pub(crate) fn live_devtools_updates(&self) -> bool {
24262418
self.devtools_wants_updates.get()
24272419
}

components/script/dom/window.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ pub(crate) struct Window {
306306
screen: MutNullableDom<Screen>,
307307
session_storage: MutNullableDom<Storage>,
308308
local_storage: MutNullableDom<Storage>,
309+
/// <https://cookiestore.spec.whatwg.org/#globals>
310+
cookie_store: MutNullableDom<CookieStore>,
309311
status: DomRefCell<DOMString>,
310312
trusted_types: MutNullableDom<TrustedTypePolicyFactory>,
311313

@@ -1502,7 +1504,8 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
15021504

15031505
/// <https://cookiestore.spec.whatwg.org/#Window>
15041506
fn CookieStore(&self, can_gc: CanGc) -> DomRoot<CookieStore> {
1505-
self.global().cookie_store(can_gc)
1507+
self.cookie_store
1508+
.or_init(|| CookieStore::new(self.upcast::<GlobalScope>(), can_gc))
15061509
}
15071510

15081511
/// <https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-GlobalCrypto>
@@ -3702,6 +3705,7 @@ impl Window {
37023705
screen: Default::default(),
37033706
session_storage: Default::default(),
37043707
local_storage: Default::default(),
3708+
cookie_store: Default::default(),
37053709
status: DomRefCell::new(DOMString::new()),
37063710
parent_info,
37073711
dom_static: GlobalStaticData::new(),

0 commit comments

Comments
 (0)