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>
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
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
);
20 service_worker_unregister(t
, scope
)
21 .then(function() { return with_iframe(url
); })
24 return frame
.contentWindow
.navigator
.serviceWorker
.register(
30 return wait_for_state(t
, r
.installing
, 'activated');
34 registration
.scope
, parsed_scope
,
35 'registration\'s scope must be the scope parsed against calling ' +
38 registration
.active
.scriptURL
, parsed_script
,
39 'worker\'s script must be the url parsed against calling ' +
42 return service_worker_unregister_and_done(t
, scope
);
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 ' +
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';
58 service_worker_unregister(t
, scope
)
59 .then(function() { return with_iframe(url
); })
62 return frame
.contentWindow
.navigator
.serviceWorker
.register(
68 assert_unreached('register() should reject');
71 assert_equals(e
.name
, 'NetworkError');
73 return service_worker_unregister_and_done(t
, scope
);
75 .catch(unreached_rejection(t
));
76 }, 'Subframe\'s container\'s register method should use calling frame\'s ' +
77 'document\'s url as a base url for parsing its script url and scope url ' +
80 // Set the scope url to a non-subdirectory of the script url.
81 // Assert the implementation throws a SecurityError exception.
82 async_test(function(t
) {
83 var url
= 'resources/blank.html';
84 var scope
= 'registration-for-iframe-from-calling-frame';
85 var script
= 'resources/empty-worker.js';
89 service_worker_unregister(t
, scope
)
90 .then(function() { return with_iframe(url
); })
93 return frame
.contentWindow
.navigator
.serviceWorker
.register(
99 assert_unreached('register() should reject');
102 assert_equals(e
.name
, 'SecurityError');
104 return service_worker_unregister_and_done(t
, scope
);
106 .catch(unreached_rejection(t
));
107 }, 'A scope url should start with the given script url');