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

Side by Side Diff: LayoutTests/http/tests/serviceworker/serviceworkerobject-id.html

Issue 1216933008: Service Worker: Migrate to version_uuid and surface ServiceWorker.id. (Layout test 3/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Service Worker: ServiceWorker.id</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>
7 var scope = 'resources/blank.html?serviceworker-id';
8 var worker_url = 'resources/update-worker.php';
9 var registration;
10 var uuid1, uuid2;
11
12 // A regex object for UUID(http://tools.ietf.org/html/rfc4122) validation.
13 var pattern = new RegExp(['^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-',
14 '9a-f]{3}-[0-9a-f]{12}$'].join(''), 'i');
15
16 function validate_uuid(id) {
17 return !!id.match(pattern);
18 }
19
20 promise_test(function(t) {
21 return service_worker_unregister_and_register(t, worker_url, scope)
22 .then(function(r) {
23 registration = r;
24 uuid1 = r.installing.id;
25 assert_true(validate_uuid(uuid1));
26 return wait_for_state(t, r.installing, 'activated');
27 })
28 .then(function() {
29 assert_equals(
30 registration.active.id,
31 uuid1,
32 'installing should still have the same UUID when activated.');
33
34 // A new worker should be found.
35 registration.update();
36 return wait_for_update(t, registration);
37 })
38 .then(function(new_installing) {
39 uuid2 = new_installing.id;
40 assert_true(validate_uuid(uuid2));
41 return wait_for_state(t, new_installing, 'activated');
42 })
43 .then(function() {
44 assert_equals(
45 registration.active.id,
46 uuid2,
47 'new installing should still have the same UUID when activated.');
48 assert_not_equals(
49 uuid1,
50 uuid2,
51 'A service worker should obtain a new UUID after update.');
52 return service_worker_unregister_and_done(t, scope);
53 });
54 }, 'ServiceWorker.id returns the service worker\'s UUID.');
55 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698