summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/head_channels.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /netwerk/test/unit/head_channels.js
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-upstream/125.0.1.tar.xz
firefox-upstream/125.0.1.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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);
+ }
+ }
+}