OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <meta charset="utf-8"> | |
3 <title>Service Worker: Registration for iframe</title> | |
4 <script src="../resources/testharness.js"></script> | |
5 <script src="../resources/testharnessreport.js"></script> | |
6 <script src="resources/test-helpers.js"></script> | |
7 <script> | |
8 // Set script url and scope url relative to the calling frame's document's url. | |
9 // Assert the implementation parses the urls against the calling frame's | |
10 // document's url. | |
11 async_test(function(t) { | |
12 var url = 'resources/blank.html'; | |
13 var scope = 'resources/registration-for-iframe-from-calling-frame'; | |
14 var parsed_scope = normalizeURL(scope); | |
15 var script = 'resources/empty-worker.js'; | |
16 var parsed_script = normalizeURL(script); | |
17 var frame; | |
18 var registration; | |
19 | |
20 service_worker_unregister(t, scope) | |
21 .then(function() { return with_iframe(url); }) | |
22 .then(function(f) { | |
23 frame = f; | |
24 return frame.contentWindow.navigator.serviceWorker.register( | |
25 script, | |
26 { scope: scope }); | |
27 }) | |
28 .then(function(r) { | |
29 registration = r; | |
30 return wait_for_state(t, r.installing, 'activated'); | |
31 }) | |
32 .then(function() { | |
33 assert_equals( | |
34 registration.scope, parsed_scope, | |
35 'registration\'s scope must be the scope parsed against calling ' + | |
36 'document\'s url'); | |
37 assert_equals( | |
38 registration.active.scriptURL, parsed_script, | |
39 'worker\'s script must be the url parsed against calling ' + | |
40 'document\'s url'); | |
41 unload_iframe(frame); | |
42 return service_worker_unregister_and_done(t, scope); | |
43 }) | |
44 .catch(unreached_rejection(t)); | |
45 }, 'Subframe\'s container\'s register method should use calling frame\'s ' + | |
46 'document\'s url as a base url for parsing its script url and scope url - ' + | |
falken
2015/02/27 12:30:03
nit: this ' should be lined up with the ' above (a
| |
47 'normal case'); | |
48 | |
49 // Set script url and scope url relative to the iframe's document's url. | |
50 // Assert the implementation throws a NetworkError exception. | |
51 async_test(function(t) { | |
52 var url = 'resources/blank.html'; | |
53 var scope = 'registration-for-iframe-from-calling-frame'; | |
54 var script = 'empty-worker.js'; | |
55 var frame; | |
56 var registration; | |
57 | |
58 service_worker_unregister(t, scope) | |
59 .then(function() { return with_iframe(url); }) | |
60 .then(function(f) { | |
61 frame = f; | |
62 return frame.contentWindow.navigator.serviceWorker.register( | |
63 script, | |
64 { scope: scope }); | |
65 }) | |
66 .then(unreached_rejection(t), | |
falken
2015/02/27 12:30:03
We want to assert the opposite. This should be ass
| |
67 function(e) { | |
falken
2015/02/27 12:30:03
See http/tests/serviceworker/register-default-scop
| |
68 assert_equals(e.name, 'NetworkError'); | |
69 unload_iframe(frame); | |
70 return service_worker_unregister_and_done(t, scope); | |
71 }) | |
72 .catch(unreached_rejection(t)); | |
73 }, 'Subframe\'s container\'s register method should use calling frame\'s ' + | |
74 'document\'s url as a base url for parsing its script url and scope url - ' + | |
75 'error case'); | |
76 | |
77 // Set the scope url to a non-subdirectory of the script url. | |
78 // Assert the implementation throws a SecurityError exception. | |
79 async_test(function(t) { | |
80 var url = 'resources/blank.html'; | |
81 var scope = 'registration-for-iframe-from-calling-frame'; | |
82 var script = 'resources/empty-worker.js'; | |
83 var frame; | |
84 var registration; | |
85 | |
86 service_worker_unregister(t, scope) | |
87 .then(function() { return with_iframe(url); }) | |
88 .then(function(f) { | |
89 frame = f; | |
90 return frame.contentWindow.navigator.serviceWorker.register( | |
91 script, | |
92 { scope: scope }); | |
93 }) | |
94 .then(unreached_rejection(t), | |
falken
2015/02/27 12:30:03
Same here this should be assert_unreached.
| |
95 function(e) { | |
96 assert_equals(e.name, 'SecurityError'); | |
97 unload_iframe(frame); | |
98 return service_worker_unregister_and_done(t, scope); | |
99 }) | |
100 .catch(unreached_rejection(t)); | |
101 }, 'A scope url should start with the given script url'); | |
102 </script> | |
OLD | NEW |