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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/test-helpers.js

Issue 430993002: [ServiceWorker] CacheStorage tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Adapter for testharness.js-style tests with Service Workers 1 // Adapter for testharness.js-style tests with Service Workers
2 2
3 // Can only be used with a worker that installs successfully, since it 3 // Can only be used with a worker that installs successfully, since it
4 // first registers to acquire a ServiceWorkerRegistration object to 4 // first registers to acquire a ServiceWorkerRegistration object to
5 // unregister. 5 // unregister.
6 // FIXME: Use getRegistration() when implemented. 6 // FIXME: Use getRegistration() when implemented.
7 function service_worker_unregister_and_register(test, url, scope) { 7 function service_worker_unregister_and_register(test, url, scope) {
8 var options = scope ? { scope: scope } : {}; 8 var options = scope ? { scope: scope } : {};
9 return navigator.serviceWorker.register(url, options) 9 return navigator.serviceWorker.register(url, options)
10 .then(function(registration) { 10 .then(function(registration) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 break; 111 break;
112 case tests[i].NOTRUN: 112 case tests[i].NOTRUN:
113 // Leave NOTRUN alone. It'll get marked as a NOTRUN when the test 113 // Leave NOTRUN alone. It'll get marked as a NOTRUN when the test
114 // terminates. 114 // terminates.
115 break; 115 break;
116 } 116 }
117 } 117 }
118 }; 118 };
119 119
120 function service_worker_test(url, description) { 120 function service_worker_test(url, description) {
121 var scope = window.location.origin + '/service-worker-scope/' + 121 var scope = window.location.origin + '/service-worker-scope' +
122 window.location.pathname; 122 window.location.pathname;
123 123
124 var test = async_test(description); 124 var test = async_test(description);
125 service_worker_unregister_and_register(test, url, scope) 125 service_worker_unregister_and_register(test, url, scope)
126 .then(function(registration) { 126 .then(function(registration) {
127 return wait_for_update(test, registration); 127 return wait_for_update(test, registration);
128 }) 128 })
129 .then(function(worker) { return fetch_tests_from_worker(worker); }) 129 .then(function(worker) { return fetch_tests_from_worker(worker); })
130 .then(function() { return navigator.serviceWorker.unregister(scope); }) 130 .then(function() { return navigator.serviceWorker.unregister(scope); })
131 .then(function() { test.done(); }) 131 .then(function() { test.done(); })
(...skipping 22 matching lines...) Expand all
154 HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT, 154 HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT,
155 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT, 155 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT,
156 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT, 156 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT,
157 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT 157 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT
158 }; 158 };
159 } 159 }
160 160
161 function base_path() { 161 function base_path() {
162 return location.pathname.replace(/\/[^\/]*$/, '/'); 162 return location.pathname.replace(/\/[^\/]*$/, '/');
163 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698