2 <title>Service Worker: Registration
</title>
3 <script src=
"../resources/testharness.js"></script>
4 <script src=
"../resources/testharnessreport.js"></script>
5 <script src=
"resources/test-helpers.js"></script>
7 function fetch_url(url
) {
8 return new Promise(function(resolve
, reject
) {
9 var request
= new XMLHttpRequest();
10 request
.addEventListener('load', function(event
) {
11 if (request
.status
== 200)
12 resolve(request
.response
);
14 reject(Error(request
.statusText
));
16 request
.open('GET', url
);
20 var worker
= 'resources/fail-on-fetch-worker.js';
22 async_test(function(t
) {
23 var scope
= 'resources/scope/uncontrolled-page/';
24 service_worker_unregister_and_register(t
, worker
, scope
)
26 return wait_for_state(t
, reg
.installing
, 'activated');
29 return fetch_url('/serviceworker/resources/simple.txt');
31 .then(function(text
) {
32 assert_equals(text
, 'a simple text file\n');
33 service_worker_unregister_and_done(t
, scope
);
35 .catch(t
.step_func(function(reason
) {
36 assert_unreached(reason
.message
);
38 }, 'Fetch events should not go through uncontrolled page.');