| 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>
|
|
|