@@ -1400,17 +1400,16 @@ index 0000000000000000000000000000000000000000..2b1fe7fa712ae210af3ebbccda084041
1400
1400
+
1401
1401
diff --git a/juggler/NetworkObserver.js b/juggler/NetworkObserver.js
1402
1402
new file mode 100644
1403
- index 0000000000000000000000000000000000000000..1a55b5498c18d2403eab21fe9149242f286157d4
1403
+ index 0000000000000000000000000000000000000000..4ed81876c3e176cf07fdeab4ca3fc83874f865a3
1404
1404
--- /dev/null
1405
1405
+++ b/juggler/NetworkObserver.js
1406
- @@ -0,0 +1,794 @@
1406
+ @@ -0,0 +1,833 @@
1407
1407
+ "use strict";
1408
1408
+
1409
1409
+ const {EventEmitter} = ChromeUtils.import('resource://gre/modules/EventEmitter.jsm');
1410
1410
+ const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');
1411
1411
+ const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
1412
1412
+ const {NetUtil} = ChromeUtils.import('resource://gre/modules/NetUtil.jsm');
1413
- + const {CommonUtils} = ChromeUtils.import("resource://services-common/utils.js");
1414
1413
+
1415
1414
+
1416
1415
+ const Cc = Components.classes;
@@ -1978,7 +1977,7 @@ index 0000000000000000000000000000000000000000..1a55b5498c18d2403eab21fe9149242f
1978
1977
+ let result = response.body;
1979
1978
+ if (response.encodings && response.encodings.length) {
1980
1979
+ for (const encoding of response.encodings)
1981
- + result = CommonUtils. convertString(result, encoding, 'uncompressed');
1980
+ + result = convertString(result, encoding, 'uncompressed');
1982
1981
+ }
1983
1982
+ return {base64body: btoa(result)};
1984
1983
+ }
@@ -2171,6 +2170,46 @@ index 0000000000000000000000000000000000000000..1a55b5498c18d2403eab21fe9149242f
2171
2170
+ }
2172
2171
+ }
2173
2172
+
2173
+ + function convertString(s, source, dest) {
2174
+ + const is = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(
2175
+ + Ci.nsIStringInputStream
2176
+ + );
2177
+ + is.setData(s, s.length);
2178
+ + const listener = Cc["@mozilla.org/network/stream-loader;1"].createInstance(
2179
+ + Ci.nsIStreamLoader
2180
+ + );
2181
+ + let result = [];
2182
+ + listener.init({
2183
+ + onStreamComplete: function onStreamComplete(
2184
+ + loader,
2185
+ + context,
2186
+ + status,
2187
+ + length,
2188
+ + data
2189
+ + ) {
2190
+ + const array = Array.from(data);
2191
+ + const kChunk = 100000;
2192
+ + for (let i = 0; i < length; i += kChunk) {
2193
+ + const len = Math.min(kChunk, length - i);
2194
+ + const chunk = String.fromCharCode.apply(this, array.slice(i, i + len));
2195
+ + result.push(chunk);
2196
+ + }
2197
+ + },
2198
+ + });
2199
+ + const converter = Cc["@mozilla.org/streamConverters;1"].getService(
2200
+ + Ci.nsIStreamConverterService
2201
+ + ).asyncConvertData(
2202
+ + source,
2203
+ + dest,
2204
+ + listener,
2205
+ + null
2206
+ + );
2207
+ + converter.onStartRequest(null, null);
2208
+ + converter.onDataAvailable(null, is, 0, s.length);
2209
+ + converter.onStopRequest(null, null, null);
2210
+ + return result.join('');
2211
+ + }
2212
+ +
2174
2213
+ const errorMap = {
2175
2214
+ 'aborted': Cr.NS_ERROR_ABORT,
2176
2215
+ 'accessdenied': Cr.NS_ERROR_PORT_ACCESS_NOT_ALLOWED,
0 commit comments