Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / serviceworker / ServiceWorkerGlobalScope / update.html
blob1600e19fd388b2c152a306e02f65d1aebbaed85c
1 <!DOCTYPE html>
2 <title>ServiceWorkerGlobalScope: update</title>
3 <script src='../../resources/testharness.js'></script>
4 <script src='../../resources/testharnessreport.js'></script>
5 <script src='../resources/test-helpers.js'></script>
6 <script>
8 promise_test(function(t) {
9 var script = 'resources/update-worker.php';
10 var scope = 'resources/scope/update';
11 var registration;
12 var frame1;
14 return service_worker_unregister_and_register(t, script, scope)
15 .then(function(r) {
16 registration = r;
17 return wait_for_state(t, registration.installing, 'activated');
19 .then(function() { return with_iframe(scope); })
20 .then(function(f) {
21 frame1 = f;
22 registration.active.postMessage('update');
23 return wait_for_update(t, registration);
25 .then(function() { return with_iframe(scope); })
26 .then(function(frame2) {
27 var expected_events_seen = [
28 'updatefound', // by register().
29 'activate',
30 'fetch',
31 'message',
32 'updatefound', // by update() in the message handler.
33 'fetch',
35 assert_equals(
36 frame2.contentDocument.body.textContent,
37 expected_events_seen.toString(),
38 'events seen by the worker');
39 frame1.remove();
40 frame2.remove();
41 return service_worker_unregister_and_done(t, scope);
42 });
43 }, 'Update a registration on ServiceWorkerGlobalScope');
45 </script>