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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/reloading-iframe.html

Issue 1886953003: ServiceWorker: Add a test to check the behavior after reloading iframe Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wrap at 80 columns Created 4 years, 8 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 | third_party/WebKit/LayoutTests/http/tests/serviceworker/unregister-then-register.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/reloading-iframe.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/reloading-iframe.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/reloading-iframe.html
new file mode 100644
index 0000000000000000000000000000000000000000..6befb01ef08158f6b52aca9afcc592491af7923d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium/reloading-iframe.html
@@ -0,0 +1,112 @@
+<!DOCTYPE html>
falken 2016/04/14 18:34:57 I think we should keep this outside of chromium/ b
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../resources/test-helpers.js"></script>
+<script>
+
+promise_test(function(t) {
+ var worker_url1 = './resources/empty-worker.js?1';
+ var worker_url2 = './resources/empty-worker.js?2';
+ var scope = './resources/blank.html?check-activate-process-after-reloading';
+ var frame;
+ var registration;
+ var old_worker;
+ var new_worker;
+ return service_worker_unregister_and_register(t, worker_url1, scope)
+ .then(function(r) {
+ add_completion_callback(function() {
+ service_worker_unregister(t, scope);
falken 2016/04/14 18:34:57 Can this just be r.unregister()?
+ });
+ registration = r;
+ old_worker = r.installing;
+ assert_not_equals(r.installing, null,
+ '.installing should be set just after registration');
falken 2016/04/14 18:34:57 Let's remove this assert. Most of our tests have t
+ return wait_for_state(t, r.installing, 'activated');
+ })
+ .then(function() {
+ return with_iframe(scope);
+ })
+ .then(function(f) {
+ frame = f;
+ var c = frame.contentWindow.navigator.serviceWorker.controller;
+ assert_not_equals(c, null, 'An iframe should be controlled by SW '+
+ 'after registration');
falken 2016/04/14 18:34:57 Let's remove this assert, it should be covered by
+ return navigator.serviceWorker.register(worker_url2, {scope: scope});
+ })
+ .then(function(r) {
+ assert_equals(r, registration,
+ 'registration should be the same for the same scope');
+ new_worker = r.installing;
+ assert_not_equals(r.installing, null,
+ 'install process should be triggered after ' +
+ 'resolving register()');
+ return wait_for_state(t, r.installing, 'installed');
+ })
+ .then(function() {
+ assert_not_equals(registration.waiting, null,
+ 'installing worker should move to waiting worker ' +
+ 'after installed');
+ assert_not_equals(registration.active, null,
+ 'active worker should remain until iframe is ' +
+ 'controlled by this worker');
falken 2016/04/14 18:34:57 Let's make these: assert_equals(registration.waiti
+ return new Promise(function(resolve) {
+ frame.onload = resolve;
+ frame.contentWindow.location.reload();
+ });
+ })
+ .then(function() {
+ assert_equals(registration.waiting, new_worker,
+ 'installing worker should move to waiting worker after ' +
+ 'installed');
+ assert_equals(registration.active, old_worker,
+ 'active worker should remain until iframe is ' +
+ 'controlled by this worker');
falken 2016/04/14 18:34:57 The descriptions should be updated to mention the
+ var c = frame.contentWindow.navigator.serviceWorker.controller;
+ assert_not_equals(c, null, 'An iframe should be controlled by SW ' +
+ 'after re-registration');
falken 2016/04/14 18:34:57 Can this assert be more specific? c.scriptURL == o
+ });
+}, 'Reloading the last controlled iframe after re-registration should not ' +
+ 'invoke Activate process of the registration');
falken 2016/04/14 18:34:57 In spec language, it's called Activate algorithm.
+
+promise_test(function(t) {
+ var worker_url = 'resources/empty-worker.js';
+ var scope = 'resources/blank.html?check-clear-process-after-reloading';
+ var registration;
+ var frame;
+ return service_worker_unregister_and_register(t, worker_url, scope)
+ .then(function(r) {
+ registration = r;
+ return wait_for_state(t, r.installing, 'activated');
+ })
+ .then(function() {
+ return with_iframe(scope);
+ })
+ .then(function(f) {
+ frame = f;
+ return registration.unregister();
+ })
+ .then(function() {
+ return new Promise(function(resolve) {
+ frame.onload = resolve;
+ frame.contentWindow.location.reload();
+ });
+ })
+ .then(function() {
+ // TODO(shimazu): Expected behavior is NOT to invoke "Clear" procedure
+ // after reloading according to comments at
+ // http://crrev.com/1865103003#msg29
+ // Assertions after here should be fixed once the behavior is fixed.
+ var c = frame.contentWindow.navigator.serviceWorker.controller;
+ assert_equals(c, null, 'a page after unregistration should not be ' +
+ 'controlled by the service worker');
+ return navigator.serviceWorker.getRegistration(scope);
+ })
+ .then(function(r) {
+ assert_equals(r, undefined,
+ 'getRegistration should return undefined after ' +
+ 'reloading the controlled iframe following ' +
+ 'unregistration');
+ });
+}, 'Reloading the last controlled iframe after unregistration should ' +
+ 'invoke Clear process of the registration');
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/unregister-then-register.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698