Index: LayoutTests/http/tests/serviceworker/fetch-event.html |
diff --git a/LayoutTests/http/tests/serviceworker/fetch-event.html b/LayoutTests/http/tests/serviceworker/fetch-event.html |
index c0d122f924ca757e67e2b37335d93a0b4982624c..5dd637a9e20f77f930f608b4665592d4689a7fd4 100644 |
--- a/LayoutTests/http/tests/serviceworker/fetch-event.html |
+++ b/LayoutTests/http/tests/serviceworker/fetch-event.html |
@@ -16,13 +16,10 @@ async_test(function(t) { |
var scope = 'resources/simple.html?string'; |
service_worker_unregister_and_register(t, worker, scope) |
.then(function(registration) { |
- return wait_for_update(t, registration); |
+ return wait_for_state(t, registration.installing, 'activated'); |
horo
2014/09/03 06:13:48
How about introducing wait_for_activated(t, regist
nhiroki
2014/09/04 06:47:09
I'd prefer to keep it as is because I think the be
horo
2014/09/04 09:07:13
I think there are many tests which just need an ac
nhiroki
2014/09/04 09:20:40
"make '.waiting' for 'activated'?" -> "make '.wait
nhiroki
2014/09/05 07:42:09
Done.
|
}) |
- .then(t.step_func(function(sw) { |
- return wait_for_state(t, sw, 'activated'); |
- })) |
- .then(t.step_func(function() { return with_iframe(scope); })) |
- .then(t.step_func(function(frame) { |
+ .then(function() { return with_iframe(scope); }) |
+ .then(function(frame) { |
assert_equals( |
frame.contentDocument.body.textContent, |
'Test string', |
@@ -35,8 +32,9 @@ async_test(function(t) { |
frame.contentDocument.characterSet, |
'UTF-8', |
'The character set of the response created with a string should be UTF-8'); |
+ unload_iframe(frame); |
return service_worker_unregister_and_done(t, scope); |
- })) |
+ }) |
.catch(unreached_rejection(t)); |
}, 'Service Worker responds to fetch event with string', properties); |
@@ -44,19 +42,17 @@ async_test(function(t) { |
var scope = 'resources/simple.html?blob'; |
service_worker_unregister_and_register(t, worker, scope) |
.then(function(registration) { |
- return wait_for_update(t, registration); |
+ return wait_for_state(t, registration.installing, 'activated'); |
}) |
- .then(t.step_func(function(sw) { |
- return wait_for_state(t, sw, 'activated'); |
- })) |
- .then(t.step_func(function() { return with_iframe(scope); })) |
- .then(t.step_func(function(frame) { |
+ .then(function() { return with_iframe(scope); }) |
+ .then(function(frame) { |
assert_equals( |
frame.contentDocument.body.textContent, |
'Test blob', |
'Service Worker should respond to fetch with a test string'); |
+ unload_iframe(frame); |
return service_worker_unregister_and_done(t, scope); |
- })) |
+ }) |
.catch(unreached_rejection(t)); |
}, 'Service Worker responds to fetch event with blob body', properties); |
@@ -64,19 +60,17 @@ async_test(function(t) { |
var scope = 'resources/simple.html?referrer'; |
service_worker_unregister_and_register(t, worker, scope) |
.then(function(registration) { |
- return wait_for_update(t, registration); |
+ return wait_for_state(t, registration.installing, 'activated'); |
}) |
- .then(t.step_func(function(sw) { |
- return wait_for_state(t, sw, 'activated'); |
- })) |
- .then(t.step_func(function() { return with_iframe(scope); })) |
- .then(t.step_func(function(frame) { |
+ .then(function() { return with_iframe(scope); }) |
+ .then(function(frame) { |
assert_equals( |
frame.contentDocument.body.textContent, |
'Referrer: ' + document.location.href, |
'Service Worker should respond to fetch with the referrer URL'); |
+ unload_iframe(frame); |
return service_worker_unregister_and_done(t, scope); |
- })) |
+ }) |
.catch(unreached_rejection(t)); |
}, 'Service Worker responds to fetch event with the referrer URL', properties); |
@@ -84,18 +78,16 @@ async_test(function(t) { |
var scope = 'resources/simple.html?ignore'; |
service_worker_unregister_and_register(t, worker, scope) |
.then(function(registration) { |
- return wait_for_update(t, registration); |
+ return wait_for_state(t, registration.installing, 'activated'); |
}) |
- .then(t.step_func(function(sw) { |
- return wait_for_state(t, sw, 'activated'); |
- })) |
- .then(t.step_func(function() { return with_iframe(scope); })) |
- .then(t.step_func(function(frame) { |
+ .then(function() { return with_iframe(scope); }) |
+ .then(function(frame) { |
assert_equals(frame.contentDocument.body.textContent, |
'Here\'s a simple html file.\n', |
'Response should come from fallback to native fetch'); |
+ unload_iframe(frame); |
return service_worker_unregister_and_done(t, scope); |
- })) |
+ }) |
.catch(unreached_rejection(t)); |
}, 'Service Worker does not respond to fetch event', properties); |
@@ -103,18 +95,16 @@ async_test(function(t) { |
var scope = 'resources/simple.html?null'; |
service_worker_unregister_and_register(t, worker, scope) |
.then(function(registration) { |
- return wait_for_update(t, registration); |
+ return wait_for_state(t, registration.installing, 'activated'); |
}) |
- .then(t.step_func(function(sw) { |
- return wait_for_state(t, sw, 'activated'); |
- })) |
- .then(t.step_func(function() { return with_iframe(scope); })) |
- .then(t.step_func(function(frame) { |
+ .then(function() { return with_iframe(scope); }) |
+ .then(function(frame) { |
assert_equals(frame.contentDocument.body.textContent, |
'', |
'Response should be the empty string'); |
+ unload_iframe(frame); |
return service_worker_unregister_and_done(t, scope); |
- })) |
+ }) |
.catch(unreached_rejection(t)); |
}, 'Service Worker responds to fetch event with null response body', properties); |
@@ -122,18 +112,16 @@ async_test(function(t) { |
var scope = 'resources/simple.html?reject'; |
service_worker_unregister_and_register(t, worker, scope) |
.then(function(registration) { |
- return wait_for_update(t, registration); |
+ return wait_for_state(t, registration.installing, 'activated'); |
}) |
- .then(t.step_func(function(sw) { |
- return wait_for_state(t, sw, 'activated'); |
- })) |
- .then(t.step_func(function() { return with_iframe(scope); })) |
- .then(t.step_func(function(frame) { |
+ .then(function() { return with_iframe(scope); }) |
+ .then(function(frame) { |
assert_equals(frame.contentDocument.body.textContent, |
'Here\'s a simple html file.\n', |
'Response should come from fallback to native fetch'); |
+ unload_iframe(frame); |
return service_worker_unregister_and_done(t, scope); |
- })) |
+ }) |
.catch(unreached_rejection(t)); |
}, 'Service Worker rejects fetch event', properties); |
@@ -141,18 +129,16 @@ async_test(function(t) { |
var scope = 'resources/simple.html?fetch'; |
service_worker_unregister_and_register(t, worker, scope) |
.then(function(registration) { |
- return wait_for_update(t, registration); |
+ return wait_for_state(t, registration.installing, 'activated'); |
}) |
- .then(t.step_func(function(sw) { |
- return wait_for_state(t, sw, 'activated'); |
- })) |
- .then(t.step_func(function() { return with_iframe(scope); })) |
- .then(t.step_func(function(frame) { |
+ .then(function() { return with_iframe(scope); }) |
+ .then(function(frame) { |
assert_equals(frame.contentDocument.body.textContent, |
'Here\'s an other html file.\n', |
'Response should come from fetched other file'); |
+ unload_iframe(frame); |
return service_worker_unregister_and_done(t, scope); |
- })) |
+ }) |
.catch(unreached_rejection(t)); |
}, 'Service Worker fetches other file in fetch event', properties); |
@@ -160,13 +146,10 @@ async_test(function(t) { |
var scope = 'resources/simple.html?form-post'; |
var frame_name = 'xhr-post-frame'; |
service_worker_unregister_and_register(t, worker, scope) |
- .then(function(registration) { |
- return wait_for_update(t, registration); |
- }) |
- .then(t.step_func(function(sw) { |
- return wait_for_state(t, sw, 'activated'); |
+ .then(t.step_func(function(registration) { |
+ return wait_for_state(t, registration.installing, 'activated'); |
})) |
- .then(t.step_func(function(sw) { |
+ .then(function(sw) { |
return new Promise(function(resolve) { |
var frame = document.createElement('iframe'); |
frame.name = frame_name; |
@@ -192,13 +175,13 @@ async_test(function(t) { |
}; |
form.submit(); |
}); |
- })) |
- .then(t.step_func(function(frame) { |
+ }) |
+ .then(function(frame) { |
assert_equals(frame.contentDocument.body.textContent, |
'POST:testName1=testValue1&testName2=testValue2'); |
document.body.removeChild(frame); |
return service_worker_unregister_and_done(t, scope); |
- })) |
+ }) |
.catch(unreached_rejection(t)); |
}, 'Service Worker responds to fetch event with POST form', properties); |
</script> |