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

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

Issue 1311103002: ServiceWorker: Make APIs that return ServiceWorkerRegistration coin a new JS object (3/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
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 if (!scope || scope.length == 0) 4 if (!scope || scope.length == 0)
5 return Promise.reject(new Error('tests must define a scope')); 5 return Promise.reject(new Error('tests must define a scope'));
6 6
7 var options = { scope: scope }; 7 var options = { scope: scope };
8 return service_worker_unregister(test, scope) 8 return service_worker_unregister(test, scope)
9 .then(function() { 9 .then(function() {
10 return navigator.serviceWorker.register(url, options); 10 return navigator.serviceWorker.register(url, options);
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 199
200 function login_https(test) { 200 function login_https(test) {
201 return test_login(test, 'https://127.0.0.1:8443', 201 return test_login(test, 'https://127.0.0.1:8443',
202 'username1s', 'password1s', 'cookie1') 202 'username1s', 'password1s', 'cookie1')
203 .then(function() { 203 .then(function() {
204 return test_login(test, 'https://localhost:8443', 204 return test_login(test, 'https://localhost:8443',
205 'username2s', 'password2s', 'cookie2'); 205 'username2s', 'password2s', 'cookie2');
206 }); 206 });
207 } 207 }
208
209 // Helper for testing with ServiceWorkerRegistration objects. Compares simple
210 // attributes defined on the interfaces.
211 function assert_registration_equals(actual, expected, description) {
212 assert_class_string(actual, "ServiceWorkerRegistration", description);
falken 2015/08/25 03:28:29 double quotes should be single quotes (and in seve
nhiroki 2015/08/25 06:28:07 Done.
213 ["scope", "installing", "waiting", "active"].forEach(function(attribute) {
214 assert_equals(actual[attribute], expected[attribute],
215 description + " Attributes differ: " + attribute + ".");
216 });
falken 2015/08/25 03:28:29 indent additional two spaces
nhiroki 2015/08/25 06:28:07 Done.
217 }
218
219 // Asserts that two arrays |actual| and |expected| contain the same set of
220 // ServiceWorkerRegistration as determined by assert_registration_equals(). The
221 // corresponding elements must occupy corresponding indices in their respective
222 // arrays.
223 function assert_registration_array_equals(actual, expected, description) {
224 assert_true(Array.isArray(actual), description);
225 assert_equals(actual.length, expected.length, description);
226 actual.forEach(function(value, index) {
227 assert_registration_equals(value, expected[index],
228 description + " : object[" + index + "]");
229 });
falken 2015/08/25 03:28:29 indent additional two spaces
nhiroki 2015/08/25 06:28:07 Done.
230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698