-
-
Save jugglinmike/00d873922e170016c85508fccbb42607 to your computer and use it in GitHub Desktop.
sw-migration-skip-waiting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git diff --no-index third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/skip-waiting-worker.js third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/skip-waiting-worker.js | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/skip-waiting-worker.js b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/skip-waiting-worker.js | |
index 4b09af5..3fc1d1e 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/skip-waiting-worker.js | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/skip-waiting-worker.js | |
@@ -1,7 +1,7 @@ | |
importScripts('worker-testharness.js'); | |
promise_test(function() { | |
- return self.skipWaiting() | |
+ return skipWaiting() | |
.then(function(result) { | |
assert_equals(result, undefined, | |
'Promise should be resolved with undefined'); | |
$ git diff --no-index third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/skip-waiting-installed-worker.js third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/skip-waiting-installed-worker.js | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/skip-waiting-installed-worker.js b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/skip-waiting-installed-worker.js | |
index 56b97a7..bf582c7 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/skip-waiting-installed-worker.js | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/skip-waiting-installed-worker.js | |
@@ -1,35 +1,24 @@ | |
-// TODO(nhiroki): stop using global states because service workers can be killed | |
-// at any point (http://crbug.com/558244). | |
self.state = 'starting'; | |
self.addEventListener('install', function() { | |
self.state = 'installing'; | |
}); | |
-self.addEventListener('activate', function() { | |
- self.state = 'activating'; | |
- }); | |
- | |
self.addEventListener('message', function(event) { | |
var port = event.data.port; | |
if (self.state !== 'installing') { | |
port.postMessage('FAIL: Worker should be waiting in installed state'); | |
return; | |
} | |
- event.waitUntil(self.skipWaiting() | |
+ self.skipWaiting() | |
.then(function(result) { | |
if (result !== undefined) { | |
port.postMessage('FAIL: Promise should be resolved with undefined'); | |
return; | |
} | |
- if (self.state !== 'activating') { | |
- port.postMessage( | |
- 'FAIL: Promise should be resolved after worker activated'); | |
- return; | |
- } | |
port.postMessage('PASS'); | |
}) | |
.catch(function(e) { | |
port.postMessage('FAIL: unexpected exception: ' + e); | |
- })); | |
+ }); | |
}); | |
$ git diff --no-index third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-installed.html third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-installed.https.html | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-installed.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-installed.https.html | |
index e7b1a19..795386f 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-installed.html | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-installed.https.html | |
@@ -1,21 +1,25 @@ | |
<!DOCTYPE html> | |
<title>Service Worker: Skip waiting installed worker</title> | |
-<script src="../resources/testharness.js"></script> | |
-<script src="../resources/testharnessreport.js"></script> | |
-<script src="resources/test-helpers.js"></script> | |
+<script src="/resources/testharness.js"></script> | |
+<script src="resources/testharness-helpers.js"></script> | |
+<script src="/resources/testharnessreport.js"></script> | |
+<script src="resources/test-helpers.sub.js"></script> | |
<script> | |
promise_test(function(t) { | |
- var scope = 'resources/blank.html'; | |
+ var scope = 'resources/blank.html?skip-waiting-installed'; | |
var url1 = 'resources/empty.js'; | |
var url2 = 'resources/skip-waiting-installed-worker.js'; | |
- var frame, frame_sw, service_worker, onmessage, oncontrollerchanged; | |
+ var frame, frame_sw, service_worker, registration, onmessage, oncontrollerchanged; | |
var saw_message = new Promise(function(resolve) { | |
onmessage = function(e) { | |
var message = e.data; | |
assert_equals( | |
message, 'PASS', | |
- 'skipWaiting promise should be resolved after activated'); | |
+ 'skipWaiting promise should be resolved with undefined'); | |
+ | |
+ assert_equals(registration.active.scriptURL, normalizeURL(url2), | |
+ "skipWaiting should make worker become active"); | |
resolve(); | |
}; | |
}); | |
@@ -28,8 +32,8 @@ promise_test(function(t) { | |
}; | |
}); | |
return service_worker_unregister_and_register(t, url1, scope) | |
- .then(function(registration) { | |
- return wait_for_state(t, registration.installing, 'activated'); | |
+ .then(function(r) { | |
+ return wait_for_state(t, r.installing, 'activated'); | |
}) | |
.then(function() { | |
return with_iframe(scope); | |
@@ -43,8 +47,9 @@ promise_test(function(t) { | |
frame_sw.oncontrollerchange = t.step_func(oncontrollerchanged); | |
return navigator.serviceWorker.register(url2, {scope: scope}); | |
}) | |
- .then(function(registration) { | |
- service_worker = registration.installing; | |
+ .then(function(r) { | |
+ registration = r; | |
+ service_worker = r.installing; | |
return wait_for_state(t, service_worker, 'installed'); | |
}) | |
.then(function() { | |
$ git diff --no-index third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-using-registration.html third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-using-registration.https.html | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-using-registration.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-using-registration.https.html | |
index 5056ee7..68deae7 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-using-registration.html | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-using-registration.https.html | |
@@ -1,12 +1,13 @@ | |
<!DOCTYPE html> | |
<title>Service Worker: Skip waiting using registration</title> | |
-<script src="../resources/testharness.js"></script> | |
-<script src="../resources/testharnessreport.js"></script> | |
-<script src="resources/test-helpers.js"></script> | |
+<script src="/resources/testharness.js"></script> | |
+<script src="resources/testharness-helpers.js"></script> | |
+<script src="/resources/testharnessreport.js"></script> | |
+<script src="resources/test-helpers.sub.js"></script> | |
<script> | |
promise_test(function(t) { | |
- var scope = 'resources/blank.html'; | |
+ var scope = 'resources/blank.html?skip-waiting-using-registration'; | |
var url1 = 'resources/empty.js'; | |
var url2 = 'resources/skip-waiting-worker.js'; | |
var frame, frame_sw, sw_registration, oncontrollerchanged; | |
@@ -44,12 +45,12 @@ promise_test(function(t) { | |
.then(function(registration) { | |
sw_registration = registration; | |
add_completion_callback(function() { | |
+ frame.remove(); | |
registration.unregister(); | |
}); | |
return saw_controllerchanged; | |
}) | |
.then(function() { | |
- frame.remove(); | |
assert_not_equals(sw_registration.active, null, | |
'Registration active worker should not be null'); | |
fetch_tests_from_worker(sw_registration.active); | |
$ git diff --no-index third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-without-client.html third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-without-client.https.html | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-without-client.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-without-client.https.html | |
index 44d357c..38fca17 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-without-client.html | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-without-client.https.html | |
@@ -1,8 +1,9 @@ | |
<!DOCTYPE html> | |
<title>Service Worker: Skip waiting without client</title> | |
-<script src="../resources/testharness.js"></script> | |
-<script src="../resources/testharnessreport.js"></script> | |
-<script src="resources/test-helpers.js"></script> | |
+<script src="/resources/testharness.js"></script> | |
+<script src="resources/testharness-helpers.js"></script> | |
+<script src="/resources/testharnessreport.js"></script> | |
+<script src="resources/test-helpers.sub.js"></script> | |
<script> | |
service_worker_test( | |
$ git diff --no-index third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-without-using-registration.html third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-without-using-registration.https.html | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-without-using-registration.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-without-using-registration.https.html | |
index c3902ae..5ae9cdb 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting-without-using-registration.html | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting-without-using-registration.https.html | |
@@ -1,12 +1,13 @@ | |
<!DOCTYPE html> | |
<title>Service Worker: Skip waiting without using registration</title> | |
-<script src="../resources/testharness.js"></script> | |
-<script src="../resources/testharnessreport.js"></script> | |
-<script src="resources/test-helpers.js"></script> | |
+<script src="/resources/testharness.js"></script> | |
+<script src="resources/testharness-helpers.js"></script> | |
+<script src="/resources/testharnessreport.js"></script> | |
+<script src="resources/test-helpers.sub.js"></script> | |
<script> | |
promise_test(function(t) { | |
- var scope = 'resources/blank.html'; | |
+ var scope = 'resources/blank.html?skip-waiting-without-using-registration'; | |
var url = 'resources/skip-waiting-worker.js'; | |
var frame, frame_sw, sw_registration; | |
@@ -24,6 +25,7 @@ promise_test(function(t) { | |
.then(function(registration) { | |
sw_registration = registration; | |
add_completion_callback(function() { | |
+ frame.remove(); | |
registration.unregister(); | |
}); | |
return wait_for_state(t, registration.installing, 'activated'); | |
@@ -34,7 +36,6 @@ promise_test(function(t) { | |
assert_not_equals(sw_registration.active, null, | |
'Registration active worker should not be null'); | |
fetch_tests_from_worker(sw_registration.active); | |
- frame.remove(); | |
}); | |
}, 'Test skipWaiting while a client is not being controlled'); | |
$ git diff --no-index third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting.html third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting.https.html | |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting.https.html | |
index 04e2bec..ac6c322 100644 | |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/skip-waiting.html | |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/skip-waiting.https.html | |
@@ -1,12 +1,13 @@ | |
<!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 src="/resources/testharness.js"></script> | |
+<script src="resources/testharness-helpers.js"></script> | |
+<script src="/resources/testharnessreport.js"></script> | |
+<script src="resources/test-helpers.sub.js"></script> | |
<script> | |
promise_test(function(t) { | |
- var scope = 'resources/blank.html'; | |
+ var scope = 'resources/blank.html?skip-waiting'; | |
var url1 = 'resources/empty.js'; | |
var url2 = 'resources/empty-worker.js'; | |
var url3 = 'resources/skip-waiting-worker.js'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment