1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This is a Mozilla-specific WebExtension API, which is not available to web
9 * content. It allows monitoring and filtering of HTTP response stream data.
11 * This API should currently be considered experimental, and is not defined by
15 enum StreamFilterStatus {
17 * The StreamFilter is not fully initialized. No methods may be called until
18 * a "start" event has been received.
22 * The underlying channel is currently transferring data, which will be
23 * dispatched via "data" events.
27 * The underlying channel has finished transferring data. Data may still be
28 * written via write() calls at this point.
30 "finishedtransferringdata",
32 * Data transfer is currently suspended. It may be resumed by a call to
33 * resume(). Data may still be written via write() calls in this state.
37 * The channel has been closed by a call to close(). No further data wlil be
38 * delivered via "data" events, and no further data may be written via
43 * The channel has been disconnected by a call to disconnect(). All further
44 * data will be delivered directly, without passing through the filter. No
45 * further events will be dispatched, and no further data may be written by
50 * An error has occurred and the channel is disconnected. The `error`
51 * property contains the details of the error.
57 * An interface which allows an extension to intercept, and optionally modify,
58 * response data from an HTTP request.
61 Func="mozilla::extensions::StreamFilter::IsAllowedInContext"]
62 interface StreamFilter : EventTarget {
64 * Creates a stream filter for the given add-on and the given extension ID.
67 static StreamFilter create(unsigned long long requestId, DOMString addonId);
70 * Suspends processing of the request. After this is called, no further data
71 * will be delivered until the request is resumed.
77 * Resumes delivery of data for a suspended request.
83 * Closes the request. After this is called, no more data may be written to
84 * the stream, and no further data will be delivered.
86 * This *must* be called after the consumer is finished writing data, unless
87 * disconnect() has already been called.
93 * Disconnects the stream filter from the request. After this is called, no
94 * further data will be delivered to the filter, and any unprocessed data
95 * will be written directly to the output stream.
101 * Writes a chunk of data to the output stream. This may not be called
102 * before the "start" event has been received.
105 void write((ArrayBuffer or Uint8Array) data);
108 * Returns the current status of the stream.
111 readonly attribute StreamFilterStatus status;
114 * After an "error" event has been dispatched, this contains a message
115 * describing the error.
118 readonly attribute DOMString error;
121 * Dispatched with a StreamFilterDataEvent whenever incoming data is
122 * available on the stream. This data will not be delivered to the output
123 * stream unless it is explicitly written via a write() call.
125 attribute EventHandler ondata;
128 * Dispatched when the stream is opened, and is about to begin delivering
131 attribute EventHandler onstart;
134 * Dispatched when the stream has closed, and has no more data to deliver.
135 * The output stream remains open and writable until close() is called.
137 attribute EventHandler onstop;
140 * Dispatched when an error has occurred. No further data may be read or
141 * written after this point.
143 attribute EventHandler onerror;