Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-event.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-event.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-event.html |
index 8b9cb40ceaca384bbeb2211249544c4dfd018703..a27c2b9490fdff21e50bdaec2743070d49166626 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-event.html |
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-event.html |
@@ -69,6 +69,47 @@ async_test(function(t) { |
}, 'Service Worker responds to fetch event with the referrer URL'); |
async_test(function(t) { |
+ var scope = 'resources/simple.html?clientId'; |
+ var frame; |
+ var client_id1, client_id2; |
+ service_worker_unregister_and_register(t, worker, scope) |
+ .then(function(reg) { |
+ return wait_for_state(t, reg.installing, 'activated'); |
+ }) |
+ .then(function() { return with_iframe(scope); }) |
+ .then(function(f) { |
+ frame = f; |
+ assert_equals( |
+ frame.contentDocument.body.textContent.substr(0, 19), |
+ 'Client ID Not Found', |
+ 'Service Worker should respond to navigation fetch with no ' + |
+ 'client id'); |
+ return frame.contentWindow.fetch('resources/other.html?clientId'); |
+ }) |
+ .then(function(response) { return response.text(); }) |
+ .then(function(response_text) { |
+ client_id1 = response_text.substr(17, 36); |
+ assert_equals( |
+ response_text.substr(0, 15), |
+ 'Client ID Found', |
+ 'Service Worker should respond to fetch with a client id'); |
+ return frame.contentWindow.fetch('resources/other.html?clientId'); |
+ }) |
+ .then(function(response) { return response.text(); }) |
+ .then(function(response_text) { |
+ client_id2 = response_text.substr(17, 36); |
+ assert_equals( |
+ client_id1, |
+ client_id2, |
+ 'Service Worker should respond to another fetch from the same ' + |
+ 'client with the same client id'); |
+ frame.remove(); |
+ return service_worker_unregister_and_done(t, scope); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Service Worker responds to fetch event with a client id'); |
+ |
+async_test(function(t) { |
var scope = 'resources/simple.html?ignore'; |
service_worker_unregister_and_register(t, worker, scope) |
.then(function(reg) { |
@@ -155,8 +196,9 @@ async_test(function(t) { |
}) |
.then(function(frame) { |
assert_equals(frame.contentDocument.body.textContent, |
- 'POST:testName1=testValue1&testName2=testValue2'); |
- document.body.removeChild(frame); |
+ 'POST:application/x-www-form-urlencoded:' + |
+ 'testName1=testValue1&testName2=testValue2'); |
+ frame.remove(); |
return service_worker_unregister_and_done(t, scope); |
}) |
.catch(unreached_rejection(t)); |
@@ -172,15 +214,7 @@ async_test(function(t) { |
.then(function(frame) { |
assert_equals( |
frame.contentDocument.body.textContent, |
- '(0)', |
- 'Response should be the argument of the first respondWith() call.'); |
- frame.remove(); |
- return with_iframe(scope); |
- }) |
- .then(function(frame) { |
- assert_equals( |
- frame.contentDocument.body.textContent, |
- '(0)(1)[InvalidStateError](2)[InvalidStateError](0)', |
+ '(0)(1)[InvalidStateError](2)[InvalidStateError]', |
'Multiple calls of respondWith must throw InvalidStateErrors.'); |
frame.remove(); |
return service_worker_unregister_and_done(t, scope); |
@@ -190,6 +224,7 @@ async_test(function(t) { |
async_test(function(t) { |
var scope = 'resources/simple.html?used-check'; |
+ var first_frame; |
service_worker_unregister_and_register(t, worker, scope) |
.then(function(reg) { |
return wait_for_state(t, reg.installing, 'activated'); |
@@ -199,7 +234,7 @@ async_test(function(t) { |
assert_equals(frame.contentDocument.body.textContent, |
'Here\'s an other html file.\n', |
'Response should come from fetched other file'); |
- frame.remove(); |
+ first_frame = frame; |
return with_iframe(scope); |
}) |
.then(function(frame) { |
@@ -211,6 +246,7 @@ async_test(function(t) { |
frame.contentDocument.body.textContent, |
'bodyUsed: true', |
'event.respondWith must set the used flag.'); |
+ first_frame.remove(); |
frame.remove(); |
return service_worker_unregister_and_done(t, scope); |
}) |