Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/fetch-waits-for-activate.https.html

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Service Worker: Fetch Event Waits for Activate Event</title>
3 <meta name=timeout content=long>
4 <script src="/resources/testharness.js"></script>
5 <script src="resources/testharness-helpers.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="resources/get-host-info.sub.js"></script>
8 <script src="resources/test-helpers.sub.js"></script>
9 <body>
10 <script>
11
12 var worker = 'resources/fetch-waits-for-activate-worker.js';
13 var expected_url = normalizeURL(worker);
14 var scope = 'resources/fetch-waits-for-activate/';
15
16 async_test(function(t) {
17 var registration;
18 var frameLoadPromise;
19 var frame;
20 service_worker_unregister_and_register(t, worker, scope).then(function(reg) {
21 registration = reg;
22 return wait_for_state(t, reg.installing, 'activating');
23 }).then(function() {
24 assert_equals(registration.active.scriptURL, expected_url,
25 'active worker should be present');
26 assert_equals(registration.active.state, 'activating',
27 'active worker should be in activating state');
28
29 // This should block until we message the worker to tell it to complete
30 // the activate event.
31 frameLoadPromise = with_iframe(scope).then(function(f) {
32 frame = f;
33 });
34
35 // Wait some time to allow frame loading to proceed. It should not,
36 // however, if the fetch event is blocked on the activate. I don't
37 // see any way to force this race without a timeout, unfortunately.
38 return new Promise(function(resolve) {
39 setTimeout(resolve, 1000);
40 });
41 }).then(function() {
42 assert_equals(frame, undefined, 'frame should not be loaded');
43 assert_equals(registration.active.scriptURL, expected_url,
44 'active worker should be present');
45 assert_equals(registration.active.state, 'activating',
46 'active worker should be in activating state');
47
48 // This signals the activate event to complete. The frame should now
49 // load.
50 registration.active.postMessage('GO');
51 return frameLoadPromise;
52 }).then(function() {
53 assert_equals(frame.contentWindow.navigator.serviceWorker.controller.scriptU RL,
54 expected_url, 'frame should now be loaded and controlled');
55 assert_equals(registration.active.state, 'activated',
56 'active worker should be in activated state');
57 frame.remove();
58 return service_worker_unregister_and_done(t, scope);
59 }).catch(unreached_rejection(t));
60 }, 'Fetch events should wait for the activate event to complete.');
61
62 </script>
63 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698