Chromium Code Reviews| Index: LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-iframe.html |
| diff --git a/LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-iframe.html b/LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-iframe.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..96d85486a55150a174ea8c2c41fa785b1d9e9028 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-iframe.html |
| @@ -0,0 +1,50 @@ |
| +<script src="test-helpers.js?pipe=sub"></script> |
| +<script> |
| +var port = undefined; |
| +var scope = 'fetch-request-body-file-test'; |
| +var script = 'fetch-request-body-file-worker.js'; |
| + |
| +window.addEventListener('message', function(evt) { |
| + port = evt.ports[0]; |
| + start(); |
| + }, false); |
| + |
| +function start() { |
| + if (location.search == '?register') { |
| + navigator.serviceWorker.register(script, {scope: scope}) |
| + .then(function(registration) { |
| + return registration.unregister(); |
| + }) |
| + .then(function() { |
| + return navigator.serviceWorker.register(script, {scope: scope}); |
| + }) |
| + .then(function(registration) { |
| + return new Promise(function(resolve) { |
| + registration.addEventListener('updatefound', function() { |
| + resolve(registration.installing); |
| + }); |
| + }); |
|
nhiroki
2014/08/25 04:29:37
How about factoring out this to 'wait_for_update()
horo
2014/08/25 11:20:23
Done.
|
| + }) |
| + .then(function(worker) { |
| + return new Promise(function(resolve) { |
| + worker.addEventListener('statechange', function() { |
| + if (worker.state == 'activated') { |
| + resolve(worker); |
| + } |
| + }); |
| + }); |
|
nhiroki
2014/08/25 04:29:37
ditto.
horo
2014/08/25 11:20:23
Done.
|
| + }) |
| + .then(function(worker) { |
| + port.postMessage({msg: 'registered'}); |
| + }); |
| + } else if (location.search == '?unregister') { |
| + navigator.serviceWorker.register(script, {scope: scope}) |
| + .then(function(registration) { |
| + return registration.unregister(); |
| + }) |
| + .then(function() { |
| + port.postMessage({msg: 'unregistered'}); |
| + }); |
| + } |
| +} |
| +</script> |