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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!-- Testing page used in ClearSiteDataThrottleTest. -->
2
3 <html>
4 <head>
5 </head>
6 <body>
7 <img id="some_resource" />
8
9 <script>
10 // The C++ side of this test will inform us about the origin on which to
11 // test cross-origin requests. It will be passed in the |other_origin|
12 // query paramater.
13 var other_origin_param_regex = /other_origin=([^&=?]+)/;
14 var other_origin = decodeURIComponent(
15 window.location.search.match(other_origin_param_regex)[1]);
16
17 if (other_origin == window.location.origin)
18 throw new Error('|other_origin| must be different form the one this page loads on.');
19
20 // Set up a service worker to handle future requests.
21 function register_sw() {
22 worker_url =
23 '/?file=worker.js&other_origin=' + encodeURIComponent(other_origin);
24 navigator.serviceWorker.register(worker_url).then(function() {
25 // Inform the C++ side of this test that the worker is now registered.
26 window.location.hash += 'service-worker-registered';
27 console.log('Service worker registered.');
28 });
29 }
30
31 // Try to fetch a cross-origin resource with the Clear-Site-Data header.
32 // The service worker is not yet set up, so the header should be honored.
33 var header = encodeURIComponent('{ "types": [ "cookies" ] }');
34 var url = other_origin + 'some_resource?header=' + header;
35 var image = document.getElementById('some_resource');
36 image.onload = image.onerror = register_sw;
37 image.src = url;
38
39 // When the image finishes loading, its onload() event will register
40 // the service worker.
41 </script>
42 </body>
43 </html>
OLDNEW
« 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