Skip to content

Truly independent web browser

LibWeb: Mark CookieStore change events as trusted

Shannon Booth315fffb0e8be
diff --git a/Libraries/LibWeb/Bindings/Rust/src/cookie_store/cookie_store.rs b/Libraries/LibWeb/Bindings/Rust/src/cookie_store/cookie_store.rs
index 3305a298180..1317c056cc7 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/cookie_store/cookie_store.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/cookie_store/cookie_store.rs
@@ -1100,6 +1100,7 @@ impl CookieStore {
};
let event =
CookieChangeEvent::create(vm, this.realm, &Utf16String::from_utf8("change"), event_init);
+ event.event().set_is_trusted(true);
// 7. Dispatch event at target.
this.event_target.dispatch_event(event.event());
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index 10d5d973439..6a647afd4d0 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -1292,6 +1292,7 @@ Text/input/third-party-cookies-are-partitioned.html
Text/input/cookies-of-a-frame-with-a-cross-site-ancestor-are-partitioned.html
Text/input/document-cookie-uses-the-partition-of-the-asking-document.html
Text/input/cookie-change-events-skip-other-partitions.html
+Text/input/cookie-change-event-is-trusted.html
Text/input/SiteIsolation/iframe/removing-remote-iframe-aborts-its-navigation-api.html
Text/input/SiteIsolation/iframe/unload-runs-in-remote-iframe-when-parent-navigates.html
Text/input/SiteIsolation/iframe/remote-iframe-unloads-before-its-parent-hosts-it.html
diff --git a/Tests/LibWeb/Text/expected/cookie-change-event-is-trusted.txt b/Tests/LibWeb/Text/expected/cookie-change-event-is-trusted.txt
new file mode 100644
index 00000000000..8727108de4f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/cookie-change-event-is-trusted.txt
@@ -0,0 +1 @@
+isTrusted: true
diff --git a/Tests/LibWeb/Text/input/cookie-change-event-is-trusted.html b/Tests/LibWeb/Text/input/cookie-change-event-is-trusted.html
new file mode 100644
index 00000000000..ae89178e870
--- /dev/null
+++ b/Tests/LibWeb/Text/input/cookie-change-event-is-trusted.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<script src="include.js"></script>
+<script>
+ promiseTest(async () => {
+ const event = await new Promise(resolve => {
+ cookieStore.addEventListener("change", resolve, { once: true });
+ cookieStore.set("trusted", "1");
+ });
+ println(`isTrusted: ${event.isTrusted}`);
+ await cookieStore.delete("trusted");
+ });
+</script>