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

Unified Diff: LayoutTests/http/tests/serviceworker/postmessage-to-client.html

Issue 466723002: ServiceWorker: Enable ServiceWorkerRegistration and update layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@updatefound
Patch Set: rebase Created 6 years, 4 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
Index: LayoutTests/http/tests/serviceworker/postmessage-to-client.html
diff --git a/LayoutTests/http/tests/serviceworker/postmessage-to-client.html b/LayoutTests/http/tests/serviceworker/postmessage-to-client.html
index 19639f889abcec79e02bff092e639648ba5155c8..2f55dcc6cff86c85983b79d6e672ee94b1f6f33f 100644
--- a/LayoutTests/http/tests/serviceworker/postmessage-to-client.html
+++ b/LayoutTests/http/tests/serviceworker/postmessage-to-client.html
@@ -8,34 +8,33 @@ var t = async_test('postMessage from ServiceWorker to ServiceWorkerClient');
t.step(function() {
var scope = 'resources/blank.html'
service_worker_unregister_and_register(
- t, 'resources/postmessage-to-client-worker.js', scope).then(t.step_func(onRegister));
-
- function onRegister(worker) {
- worker.addEventListener('statechange', t.step_func(function(event) {
- if (event.target.state == 'activated')
- onActive();
- }));
- }
-
- function onActive() {
- with_iframe(scope, t.step_func(function(frame) {
- var w = frame.contentWindow;
- w.onmessage = t.step_func(onMessage);
- w.navigator.serviceWorker.controller.postMessage('ping');
- }));
- }
+ t, 'resources/postmessage-to-client-worker.js', 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); })
+ .then(function(frame) {
+ var w = frame.contentWindow;
+ w.onmessage = t.step_func(onMessage);
+ w.navigator.serviceWorker.controller.postMessage('ping');
+ })
+ .catch(unreached_rejection(t));
var result = [];
var expected = ['Sending message via clients'];
function onMessage(e) {
- var message = e.data;
- if (message === 'quit') {
- assert_array_equals(result, expected, 'Worker should post back expected messages.');
- service_worker_unregister_and_done(t, scope);
- } else {
- result.push(message);
- }
+ var message = e.data;
+ if (message === 'quit') {
+ assert_array_equals(result, expected,
+ 'Worker should post back expected messages.');
+ service_worker_unregister_and_done(t, scope);
+ } else {
+ result.push(message);
+ }
}
-});
+ });
</script>

Powered by Google App Engine
This is Rietveld 408576698