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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/registration-attribute.html

Issue 1460653002: ServiceWorker: Fix messed registration attributes on ServiceWorkerGlobalScope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments Created 5 years, 1 month 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
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/registration-attribute.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/registration-attribute.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/registration-attribute.html
index 688fc0cec481a2de6eec56fee555affb2303987a..0932e3258ae267345ec4762f5070d46bca4cc9c1 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/registration-attribute.html
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/ServiceWorkerGlobalScope/registration-attribute.html
@@ -11,6 +11,7 @@ promise_test(function(t) {
return service_worker_unregister_and_register(t, script, scope)
.then(function(registration) {
+ add_completion_callback(function() { registration.unregister(); });
return wait_for_state(t, registration.installing, 'activated');
})
.then(function() { return with_iframe(scope); })
@@ -30,8 +31,71 @@ promise_test(function(t) {
expected_events_seen.toString(),
'Service Worker should respond to fetch');
frame.remove();
- return service_worker_unregister_and_done(t, scope);
});
- }, 'Verify registration attribute on ServiceWorkerGlobalScope');
+ }, 'Verify registration attributes on ServiceWorkerGlobalScope');
+
+promise_test(function(t) {
+ var script = 'resources/registration-attribute-worker.js';
+ var newer_script = 'resources/registration-attribute-newer-worker.js';
+ var scope = 'resources/scope/registration-attribute';
+ var newer_worker;
+
+ return service_worker_unregister_and_register(t, script, scope)
+ .then(function(registration) {
+ add_completion_callback(function() { registration.unregister(); });
+ return wait_for_state(t, registration.installing, 'activated');
+ })
+ .then(function() {
+ return navigator.serviceWorker.register(newer_script, {scope: scope});
+ })
+ .then(function(registration) {
+ newer_worker = registration.installing;
+ return wait_for_state(t, registration.installing, 'activated');
+ })
+ .then(function() {
+ var channel = new MessageChannel;
+ var saw_message = new Promise(function(resolve) {
+ channel.port1.onmessage = function(e) { resolve(e.data); };
+ });
+ newer_worker.postMessage({port: channel.port2}, [channel.port2]);
+ return saw_message;
+ })
+ .then(function(results) {
+ var script_url = normalizeURL(script);
+ var newer_script_url = normalizeURL(newer_script);
+ var expectations = [
+ 'evaluate',
+ ' installing: empty',
+ ' waiting: empty',
+ ' active: ' + script_url,
+ 'updatefound',
+ ' installing: ' + newer_script_url,
+ ' waiting: empty',
+ ' active: ' + script_url,
+ 'install',
+ ' installing: ' + newer_script_url,
+ ' waiting: empty',
+ ' active: ' + script_url,
+ 'statechange(installed)',
+ ' installing: empty',
+ ' waiting: ' + newer_script_url,
+ ' active: ' + script_url,
+ 'statechange(activating)',
+ ' installing: empty',
+ ' waiting: empty',
+ ' active: ' + newer_script_url,
+ 'activate',
+ ' installing: empty',
+ ' waiting: empty',
+ ' active: ' + newer_script_url,
+ 'statechange(activated)',
+ ' installing: empty',
+ ' waiting: empty',
+ ' active: ' + newer_script_url,
+ ];
+ assert_array_equals(results, expectations);
+ });
+ }, 'Verify registration attributes on ServiceWorkerGlobalScope of the ' +
+ 'newer worker');
</script>

Powered by Google App Engine
This is Rietveld 408576698