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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/http/tests/serviceworker/serviceworkerobject-id.html
diff --git a/LayoutTests/http/tests/serviceworker/serviceworkerobject-id.html b/LayoutTests/http/tests/serviceworker/serviceworkerobject-id.html
new file mode 100644
index 0000000000000000000000000000000000000000..f3acdfe95aa6fdcc8d3388bac47662f8990f8741
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/serviceworkerobject-id.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<title>Service Worker: ServiceWorker.id</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.js"></script>
+<script>
+var scope = 'resources/blank.html?serviceworker-id';
+var worker_url = 'resources/update-worker.php';
+var registration;
+var uuid1, uuid2;
+
+// A regex object for UUID(http://tools.ietf.org/html/rfc4122) validation.
+var pattern = new RegExp(['^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-',
+ '9a-f]{3}-[0-9a-f]{12}$'].join(''), 'i');
+
+function validate_uuid(id) {
+ return !!id.match(pattern);
+}
+
+promise_test(function(t) {
+ return service_worker_unregister_and_register(t, worker_url, scope)
+ .then(function(r) {
+ registration = r;
+ uuid1 = r.installing.id;
+ assert_true(validate_uuid(uuid1));
+ return wait_for_state(t, r.installing, 'activated');
+ })
+ .then(function() {
+ assert_equals(
+ registration.active.id,
+ uuid1,
+ 'installing should still have the same UUID when activated.');
+
+ // A new worker should be found.
+ registration.update();
+ return wait_for_update(t, registration);
+ })
+ .then(function(new_installing) {
+ uuid2 = new_installing.id;
+ assert_true(validate_uuid(uuid2));
+ return wait_for_state(t, new_installing, 'activated');
+ })
+ .then(function() {
+ assert_equals(
+ registration.active.id,
+ uuid2,
+ 'new installing should still have the same UUID when activated.');
+ assert_not_equals(
+ uuid1,
+ uuid2,
+ 'A service worker should obtain a new UUID after update.');
+ return service_worker_unregister_and_done(t, scope);
+ });
+ }, 'ServiceWorker.id returns the service worker\'s UUID.');
+</script>
« 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