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

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, 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 function service_worker_unregister_and_register(test, url, scope) { 3 function service_worker_unregister_and_register(test, url, scope) {
4 var options = scope ? { scope: scope } : {}; 4 var options = scope ? { scope: scope } : {};
5 return navigator.serviceWorker.unregister(scope).then( 5 return navigator.serviceWorker.unregister(scope).then(
6 test.step_func(function() { 6 test.step_func(function() {
7 return navigator.serviceWorker.register(url, options); 7 return navigator.serviceWorker.register(url, options);
8 }), 8 }),
9 unreached_rejection(test, 'Unregister should not fail') 9 unreached_rejection(test, 'Unregister should not fail')
10 ).then(test.step_func(function(worker) { 10 ).then(test.step_func(function(worker) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 break; 100 break;
101 case tests[i].NOTRUN: 101 case tests[i].NOTRUN:
102 // Leave NOTRUN alone. It'll get marked as a NOTRUN when the test 102 // Leave NOTRUN alone. It'll get marked as a NOTRUN when the test
103 // terminates. 103 // terminates.
104 break; 104 break;
105 } 105 }
106 } 106 }
107 }; 107 };
108 108
109 function service_worker_test(url, description) { 109 function service_worker_test(url, description) {
110 var scope = window.location.origin + '/service-worker-scope/' + 110 var scope = window.location.origin + '/service-worker-scope' +
111 window.location.pathname; 111 window.location.pathname;
112 112
113 var test = async_test(description); 113 var test = async_test(description);
114 service_worker_unregister_and_register(test, url, scope) 114 service_worker_unregister_and_register(test, url, scope)
115 .then(function(worker) { return fetch_tests_from_worker(worker); }) 115 .then(function(worker) { return fetch_tests_from_worker(worker); })
116 .then(function() { return navigator.serviceWorker.unregister(scope); }) 116 .then(function() { return navigator.serviceWorker.unregister(scope); })
117 .then(function() { test.done(); }) 117 .then(function() { test.done(); })
118 .catch(test.step_func(function(e) { throw e; })); 118 .catch(test.step_func(function(e) { throw e; }));
119 }; 119 };
120 120
(...skipping 19 matching lines...) Expand all
140 HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT, 140 HTTP_ORIGIN: 'http://' + ORIGINAL_HOST + ':' + HTTP_PORT,
141 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT, 141 HTTPS_ORIGIN: 'https://' + ORIGINAL_HOST + ':' + HTTPS_PORT,
142 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT, 142 HTTP_REMOTE_ORIGIN: 'http://' + REMOTE_HOST + ':' + HTTP_PORT,
143 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT 143 HTTPS_REMOTE_ORIGIN: 'https://' + REMOTE_HOST + ':' + HTTPS_PORT
144 }; 144 };
145 } 145 }
146 146
147 function base_path() { 147 function base_path() {
148 return location.pathname.replace(/\/[^\/]*$/, '/'); 148 return location.pathname.replace(/\/[^\/]*$/, '/');
149 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698