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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-event.html

Issue 1435633002: Service Worker: Add FetchEvent.clientId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address the spec resolution: return null for navigation request Created 4 years, 11 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: 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..5f316488ad54b82438afdffc1098f64d42218b43 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,35 @@ 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;
+ 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 null');
falken 2016/01/13 09:06:53 "no client id"
jungkees 2016/01/13 10:55:18 Done.
+ return frame.contentWindow.fetch('resources/other.html?clientId');
+ })
+ .then(function(response) { return response.text(); })
+ .then(function(response_text) {
+ var client_id = response_text.substr(15);
+ assert_equals(
+ response_text.substr(0, 15),
+ 'Client ID Found',
+ 'Service Worker should respond to fetch with an existing client id');
falken 2016/01/13 09:06:53 "with a client id" Then we should do another fetc
jungkees 2016/01/13 10:55:18 Done.
+ frame.remove();
+ return service_worker_unregister_and_done(t, scope);
+ })
+ .catch(unreached_rejection(t));
+ }, 'Service Worker responds to fetch event with an existing client id');
falken 2016/01/13 09:06:53 "a client id"
jungkees 2016/01/13 10:55:18 Done.
+
+async_test(function(t) {
var scope = 'resources/simple.html?ignore';
service_worker_unregister_and_register(t, worker, scope)
.then(function(reg) {
@@ -155,8 +184,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 +202,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 +212,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 +222,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 +234,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);
})

Powered by Google App Engine
This is Rietveld 408576698