Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1669)

Unified Diff: content/test/data/browsing_data/worker_setup.html

Issue 2368923003: Support the Clear-Site-Data header on resource requests (Closed)
Patch Set: Addressed comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/test/data/browsing_data/worker_setup.html
diff --git a/content/test/data/browsing_data/worker_setup.html b/content/test/data/browsing_data/worker_setup.html
new file mode 100644
index 0000000000000000000000000000000000000000..1a88d47bec1234f3cdad0ffb077e428e98576a63
--- /dev/null
+++ b/content/test/data/browsing_data/worker_setup.html
@@ -0,0 +1,43 @@
+<!-- Testing page used in ClearSiteDataThrottleTest. -->
+
+<html>
+ <head>
+ </head>
+ <body>
+ <img id="some_resource" />
+
+ <script>
+ // The C++ side of this test will inform us about the origin on which to
+ // test cross-origin requests. It will be passed in the |other_origin|
+ // query paramater.
+ var other_origin_param_regex = /other_origin=([^&=?]+)/;
+ var other_origin = decodeURIComponent(
+ window.location.search.match(other_origin_param_regex)[1]);
+
+ if (other_origin == window.location.origin)
+ throw new Error('|other_origin| must be different form the one this page loads on.');
+
+ // Set up a service worker to handle future requests.
+ function register_sw() {
+ worker_url =
+ '/?file=worker.js&other_origin=' + encodeURIComponent(other_origin);
+ navigator.serviceWorker.register(worker_url).then(function() {
+ // Inform the C++ side of this test that the worker is now registered.
+ window.location.hash += 'service-worker-registered';
+ console.log('Service worker registered.');
+ });
+ }
+
+ // Try to fetch a cross-origin resource with the Clear-Site-Data header.
+ // The service worker is not yet set up, so the header should be honored.
+ var header = encodeURIComponent('{ "types": [ "cookies" ] }');
+ var url = other_origin + 'some_resource?header=' + header;
+ var image = document.getElementById('some_resource');
+ image.onload = image.onerror = register_sw;
+ image.src = url;
+
+ // When the image finishes loading, its onload() event will register
+ // the service worker.
+ </script>
+ </body>
+</html>
« content/test/data/browsing_data/worker.js ('K') | « content/test/data/browsing_data/worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698