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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/local/blob/resources/hybrid-blob-util.js

Issue 2147633002: Remove nonstandard 'endings' option for Blob/File constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 3 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 unified diff | Download patch
OLDNEW
1 var HybridBlobTestUtil = function(testFunc, opt_filePaths) { 1 var HybridBlobTestUtil = function(testFunc, opt_filePaths) {
2 this.testCallbackFunc = testFunc; 2 this.testCallbackFunc = testFunc;
3 3
4 this.testFilePaths = opt_filePaths; 4 this.testFilePaths = opt_filePaths;
5 this.testFiles = []; 5 this.testFiles = [];
6 this.testFileMap = {}; 6 this.testFileMap = {};
7 this.fileInput = null; 7 this.fileInput = null;
8 8
9 this.dragBaseDir = ""; 9 this.dragBaseDir = "";
10 this.urlPathBaseDir = ""; 10 this.urlPathBaseDir = "";
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 this.DataItem = function(data) 95 this.DataItem = function(data)
96 { 96 {
97 var item = new Object(); 97 var item = new Object();
98 item.type = 'data'; 98 item.type = 'data';
99 item.value = data; 99 item.value = data;
100 return item; 100 return item;
101 } 101 }
102 102
103 this.createItemParamArray = function(items, itemParams, opt_ending) 103 this.createItemParamArray = function(items, itemParams)
104 { 104 {
105 for (var i = 0; i < items.length; i++) { 105 for (var i = 0; i < items.length; i++) {
106 if (items[i] instanceof Array) 106 if (items[i] instanceof Array)
107 this.createItemParamArray(items[i], itemParams, opt_ending); 107 this.createItemParamArray(items[i], itemParams);
108 else if (items[i].type == "data") { 108 else if (items[i].type == "data") {
109 var data = items[i].value; 109 itemParams.push("data:" + escape(items[i].value));
110 if (opt_ending)
111 data = data.replace(/\r\n/g, "[NL]").replace(/[\n\r]/g, "[NL ]");
112 itemParams.push("data:" + escape(data));
113 } else if (items[i].type == "file") 110 } else if (items[i].type == "file")
114 itemParams.push("file:" + this.urlPathBaseDir + items[i].path); 111 itemParams.push("file:" + this.urlPathBaseDir + items[i].path);
115 } 112 }
116 }; 113 };
117 114
118 this.createUrlParameter = function(items, opt_range, opt_ending) 115 this.createUrlParameter = function(items, opt_range)
119 { 116 {
120 var itemParams = []; 117 var itemParams = [];
121 this.createItemParamArray(items, itemParams, opt_ending); 118 this.createItemParamArray(items, itemParams);
122 var urlParameter = "items=" + itemParams.join(","); 119 var urlParameter = "items=" + itemParams.join(",");
123 if (opt_range) { 120 if (opt_range) {
124 urlParameter += "&start=" + opt_range.start; 121 urlParameter += "&start=" + opt_range.start;
125 urlParameter += "&length=" + opt_range.length; 122 urlParameter += "&length=" + opt_range.length;
126 } 123 }
127 if (opt_ending)
128 urlParameter += "&convert_newlines=1";
129 return urlParameter; 124 return urlParameter;
130 }; 125 };
131 126
132 this.appendAndCreateBlob = function(items, opt_ending, opt_type) 127 this.appendAndCreateBlob = function(items, opt_type)
133 { 128 {
134 var builder = []; 129 var builder = [];
135 for (var i = 0; i < items.length; i++) { 130 for (var i = 0; i < items.length; i++) {
136 if (items[i] instanceof Array) { 131 if (items[i] instanceof Array) {
137 // If it's an array, combine its elements and append as a blob. 132 // If it's an array, combine its elements and append as a blob.
138 builder.push(this.appendAndCreateBlob(items[i], opt_ending, opt_ type)); 133 builder.push(this.appendAndCreateBlob(items[i], opt_type));
139 } else 134 } else
140 builder.push(items[i].value); 135 builder.push(items[i].value);
141 } 136 }
142 var options = {}; 137 var options = {};
143 if (opt_ending)
144 options.endings = opt_ending;
145 if (opt_type) 138 if (opt_type)
146 options.type = opt_type; 139 options.type = opt_type;
147 return new Blob(builder, options); 140 return new Blob(builder, options);
148 }; 141 };
149 }; 142 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698