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

Unified Diff: LayoutTests/http/tests/serviceworker/resources/fetch-access-control-worker.js

Issue 555443002: [Fetch API] Put body members directly on Response/Request (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated yhirano's comment Created 6 years, 3 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/resources/fetch-access-control-worker.js
diff --git a/LayoutTests/http/tests/serviceworker/resources/fetch-access-control-worker.js b/LayoutTests/http/tests/serviceworker/resources/fetch-access-control-worker.js
index 1cfb4c4274d203f86816ff966d233c687d5fc964..56b8b8a1fe16ca3575225b32066a5110f48d35de 100644
--- a/LayoutTests/http/tests/serviceworker/resources/fetch-access-control-worker.js
+++ b/LayoutTests/http/tests/serviceworker/resources/fetch-access-control-worker.js
@@ -75,15 +75,28 @@ self.addEventListener('fetch', function(event) {
} else if (!params['noChange']) {
request = new Request(request, init);
}
+ var response;
fetch(request)
.then(function(res) {
- // Send the result to fetch-access-control.html.
- port.postMessage({fetchResult: 'resolved',
- hasBody: !!res.body,
- headers: headersToArray(res.headers),
- type: res.type,
- originalURL: originalURL});
- resolve(res);
+ response = res;
+ res.text()
+ .then(function(body) {
+ // Send the result to fetch-access-control.html.
+ port.postMessage(
+ {
+ fetchResult: 'resolved',
+ body: body,
+ headers: headersToArray(response.headers),
+ type: response.type,
+ originalURL: originalURL
+ });
+ resolve(response);
+ })
+ .catch(function(e) {
+ // Send the result to fetch-access-control.html.
+ port.postMessage({fetchResult: 'error'});
+ reject();
+ });
})
.catch(function(e) {
// Send the result to fetch-access-control.html.

Powered by Google App Engine
This is Rietveld 408576698