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

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

Issue 324893002: Add tests for navigator.serviceWorker.waiting. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Put the expected result file at the right path. Created 6 years, 6 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/waiting.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_test(url, description) { 3 function service_worker_test(url, description) {
4 var t = async_test(description); 4 var t = async_test(description);
5 t.step(function() { 5 t.step(function() {
6 var scope = 'nonexistent'; 6 var scope = 'nonexistent';
7 service_worker_unregister_and_register(t, url, scope, onRegistered); 7 service_worker_unregister_and_register(t, url, scope, onRegistered);
8 8
9 function onRegistered(worker) { 9 function onRegistered(worker) {
10 var messageChannel = new MessageChannel(); 10 var messageChannel = new MessageChannel();
(...skipping 16 matching lines...) Expand all
27 return navigator.serviceWorker.register(url, options); 27 return navigator.serviceWorker.register(url, options);
28 }, 28 },
29 unreached_rejection(test, 'Unregister should not fail') 29 unreached_rejection(test, 'Unregister should not fail')
30 ).then( 30 ).then(
31 test.step_func(onregister), 31 test.step_func(onregister),
32 unreached_rejection(test, 'Registration should not fail') 32 unreached_rejection(test, 'Registration should not fail')
33 ); 33 );
34 } 34 }
35 35
36 function service_worker_unregister_and_done(test, scope) { 36 function service_worker_unregister_and_done(test, scope) {
37 navigator.serviceWorker.unregister(scope).then( 37 return navigator.serviceWorker.unregister(scope).then(
38 test.done.bind(test), 38 test.done.bind(test),
39 unreached_rejection(test, 'Unregister should not fail')); 39 unreached_rejection(test, 'Unregister should not fail'));
40 } 40 }
41 41
42 // Rejection-specific helper that provides more details 42 // Rejection-specific helper that provides more details
43 function unreached_rejection(test, prefix) { 43 function unreached_rejection(test, prefix) {
44 return test.step_func(function(reason) { 44 return test.step_func(function(reason) {
45 assert_unreached(prefix + ': ' + reason.name); 45 assert_unreached(prefix + ': ' + reason.name);
46 }); 46 });
47 } 47 }
48 48
49 // FIXME: Clean up the iframe when the test completes. 49 // FIXME: Clean up the iframe when the test completes.
50 function with_iframe(url, f) { 50 function with_iframe(url, f) {
51 var frame = document.createElement('iframe'); 51 return new Promise(function(resolve, reject) {
52 frame.src = url; 52 var frame = document.createElement('iframe');
53 frame.onload = function() { 53 frame.src = url;
54 f(frame); 54 frame.onload = function() {
55 }; 55 if (f) {
56 document.body.appendChild(frame); 56 f(frame);
57 }
58 resolve(frame);
59 };
60 document.body.appendChild(frame);
61 });
57 } 62 }
58 63
59 function normalizeURL(url) { 64 function normalizeURL(url) {
60 return new URL(url, document.location).toString().replace(/#.*$/, ''); 65 return new URL(url, document.location).toString().replace(/#.*$/, '');
61 } 66 }
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/waiting.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698