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

Unified Diff: LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-worker.js

Issue 514113003: [ServiceWorker] Create a new Blob when body.asBody() is called if the size of body is not set. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/local/serviceworker/resources/fetch-request-body-file-worker.js
diff --git a/LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-worker.js b/LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-worker.js
index 83d7445dc815185fbabcdc0e35c45e84dafaa7d5..f2c027d32c2b447dd7252cb4837f85fbd382a124 100644
--- a/LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-worker.js
+++ b/LayoutTests/http/tests/local/serviceworker/resources/fetch-request-body-file-worker.js
@@ -4,13 +4,26 @@ self.addEventListener('fetch', function(event) {
event.request.headers.forEach(function(value, key) {
headers.push([key, value]);
});
- event.request.body.asText()
- .then(function(result) {
- resolve(new Response(JSON.stringify({
- method: event.request.method,
- headers: headers,
- body: result
- })));
- })
+ if (event.request.url.indexOf('asText') != -1) {
+ event.request.body.asText()
+ .then(function(result) {
+ resolve(new Response(JSON.stringify({
+ method: event.request.method,
+ headers: headers,
+ body: result
+ })));
+ })
+ } else if (event.request.url.indexOf('asBlob') != -1) {
+ event.request.body.asBlob()
+ .then(function(result) {
+ resolve(new Response(JSON.stringify({
+ method: event.request.method,
+ headers: headers,
+ body_size: result.size
+ })));
+ })
+ } else {
+ resolve(new Response('url error:' + event.request.url));
+ }
}));
});

Powered by Google App Engine
This is Rietveld 408576698