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

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: Created 6 years, 3 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 if (!scope || scope.length == 0) 8 if (!scope || scope.length == 0)
9 return Promise.reject(new Error('tests must define a scope')); 9 return Promise.reject(new Error('tests must define a scope'));
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 break; 114 break;
115 case tests[i].NOTRUN: 115 case tests[i].NOTRUN:
116 // Leave NOTRUN alone. It'll get marked as a NOTRUN when the test 116 // Leave NOTRUN alone. It'll get marked as a NOTRUN when the test
117 // terminates. 117 // terminates.
118 break; 118 break;
119 } 119 }
120 } 120 }
121 }; 121 };
122 122
123 function service_worker_test(url, description) { 123 function service_worker_test(url, description) {
124 var scope = window.location.origin + '/service-worker-scope/' + 124 var scope = window.location.origin + '/service-worker-scope' +
125 window.location.pathname; 125 window.location.pathname;
126 126
127 var test = async_test(description); 127 var test = async_test(description);
128 service_worker_unregister_and_register(test, url, scope) 128 service_worker_unregister_and_register(test, url, scope)
129 .then(function(registration) { 129 .then(function(registration) {
130 return wait_for_update(test, registration); 130 return wait_for_update(test, registration);
131 }) 131 })
132 .then(function(worker) { return fetch_tests_from_worker(worker); }) 132 .then(function(worker) { return fetch_tests_from_worker(worker); })
133 .then(function() { return navigator.serviceWorker.unregister(scope); }) 133 .then(function() { return navigator.serviceWorker.unregister(scope); })
134 .then(function() { test.done(); }) 134 .then(function() { test.done(); })
(...skipping 22 matching lines...) Expand all
157 HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT, 157 HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT,
158 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT, 158 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT,
159 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT, 159 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT,
160 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT 160 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT
161 }; 161 };
162 } 162 }
163 163
164 function base_path() { 164 function base_path() {
165 return location.pathname.replace(/\/[^\/]*$/, '/'); 165 return location.pathname.replace(/\/[^\/]*$/, '/');
166 } 166 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698