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

Unified Diff: LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-iframe.html

Issue 491203002: [ServiceWorker] Add test for FetchEvent's body with a local file. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove test-helpers.js from iframe Created 6 years, 4 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: 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..fa98d0a3d15ae12a492aa474221be691e5b1bc0b
--- /dev/null
+++ b/LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-iframe.html
@@ -0,0 +1,53 @@
+<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 wait_for_update(registration) {
+ return new Promise(function(resolve) {
+ registration.addEventListener('updatefound', function() {
+ resolve(registration.installing);
+ });
+ });
+}
+
+function wait_for_activated(worker) {
+ return new Promise(function(resolve) {
+ worker.addEventListener('statechange', function() {
+ if (worker.state == 'activated') {
+ resolve(worker);
+ }
+ });
+ });
+}
+
+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(wait_for_update)
+ .then(wait_for_activated)
+ .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>

Powered by Google App Engine
This is Rietveld 408576698