summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/head_channels.js
diff options
context:
space:
mode:
Diffstat (limited to 'netwerk/test/unit/head_channels.js')
-rw-r--r--netwerk/test/unit/head_channels.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/netwerk/test/unit/head_channels.js b/netwerk/test/unit/head_channels.js
index 140135339a..ca16bd2835 100644
--- a/netwerk/test/unit/head_channels.js
+++ b/netwerk/test/unit/head_channels.js
@@ -274,12 +274,10 @@ ChannelEventSink.prototype = {
/**
* A helper class to construct origin attributes.
*/
-function OriginAttributes(inIsolatedMozBrowser, privateId) {
- this.inIsolatedMozBrowser = inIsolatedMozBrowser;
+function OriginAttributes(privateId) {
this.privateBrowsingId = privateId;
}
OriginAttributes.prototype = {
- inIsolatedMozBrowser: false,
privateBrowsingId: 0,
};
@@ -525,3 +523,27 @@ function makeHTTPChannel(url, with_proxy) {
loadUsingSystemPrincipal: true,
}).QueryInterface(Ci.nsIHttpChannel);
}
+
+// Like ChannelListener but does not throw an exception if something
+// goes wrong. Callback is supposed to do all the work.
+class SimpleChannelListener {
+ constructor(callback) {
+ this._onStopCallback = callback;
+ this._buffer = "";
+ }
+ get QueryInterface() {
+ return ChromeUtils.generateQI(["nsIStreamListener", "nsIRequestObserver"]);
+ }
+
+ onStartRequest() {}
+
+ onDataAvailable(request, stream, offset, count) {
+ this._buffer = this._buffer.concat(read_stream(stream, count));
+ }
+
+ onStopRequest(request) {
+ if (this._onStopCallback) {
+ this._onStopCallback(request, this._buffer);
+ }
+ }
+}