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 step = t.step_func.bind(t); | |
13 var url = 'resources/blank.html'; | |
14 var scope = 'resources/registration-for-iframe-from-calling-frame'; | |
15 var parsed_scope = normalizeURL(scope); | |
16 var script = 'resources/empty-worker.js'; | |
17 var parsed_script = normalizeURL(script); | |
18 var frame; | |
19 var registration; | |
20 | |
21 service_worker_unregister(t, scope) | |
22 .then(step(function() { return with_iframe(url); })) | |
23 .then(step(function(f) { | |
24 frame = f; | |
25 return frame.contentWindow.navigator.serviceWorker.register( | |
26 script, | |
27 { scope: scope }); | |
28 })) | |
29 .then(step(function(r) { | |
30 registration = r; | |
31 return wait_for_state(t, r.installing, 'activated'); | |
32 })) | |
33 .then(step(function() { | |
34 assert_equals( | |
35 registration.scope, parsed_scope, | |
36 'registration\'s scope must be the scope parsed against calling ' + | |
37 'document\'s url'); | |
38 assert_equals( | |
39 registration.active.scriptURL, parsed_script, | |
40 'worker\'s script must be the url parsed against calling ' + | |
41 'document\'s url'); | |
42 unload_iframe(frame); | |
43 return service_worker_unregister_and_done(t, scope); | |
44 })) | |
45 .catch(unreached_rejection(t)); | |
46 }, 'Subframe\'s container\'s register method should use calling frame\'s ' + | |
47 'document\'s url as a base url for parsing its script url and scope url - ' + | |
48 'normal case'); | |
49 | |
50 // Set script url and scope url relative to the iframe's document's url | |
51 // Assert the implementation throws a NetworkError exception | |
52 async_test(function(t) { | |
53 var step = t.step_func.bind(t); | |
54 var url = 'resources/blank.html'; | |
55 var scope = 'registration-for-iframe-from-calling-frame'; | |
56 var script = 'empty-worker.js'; | |
57 var frame; | |
58 var registration; | |
59 | |
60 service_worker_unregister(t, scope) | |
61 .then(step(function() { return with_iframe(url); })) | |
62 .then(step(function(f) { | |
63 frame = f; | |
64 return frame.contentWindow.navigator.serviceWorker.register( | |
65 script, | |
66 { scope: scope }); | |
67 })) | |
68 .catch(step(function(e) { | |
69 assert_equals(e.name, 'NetworkError'); | |
70 unload_iframe(frame); | |
71 return service_worker_unregister_and_done(t, scope); | |
72 })) | |
73 .catch(unreached_rejection(t)); | |
74 }, 'Subframe\'s container\'s register method should use calling frame\'s ' + | |
75 'document\'s url as a base url for parsing its script url and scope url - ' + | |
76 'error case'); | |
77 | |
78 // Set scope url such that it does not start with script url | |
dominicc (has gone to gerrit)
2015/02/09 07:31:48
This seems imprecise; the scope URL has to be a pr
jungkees
2015/02/13 08:12:37
It seems the script URL (up to the last slash) bei
dominicc (has gone to gerrit)
2015/02/16 06:54:45
No, but read the comment. It says:
"Set scope url
jungkees
2015/02/16 09:06:10
How about "Set the scope URL to a non-subdirectory
| |
79 // Assert the implementation throws a SecurityError exception | |
80 async_test(function(t) { | |
81 var step = t.step_func.bind(t); | |
82 var url = 'resources/blank.html'; | |
83 var scope = 'registration-for-iframe-from-calling-frame'; | |
84 var parsed_scope = normalizeURL(scope); | |
85 var script = 'resources/empty-worker.js'; | |
86 var parsed_script = normalizeURL(script); | |
87 var frame; | |
88 var registration; | |
89 | |
90 service_worker_unregister(t, scope) | |
91 .then(step(function() { return with_iframe(url); })) | |
92 .then(step(function(f) { | |
93 frame = f; | |
94 return frame.contentWindow.navigator.serviceWorker.register( | |
95 script, | |
96 { scope: scope }); | |
97 })) | |
98 .catch(step(function(e) { | |
99 assert_equals(e.name, 'SecurityError'); | |
100 unload_iframe(frame); | |
101 return service_worker_unregister_and_done(t, scope); | |
102 })) | |
103 .catch(unreached_rejection(t)); | |
104 }, 'A scope url should start with the given script url'); | |
105 </script> | |
OLD | NEW |