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

Side by Side Diff: LayoutTests/http/tests/serviceworker/getregistration.html

Issue 540823003: ServiceWorker: Implement navigator.serviceWorker.getRegistration [3/3] (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
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.js"></script>
5 <script>
6 async_test(function(t) {
7 var documentURL = 'no-such-worker';
8 navigator.serviceWorker.getRegistration(documentURL)
9 .then(function(value) {
10 assert_equals(value, undefined,
11 'getRegistration should resolve with undefined');
12 t.done();
13 })
14 .catch(unreached_rejection(t));
15 }, 'getRegistration');
16
17 async_test(function(t) {
18 var scope = 'scope/worker/';
19 var registration;
20 service_worker_unregister_and_register(t, 'resources/empty-worker.js',
21 scope)
22 .then(function(r) {
23 registration = r;
24 return navigator.serviceWorker.getRegistration(scope);
25 })
26 .then(function(value) {
27 assert_equals(value, registration,
28 'getRegistration should resolve with registration');
29 service_worker_unregister_and_done(t, scope);
30 })
31 .catch(unreached_rejection(t));
32 }, 'Register then getRegistration');
33
34 async_test(function(t) {
35 var documentURL = 'http://example.com/';
36 navigator.serviceWorker.getRegistration(documentURL)
37 .then(function() {
38 assert_unreached(
39 'getRegistration with an out of origin URL should fail');
40 }, function(reason) {
41 assert_equals(
42 reason.name, 'SecurityError',
43 'getRegistration with an out of origin URL should fail');
44 t.done();
45 })
46 .catch(unreached_rejection(t));
47 }, 'getRegistration with a cross origin URL');
48
49 async_test(function(t) {
50 var scope = 'scope/worker/';
51 service_worker_unregister_and_register(t, 'resources/empty-worker.js',
52 scope)
53 .then(function(registration) {
54 return registration.unregister();
55 })
56 .then(function() {
57 return navigator.serviceWorker.getRegistration(scope);
58 })
59 .then(function(value) {
60 assert_equals(value, undefined,
61 'getRegistration should resolve with undefined');
62 t.done();
63 })
64 .catch(unreached_rejection(t));
65 }, 'Register then Unregister then getRegistration');
66
67 </script>
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/url-limits.html ('k') | Source/modules/serviceworkers/ServiceWorkerContainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698