From 504d1fd85a5781531f8bdb1095dfbd4229da50d4 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Sun, 16 Jul 2023 01:49:39 +0000 Subject: [PATCH] Bug 1841112 [wpt PR 40815] - [Client Hints] Support custom Clear-Site-Data method, a=testonly Automatic update from web-platform-tests [Client Hints] Support custom Clear-Site-Data method Let's add a (disabled by default) method to target just client hints for clearing. This is per the proposed spec change: https://github.com/w3c/webappsec-clear-site-data/pull/74 Note: The next step is to ensure that the Clear-Site-Data directive causes any Accept-CH or Critical-CH to be ignored when it does clear client hints. Bug: 1458394 Change-Id: Iae52b86d68bd6c0f81a9886c6ee29b7245d6915a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4652839 Reviewed-by: Avi Drissman Commit-Queue: Avi Drissman Auto-Submit: Ari Chivukula Reviewed-by: Arthur Sonzogni Cr-Commit-Position: refs/heads/main{#1165947} -- wpt-commits: fc5bb604a77419e6bdcd0f52a072713c04385cfb wpt-pr: 40815 UltraBlame original commit: d3360fa0d016dc45ffdad7991fb0c779a704d08c --- .../clear-site-data-all.https.html | 21 +- .../clear-site-data-cache.https.html | 21 +- .../clear-site-data-client-hints.https.html | 383 ++++++++++++++++++ ...-site-data-client-hints.https.html.headers | 11 + .../clear-site-data-cookies.https.html | 21 +- .../clear-site-data-storage.https.html | 21 +- 6 files changed, 454 insertions(+), 24 deletions(-) create mode 100644 testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-client-hints.https.html create mode 100644 testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-client-hints.https.html.headers diff --git a/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-all.https.html b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-all.https.html index ef9a0445941c0..641b80f939760 100644 --- a/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-all.https.html +++ b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-all.https.html @@ -240,12 +240,6 @@ " ) ; -new_window -. -close -( -) -; t . done @@ -337,6 +331,21 @@ " ) ; +t +. +add_cleanup +( +( +) += +> +new_window +. +close +( +) +) +; } " Clear diff --git a/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-cache.https.html b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-cache.https.html index 80dfe5b588872..401fd96783ab2 100644 --- a/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-cache.https.html +++ b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-cache.https.html @@ -240,12 +240,6 @@ " ) ; -new_window -. -close -( -) -; t . done @@ -341,6 +335,21 @@ " ) ; +t +. +add_cleanup +( +( +) += +> +new_window +. +close +( +) +) +; } " Clear diff --git a/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-client-hints.https.html b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-client-hints.https.html new file mode 100644 index 0000000000000..1af5f368fdafc --- /dev/null +++ b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-client-hints.https.html @@ -0,0 +1,383 @@ +< +! +DOCTYPE +html +> +< +body +> +< +script +src += +" +/ +resources +/ +testharness +. +js +" +> +< +/ +script +> +< +script +src += +" +/ +resources +/ +testharnessreport +. +js +" +> +< +/ +script +> +< +script +> +/ +/ +Here +' +s +the +set +- +up +for +this +test +: +/ +/ +Step +1 +( +first +window +) +Open +new +window +to +verify +that +hints +were +set +. +/ +/ +Step +2 +( +second +window +) +Alert +first +window +of +client +hints +present +. +/ +/ +Step +3 +( +first +window +) +Asserts +client +hints +were +present +. +/ +/ +Step +4 +( +first +window +) +Navigate +other +window +to +page +that +clears +client +hint +data +. +/ +/ +Step +5 +( +second +window +) +Navigate +to +a +page +that +can +check +client +hints +still +sent +. +/ +/ +Step +6 +( +second +window +) +Alert +first +window +of +client +hints +present +. +/ +/ +Step +7 +( +first +window +) +Asserts +client +hints +were +not +present +. +async_test +( +t += +> +{ +var +new_window +; +/ +/ +Step +3 +window +. +addEventListener +( +" +message +" +t +. +step_func +( +e += +> +{ +assert_equals +( +e +. +data +" +HadDeviceMemory +" +) +; +/ +/ +Step +7 +window +. +addEventListener +( +" +message +" +t +. +step_func +( +e += +> +{ +assert_equals +( +e +. +data +" +MissingDeviceMemory +" +) +; +t +. +done +( +) +; +} +) +{ +once +: +true +} +) +; +/ +/ +Step +4 +new_window +. +location +. +href += +" +/ +client +- +hints +/ +clear +- +site +- +data +/ +resources +/ +clear +- +site +- +data +. +py +? +target += +clientHints +" +; +} +) +{ +once +: +true +} +) +; +/ +/ +Step +1 +new_window += +window +. +open +( +" +/ +client +- +hints +/ +clear +- +site +- +data +/ +resources +/ +check +- +client +- +hints +. +py +" +) +; +t +. +add_cleanup +( +( +) += +> +new_window +. +close +( +) +) +; +} +" +Clear +- +Site +- +Data +for +clientHints +should +remove +all +client +hints +. +" +) +; +< +/ +script +> +< +/ +body +> +< +/ +html +> diff --git a/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-client-hints.https.html.headers b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-client-hints.https.html.headers new file mode 100644 index 0000000000000..378e30946f211 --- /dev/null +++ b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-client-hints.https.html.headers @@ -0,0 +1,11 @@ +Accept +- +CH +: +Sec +- +CH +- +Device +- +Memory diff --git a/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-cookies.https.html b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-cookies.https.html index 0eeed7c72bd86..a81413c4e72f9 100644 --- a/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-cookies.https.html +++ b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-cookies.https.html @@ -239,12 +239,6 @@ " ) ; -new_window -. -close -( -) -; t . done @@ -340,6 +334,21 @@ " ) ; +t +. +add_cleanup +( +( +) += +> +new_window +. +close +( +) +) +; } " Clear diff --git a/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-storage.https.html b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-storage.https.html index 273d762e28475..b96d64f2b2670 100644 --- a/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-storage.https.html +++ b/testing/web-platform/tests/client-hints/clear-site-data/clear-site-data-storage.https.html @@ -239,12 +239,6 @@ " ) ; -new_window -. -close -( -) -; t . done @@ -340,6 +334,21 @@ " ) ; +t +. +add_cleanup +( +( +) += +> +new_window +. +close +( +) +) +; } " Clear