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

Unified Diff: LayoutTests/http/tests/serviceworker/skip-waiting.html

Issue 723923002: ServiceWorker: Add support for .skipWaiting and controllerchange event(1/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: webcallback->skipwaitingcallbacks, test re-write Created 6 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: 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..cdb99150bc77a87e0f7e7b67e3fbb41a0a410898
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/skip-waiting.html
@@ -0,0 +1,48 @@
+<!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 iframeContainer, onControllerChanged, worker;
falken 2014/12/01 02:28:48 nit: variables should be snake_case (same with oth
xiang 2014/12/01 07:13:44 Done.
+ var controllerchanged = new Promise(function(resolve) {
+ onControllerChanged = function() {
+ assert_equals(
+ iframeContainer.controller.scriptURL, normalizeURL(url2),
+ 'Controller scriptURL should change to the second one');
+ resolve();
+ };
+ });
+ 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');
+ })
+ .then(function() {
+ return with_iframe(scope);
falken 2014/12/01 02:28:48 nit: please remove this iframe when done, as per s
xiang 2014/12/01 07:13:44 Done.
+ })
+ .then(function(frame) {
+ iframeContainer = frame.contentWindow.navigator.serviceWorker;
+ assert_equals(
+ iframeContainer.controller.scriptURL, normalizeURL(url1),
+ 'Document controller scriptURL should equal to the first one');
+ iframeContainer.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() {
+ return service_worker_unregister_and_done(t, scope);
+ })
+ }, 'Test skipWaiting while a client is using the registration');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698