Index: LayoutTests/http/tests/serviceworker/skip-waiting.html |
diff --git a/LayoutTests/http/tests/serviceworker/skip-waiting.html b/LayoutTests/http/tests/serviceworker/skip-waiting.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..28ef667aa3e274bac03982fdad3ba49bc33ee66b |
--- /dev/null |
+++ b/LayoutTests/http/tests/serviceworker/skip-waiting.html |
@@ -0,0 +1,56 @@ |
+<!DOCTYPE html> |
+<title>Service Worker: Skip waiting</title> |
+<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 scope = 'resources/blank.html'; |
+ var url1 = 'resources/empty.js'; |
+ var url2 = 'resources/skip-waiting-worker.js'; |
+ var frame, frame_sw, oncontrollerchanged; |
+ var controllerchanged = new Promise(function(resolve) { |
falken
2014/12/04 06:15:38
nit: pick either controllerchanged or saw_controll
xiang
2014/12/11 11:24:32
Done.
|
+ oncontrollerchanged = function(e) { |
+ assert_equals(e.type, 'controllerchange', |
+ 'Event name should be "controllerchange"'); |
+ assert_true( |
+ e.target instanceof frame.contentWindow.ServiceWorkerContainer, |
+ 'Event target should be a ServiceWorkerContainer'); |
+ assert_equals(e.target.controller.state, 'activating', |
+ 'Controller state should be activating'); |
+ assert_equals( |
+ frame_sw.controller.scriptURL, normalizeURL(url2), |
+ 'Controller scriptURL should change to the second one'); |
+ resolve(); |
+ }; |
+ }); |
falken
2014/12/04 06:15:38
this needs +2 indent
xiang
2014/12/11 11:24:32
Done.
|
+ return service_worker_unregister_and_register(t, url1, scope) |
+ .then(function(registration) { |
+ return wait_for_update(t, registration); }) |
+ .then(function(sw) { |
+ return wait_for_state(t, sw, 'activated'); |
falken
2014/12/11 05:01:51
Lines 30-32 should be collapsed into simply: retur
xiang
2014/12/11 11:24:32
Done.
|
+ }) |
+ .then(function() { |
+ return with_iframe(scope); |
+ }) |
+ .then(function(f) { |
+ frame = f; |
+ frame_sw = f.contentWindow.navigator.serviceWorker; |
+ assert_equals( |
+ frame_sw.controller.scriptURL, normalizeURL(url1), |
+ 'Document controller scriptURL should equal to the first one'); |
+ frame_sw.oncontrollerchange = t.step_func(oncontrollerchanged); |
+ return navigator.serviceWorker.register(url2, {scope: scope}); |
+ }) |
+ .then(function(registration) { |
+ return Promise.all([controllerchanged, |
+ fetch_tests_from_worker(registration.installing)]); |
+ }) |
+ .then(function() { |
+ frame.remove(); |
+ return service_worker_unregister_and_done(t, scope); |
+ }) |
+ }, 'Test skipWaiting while a client is using the registration'); |
+ |
+</script> |