chromium-bidi 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +199 -69
- package/lib/cjs/bidiMapper/BidiServer.d.ts +40 -0
- package/lib/cjs/bidiMapper/BidiServer.js +89 -0
- package/lib/cjs/bidiMapper/BidiServer.js.map +1 -0
- package/lib/cjs/bidiMapper/BidiTransport.d.ts +22 -0
- package/lib/cjs/bidiMapper/BidiTransport.js +19 -0
- package/lib/cjs/bidiMapper/BidiTransport.js.map +1 -0
- package/lib/cjs/bidiMapper/CdpConnection.d.ts +32 -0
- package/lib/cjs/bidiMapper/CdpConnection.js +19 -0
- package/lib/cjs/bidiMapper/CdpConnection.js.map +1 -0
- package/lib/cjs/bidiMapper/CommandProcessor.d.ts +46 -0
- package/lib/cjs/bidiMapper/CommandProcessor.js +136 -0
- package/lib/cjs/bidiMapper/CommandProcessor.js.map +1 -0
- package/lib/cjs/bidiMapper/OutgoingBidiMessage.d.ts +25 -0
- package/lib/cjs/bidiMapper/OutgoingBidiMessage.js +42 -0
- package/lib/cjs/bidiMapper/OutgoingBidiMessage.js.map +1 -0
- package/lib/cjs/bidiMapper/bidiMapper.d.ts +25 -0
- package/lib/cjs/bidiMapper/bidiMapper.js +24 -0
- package/lib/cjs/bidiMapper/bidiMapper.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.d.ts +43 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.js +375 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.d.ts +47 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.js +238 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.d.ts +26 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.js +50 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/events/EventManager.d.ts +32 -0
- package/lib/cjs/bidiMapper/domains/events/EventManager.js +167 -0
- package/lib/cjs/bidiMapper/domains/events/EventManager.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.d.ts +25 -0
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.js +128 -0
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.spec.d.ts +16 -0
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.spec.js +175 -0
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.spec.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/log/logHelper.d.ts +23 -0
- package/lib/cjs/bidiMapper/domains/log/logHelper.js +176 -0
- package/lib/cjs/bidiMapper/domains/log/logHelper.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/log/logHelper_getRemoteValuesText.spec.d.ts +17 -0
- package/lib/cjs/bidiMapper/domains/log/logHelper_getRemoteValuesText.spec.js +65 -0
- package/lib/cjs/bidiMapper/domains/log/logHelper_getRemoteValuesText.spec.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/log/logHelper_logMessageFormatter.spec.d.ts +17 -0
- package/lib/cjs/bidiMapper/domains/log/logHelper_logMessageFormatter.spec.js +378 -0
- package/lib/cjs/bidiMapper/domains/log/logHelper_logMessageFormatter.spec.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/log/logManager.d.ts +8 -0
- package/lib/cjs/bidiMapper/domains/log/logManager.js +136 -0
- package/lib/cjs/bidiMapper/domains/log/logManager.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/script/realm.d.ts +56 -0
- package/lib/cjs/bidiMapper/domains/script/realm.js +185 -0
- package/lib/cjs/bidiMapper/domains/script/realm.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/script/realmStorage.d.ts +38 -0
- package/lib/cjs/bidiMapper/domains/script/realmStorage.js +72 -0
- package/lib/cjs/bidiMapper/domains/script/realmStorage.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/script/scriptEvaluator.d.ts +41 -0
- package/lib/cjs/bidiMapper/domains/script/scriptEvaluator.js +365 -0
- package/lib/cjs/bidiMapper/domains/script/scriptEvaluator.js.map +1 -0
- package/lib/cjs/bidiMapper/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/bidiServer/bidiServerRunner.d.ts +29 -0
- package/{src/.build → lib/cjs}/bidiServer/bidiServerRunner.js +61 -52
- package/lib/cjs/bidiServer/bidiServerRunner.js.map +1 -0
- package/lib/cjs/bidiServer/index.d.ts +17 -0
- package/{src/.build → lib/cjs}/bidiServer/index.js +35 -18
- package/lib/cjs/bidiServer/index.js.map +1 -0
- package/lib/cjs/bidiServer/mapperReader.d.ts +17 -0
- package/{src/.build → lib/cjs}/bidiServer/mapperReader.js +1 -1
- package/lib/cjs/bidiServer/mapperReader.js.map +1 -0
- package/lib/cjs/bidiServer/mapperServer.d.ts +32 -0
- package/{src/.build → lib/cjs}/bidiServer/mapperServer.js +39 -37
- package/lib/cjs/bidiServer/mapperServer.js.map +1 -0
- package/lib/cjs/bidiServer/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/bidiTab/bidiTab.d.ts +30 -0
- package/lib/cjs/bidiTab/bidiTab.js +248 -0
- package/lib/cjs/bidiTab/bidiTab.js.map +1 -0
- package/lib/cjs/bidiTab/mapperTabPage.d.ts +19 -0
- package/lib/cjs/bidiTab/mapperTabPage.js +74 -0
- package/lib/cjs/bidiTab/mapperTabPage.js.map +1 -0
- package/lib/cjs/bidiTab/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/cdp/cdpClient.d.ts +41 -0
- package/lib/cjs/cdp/cdpClient.js +50 -0
- package/lib/cjs/cdp/cdpClient.js.map +1 -0
- package/lib/cjs/cdp/cdpClient.spec.d.ts +17 -0
- package/{src/.build/bidiServer → lib/cjs}/cdp/cdpClient.spec.js +31 -31
- package/lib/cjs/cdp/cdpClient.spec.js.map +1 -0
- package/lib/cjs/cdp/cdpConnection.d.ts +42 -0
- package/{src/.build/bidiServer → lib/cjs}/cdp/cdpConnection.js +36 -35
- package/lib/cjs/cdp/cdpConnection.js.map +1 -0
- package/lib/cjs/cdp/cdpConnection.spec.d.ts +17 -0
- package/{src/.build/bidiServer → lib/cjs}/cdp/cdpConnection.spec.js +23 -23
- package/lib/cjs/cdp/cdpConnection.spec.js.map +1 -0
- package/lib/cjs/cdp/cdpMessage.d.ts +28 -0
- package/{src/.build/bidiServer → lib/cjs}/cdp/cdpMessage.js +0 -0
- package/lib/cjs/cdp/cdpMessage.js.map +1 -0
- package/lib/cjs/cdp/index.d.ts +19 -0
- package/{src/.build/bidiServer → lib/cjs}/cdp/index.js +7 -5
- package/lib/cjs/cdp/index.js.map +1 -0
- package/lib/cjs/cdp/stubTransport.spec.d.ts +28 -0
- package/{src/.build/bidiServer/tests → lib/cjs/cdp}/stubTransport.spec.js +2 -2
- package/lib/cjs/cdp/stubTransport.spec.js.map +1 -0
- package/lib/cjs/cdp/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/cdp/websocketTransport.d.ts +26 -0
- package/{src/.build/bidiServer → lib/cjs}/cdp/websocketTransport.js +11 -11
- package/lib/cjs/cdp/websocketTransport.js.map +1 -0
- package/lib/cjs/protocol/protocol.d.ts +518 -0
- package/lib/cjs/protocol/protocol.js +101 -0
- package/lib/cjs/protocol/protocol.js.map +1 -0
- package/lib/cjs/protocol/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/protocol-parser/protocol-parser.d.ts +765 -0
- package/lib/cjs/protocol-parser/protocol-parser.js +385 -0
- package/lib/cjs/protocol-parser/protocol-parser.js.map +1 -0
- package/lib/cjs/protocol-parser/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/utils/EventEmitter.d.ts +51 -0
- package/lib/cjs/utils/EventEmitter.js +59 -0
- package/lib/cjs/utils/EventEmitter.js.map +1 -0
- package/lib/cjs/utils/EventEmitter.spec.d.ts +16 -0
- package/lib/cjs/utils/EventEmitter.spec.js +109 -0
- package/lib/cjs/utils/EventEmitter.spec.js.map +1 -0
- package/lib/cjs/utils/buffer.d.ts +29 -0
- package/lib/cjs/utils/buffer.js +49 -0
- package/lib/cjs/utils/buffer.js.map +1 -0
- package/lib/cjs/utils/buffer.spec.d.ts +17 -0
- package/lib/cjs/utils/buffer.spec.js +68 -0
- package/lib/cjs/utils/buffer.spec.js.map +1 -0
- package/lib/cjs/utils/deferred.d.ts +27 -0
- package/lib/cjs/utils/deferred.js +54 -0
- package/lib/cjs/utils/deferred.js.map +1 -0
- package/lib/cjs/utils/idWrapper.d.ts +24 -0
- package/lib/cjs/utils/idWrapper.js +34 -0
- package/lib/cjs/utils/idWrapper.js.map +1 -0
- package/lib/cjs/utils/idWrapper.spec.d.ts +17 -0
- package/lib/cjs/utils/idWrapper.spec.js +53 -0
- package/lib/cjs/utils/idWrapper.spec.js.map +1 -0
- package/lib/cjs/utils/log.d.ts +23 -0
- package/lib/cjs/utils/log.js +27 -0
- package/lib/cjs/utils/log.js.map +1 -0
- package/lib/cjs/utils/processingQueue.d.ts +22 -0
- package/lib/cjs/utils/processingQueue.js +60 -0
- package/lib/cjs/utils/processingQueue.js.map +1 -0
- package/lib/cjs/utils/processingQueue.spec.d.ts +17 -0
- package/lib/cjs/utils/processingQueue.spec.js +105 -0
- package/lib/cjs/utils/processingQueue.spec.js.map +1 -0
- package/lib/cjs/utils/transport.d.ts +25 -0
- package/{src/.build/bidiServer → lib/cjs}/utils/transport.js +0 -0
- package/lib/cjs/utils/transport.js.map +1 -0
- package/lib/cjs/utils/tsconfig.tsbuildinfo +1 -0
- package/lib/iife/mapperTab.js +21 -0
- package/lib/iife/mapperTab.js.map +1 -0
- package/package.json +60 -45
- package/src/.build/bidiMapper/mapper.js +0 -26110
- package/src/.build/bidiMapper/mapper.js.map +0 -1
- package/src/.build/bidiServer/bidiServerRunner.js.map +0 -1
- package/src/.build/bidiServer/cdp/cdpClient.js +0 -122
- package/src/.build/bidiServer/cdp/cdpClient.js.map +0 -1
- package/src/.build/bidiServer/cdp/cdpClient.spec.js.map +0 -1
- package/src/.build/bidiServer/cdp/cdpConnection.js.map +0 -1
- package/src/.build/bidiServer/cdp/cdpConnection.spec.js.map +0 -1
- package/src/.build/bidiServer/cdp/cdpMessage.js.map +0 -1
- package/src/.build/bidiServer/cdp/index.js.map +0 -1
- package/src/.build/bidiServer/cdp/websocketTransport.js.map +0 -1
- package/src/.build/bidiServer/index.js.map +0 -1
- package/src/.build/bidiServer/mapperReader.js.map +0 -1
- package/src/.build/bidiServer/mapperServer.js.map +0 -1
- package/src/.build/bidiServer/tests/stubTransport.spec.js.map +0 -1
- package/src/.build/bidiServer/utils/log.js +0 -44
- package/src/.build/bidiServer/utils/log.js.map +0 -1
- package/src/.build/bidiServer/utils/transport.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -198,4 +198,4 @@
|
|
|
198
198
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
199
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
200
|
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,15 +1,135 @@
|
|
|
1
1
|
# WebDriver BiDi for Chromium [](https://www.npmjs.com/package/chromium-bidi)
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
3
10
|
This is an implementation of the
|
|
4
|
-
[WebDriver BiDi](https://w3c.github.io/webdriver-bidi/) protocol
|
|
5
|
-
|
|
6
|
-
|
|
11
|
+
[WebDriver BiDi](https://w3c.github.io/webdriver-bidi/) protocol with some
|
|
12
|
+
extensions (**BiDi+**)
|
|
13
|
+
for Chromium, implemented as a JavaScript layer translating between BiDi and CDP,
|
|
14
|
+
running inside a Chrome tab.
|
|
7
15
|
|
|
8
|
-
Current status can be checked
|
|
9
|
-
[
|
|
10
|
-
|
|
16
|
+
Current status can be checked
|
|
17
|
+
at [WPT WebDriver BiDi status](https://wpt.fyi/results/webdriver/tests/bidi).
|
|
18
|
+
|
|
19
|
+
## BiDi+
|
|
20
|
+
|
|
21
|
+
**"BiDi+"** is an extension of the WebDriver BiDi protocol. In addition to [WebDriver BiDi](https://w3c.github.io/webdriver-bidi/) it has:
|
|
22
|
+
|
|
23
|
+
### Command `cdp.sendCommand`
|
|
24
|
+
|
|
25
|
+
```cddl
|
|
26
|
+
CdpSendCommandCommand = {
|
|
27
|
+
method: "cdp.sendCommand",
|
|
28
|
+
params: ScriptEvaluateParameters,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
CdpSendCommandParameters = {
|
|
32
|
+
cdpMethod: text,
|
|
33
|
+
cdpParams: any,
|
|
34
|
+
cdpSession?: text,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
CdpSendCommandResult = {
|
|
38
|
+
result: any,
|
|
39
|
+
cdpSession: text,
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The command runs the
|
|
44
|
+
described [CDP command](https://chromedevtools.github.io/devtools-protocol)
|
|
45
|
+
and returns result.
|
|
46
|
+
|
|
47
|
+
### Command `cdp.getSession`
|
|
48
|
+
|
|
49
|
+
```cddl
|
|
50
|
+
CdpGetSessionCommand = {
|
|
51
|
+
method: "cdp.sendCommand",
|
|
52
|
+
params: ScriptEvaluateParameters,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
CdpGetSessionParameters = {
|
|
56
|
+
context: BrowsingContext,
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
CdpGetSessionResult = {
|
|
60
|
+
cdpSession: text,
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The command returns the default CDP session for the selected browsing context.
|
|
11
65
|
|
|
12
|
-
|
|
66
|
+
### Event `cdp.eventReceived`
|
|
67
|
+
|
|
68
|
+
```cddl
|
|
69
|
+
CdpEventReceivedEvent = {
|
|
70
|
+
method: "cdp.eventReceived",
|
|
71
|
+
params: ScriptEvaluateParameters,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
CdpEventReceivedParameters = {
|
|
75
|
+
cdpMethod: text,
|
|
76
|
+
cdpParams: any,
|
|
77
|
+
cdpSession: string,
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The event contains a CDP event.
|
|
82
|
+
|
|
83
|
+
### Field `channel`
|
|
84
|
+
|
|
85
|
+
Each command can be extended with a `channel`:
|
|
86
|
+
|
|
87
|
+
```cddl
|
|
88
|
+
Command = {
|
|
89
|
+
id: js-uint,
|
|
90
|
+
channel?: text,
|
|
91
|
+
CommandData,
|
|
92
|
+
Extensible,
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
If provided and non-empty string, the very same `channel` is added to the response:
|
|
97
|
+
|
|
98
|
+
```cddl
|
|
99
|
+
CommandResponse = {
|
|
100
|
+
id: js-uint,
|
|
101
|
+
channel?: text,
|
|
102
|
+
result: ResultData,
|
|
103
|
+
Extensible,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
ErrorResponse = {
|
|
107
|
+
id: js-uint / null,
|
|
108
|
+
channel?: text,
|
|
109
|
+
error: ErrorCode,
|
|
110
|
+
message: text,
|
|
111
|
+
?stacktrace: text,
|
|
112
|
+
Extensible
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
When client uses
|
|
117
|
+
commands [`session.subscribe`](https://w3c.github.io/webdriver-bidi/#command-session-subscribe)
|
|
118
|
+
and [`session.unsubscribe`](https://w3c.github.io/webdriver-bidi/#command-session-unsubscribe)
|
|
119
|
+
with `channel`, the subscriptions are handled per channel, and the corresponding
|
|
120
|
+
`channel` filed is added to the event message:
|
|
121
|
+
|
|
122
|
+
```cddl
|
|
123
|
+
Event = {
|
|
124
|
+
channel?: text,
|
|
125
|
+
EventData,
|
|
126
|
+
Extensible,
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Dev Setup
|
|
131
|
+
|
|
132
|
+
### `npm`
|
|
13
133
|
|
|
14
134
|
This is a Node.js project, so install dependencies as usual:
|
|
15
135
|
|
|
@@ -17,14 +137,19 @@ This is a Node.js project, so install dependencies as usual:
|
|
|
17
137
|
npm install
|
|
18
138
|
```
|
|
19
139
|
|
|
20
|
-
|
|
140
|
+
### pre-commit.com integration
|
|
141
|
+
|
|
142
|
+
Refer to the documentation at [.pre-commit-config.yaml](.pre-commit-config.yaml).
|
|
143
|
+
|
|
144
|
+
### Starting the Server
|
|
145
|
+
|
|
146
|
+
This will run the server on port `8080`:
|
|
21
147
|
|
|
22
148
|
```sh
|
|
23
149
|
npm run server
|
|
24
150
|
```
|
|
25
151
|
|
|
26
|
-
|
|
27
|
-
or `--port=...` argument to run it on another port:
|
|
152
|
+
Use the `PORT=` environment variable or `--port=` argument to run it on another port:
|
|
28
153
|
|
|
29
154
|
```sh
|
|
30
155
|
PORT=8081 npm run server
|
|
@@ -43,7 +168,18 @@ Use the CLI argument `--headless=false` to run browser in headful mode:
|
|
|
43
168
|
npm run server -- --headless=false
|
|
44
169
|
```
|
|
45
170
|
|
|
46
|
-
|
|
171
|
+
Use the `CHANNEL=...` environment variable or `--channel=...` argument with one of
|
|
172
|
+
the following values to run the specific Chrome channel: `chrome`,
|
|
173
|
+
`chrome-beta`, `chrome-canary`, `chrome-dev`.
|
|
174
|
+
|
|
175
|
+
The requested Chrome version should be installed.
|
|
176
|
+
|
|
177
|
+
```sh
|
|
178
|
+
CHANNEL=chrome-dev npm run server
|
|
179
|
+
npm run server -- --channel=chrome-dev
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Starting on Linux and Mac
|
|
47
183
|
|
|
48
184
|
TODO: verify if it works on Windows.
|
|
49
185
|
|
|
@@ -54,19 +190,19 @@ output to the file `log.txt`:
|
|
|
54
190
|
./runBiDiServer.sh --port=8081 --headless=false
|
|
55
191
|
```
|
|
56
192
|
|
|
57
|
-
|
|
193
|
+
## Running
|
|
58
194
|
|
|
59
|
-
|
|
195
|
+
### Unit tests
|
|
60
196
|
|
|
61
197
|
Running:
|
|
62
198
|
|
|
63
199
|
```sh
|
|
64
|
-
npm
|
|
200
|
+
npm test
|
|
65
201
|
```
|
|
66
202
|
|
|
67
|
-
|
|
203
|
+
### E2E tests
|
|
68
204
|
|
|
69
|
-
The
|
|
205
|
+
The E2E tests are written using Python, in order to learn how to eventually do
|
|
70
206
|
this in web-platform-tests.
|
|
71
207
|
|
|
72
208
|
### Installation
|
|
@@ -79,7 +215,7 @@ python3 -m pip install --user -r tests/requirements.txt
|
|
|
79
215
|
|
|
80
216
|
### Running
|
|
81
217
|
|
|
82
|
-
The
|
|
218
|
+
The E2E tests require BiDi server running on the same host. By default, tests
|
|
83
219
|
try to connect to the port `8080`. The server can be run from the project root:
|
|
84
220
|
|
|
85
221
|
```sh
|
|
@@ -92,50 +228,22 @@ Use the `PORT` environment variable to connect to another port:
|
|
|
92
228
|
PORT=8081 npm run e2e
|
|
93
229
|
```
|
|
94
230
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
The examples are stored in the `/examples` folder and are intended to show who
|
|
98
|
-
the BiDi protocol can be used. Examples are based on
|
|
99
|
-
[Puppeteer's examples](https://github.com/puppeteer/puppeteer/tree/main/examples)
|
|
100
|
-
.
|
|
101
|
-
|
|
102
|
-
### Instalation
|
|
103
|
-
|
|
104
|
-
The examples are written using Python, to align with e2e test. Python 3.6+ and
|
|
105
|
-
some dependencies are required:
|
|
106
|
-
|
|
107
|
-
```sh
|
|
108
|
-
python3 -m pip install --user -r tests/requirements.txt
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Running
|
|
112
|
-
|
|
113
|
-
The examples require BiDi server running on the same host on the port `8080`.
|
|
114
|
-
The server can be run from the project root:
|
|
115
|
-
|
|
116
|
-
```sh
|
|
117
|
-
npm run server
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
After running server, examples can be simply run:
|
|
231
|
+
### Examples
|
|
121
232
|
|
|
122
|
-
|
|
123
|
-
python3 examples/cross-browser.py
|
|
124
|
-
```
|
|
233
|
+
Refer to [examples/README.md](examples/README.md).
|
|
125
234
|
|
|
126
|
-
## WPT
|
|
235
|
+
## WPT (Web Platform Tests)
|
|
127
236
|
|
|
128
237
|
WPT is added as
|
|
129
|
-
a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules). To get
|
|
130
|
-
|
|
238
|
+
a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules). To get run
|
|
239
|
+
WPT tests:
|
|
131
240
|
|
|
132
|
-
### Check out
|
|
241
|
+
### Check out and setup WPT
|
|
133
242
|
|
|
134
243
|
#### 1. Check out WPT
|
|
135
244
|
|
|
136
245
|
```sh
|
|
137
|
-
git submodule init
|
|
138
|
-
git submodule update
|
|
246
|
+
git submodule update --init
|
|
139
247
|
```
|
|
140
248
|
|
|
141
249
|
#### 2. Go to the WPT folder
|
|
@@ -156,13 +264,13 @@ Follow
|
|
|
156
264
|
the [`hosts` File Setup](https://web-platform-tests.org/running-tests/from-local-system.html#hosts-file-setup)
|
|
157
265
|
instructions.
|
|
158
266
|
|
|
159
|
-
##### On Linux, macOS or other UNIX-like system
|
|
267
|
+
##### 4.a On Linux, macOS or other UNIX-like system
|
|
160
268
|
|
|
161
269
|
```sh
|
|
162
270
|
./wpt make-hosts-file | sudo tee -a /etc/hosts
|
|
163
271
|
```
|
|
164
272
|
|
|
165
|
-
#####
|
|
273
|
+
##### 4.b On **Windows**
|
|
166
274
|
|
|
167
275
|
This must be run in a PowerShell session with Administrator privileges:
|
|
168
276
|
|
|
@@ -170,26 +278,48 @@ This must be run in a PowerShell session with Administrator privileges:
|
|
|
170
278
|
python wpt make-hosts-file | Out-File $env:SystemRoot\System32\drivers\etc\hosts -Encoding ascii -Append
|
|
171
279
|
```
|
|
172
280
|
|
|
173
|
-
If you are behind a proxy, you also need to make sure the domains above are
|
|
174
|
-
|
|
281
|
+
If you are behind a proxy, you also need to make sure the domains above are excluded
|
|
282
|
+
from your proxy lookups.
|
|
283
|
+
|
|
284
|
+
#### 5. Set `WPT_BROWSER_PATH`
|
|
175
285
|
|
|
176
|
-
|
|
286
|
+
Set the `WPT_BROWSER_PATH` environment variable to a Chrome, Edge or Chromium binary to launch.
|
|
287
|
+
For example, on macOS:
|
|
177
288
|
|
|
178
289
|
```sh
|
|
290
|
+
# Chrome
|
|
179
291
|
export WPT_BROWSER_PATH="/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"
|
|
180
|
-
export WPT_BROWSER_PATH="/Applications/
|
|
292
|
+
export WPT_BROWSER_PATH="/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev"
|
|
293
|
+
export WPT_BROWSER_PATH="/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta"
|
|
294
|
+
export WPT_BROWSER_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
|
181
295
|
export WPT_BROWSER_PATH="/Applications/Chromium.app/Contents/MacOS/Chromium"
|
|
296
|
+
|
|
297
|
+
# Edge
|
|
298
|
+
export WPT_BROWSER_PATH="/Applications/Microsoft Edge Canary.app/Contents/MacOS/Microsoft Edge Canary"
|
|
299
|
+
export WPT_BROWSER_PATH="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
|
|
182
300
|
```
|
|
183
301
|
|
|
184
302
|
### Run WPT tests
|
|
185
303
|
|
|
186
|
-
#### 1.
|
|
304
|
+
#### 1. Make sure you have Chrome Dev installed
|
|
305
|
+
|
|
306
|
+
https://www.google.com/chrome/dev/
|
|
307
|
+
|
|
308
|
+
#### 2. Build ChromeDriver BiDi
|
|
309
|
+
|
|
310
|
+
Oneshot:
|
|
187
311
|
|
|
188
312
|
```sh
|
|
189
313
|
npm run build
|
|
190
314
|
```
|
|
191
315
|
|
|
192
|
-
|
|
316
|
+
Continuously:
|
|
317
|
+
|
|
318
|
+
```sh
|
|
319
|
+
npm run watch
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
#### 3. Run
|
|
193
323
|
|
|
194
324
|
```sh
|
|
195
325
|
./wpt/wpt run \
|
|
@@ -226,7 +356,7 @@ npm run build
|
|
|
226
356
|
./wptreport.json
|
|
227
357
|
```
|
|
228
358
|
|
|
229
|
-
|
|
359
|
+
## How does it work?
|
|
230
360
|
|
|
231
361
|
The architecture is described in the
|
|
232
362
|
[WebDriver BiDi in Chrome Context implementation plan](https://docs.google.com/document/d/1VfQ9tv0wPSnb5TI-MOobjoQ5CXLnJJx9F_PxOMQc8kY)
|
|
@@ -234,17 +364,17 @@ The architecture is described in the
|
|
|
234
364
|
|
|
235
365
|
There are 2 main modules:
|
|
236
366
|
|
|
237
|
-
1. backend WS server in `src`. It runs webSocket server, and for each ws
|
|
238
|
-
|
|
239
|
-
2. front-end BiDi Mapper in `src/bidiMapper`. Gets BiDi commands from the
|
|
240
|
-
|
|
367
|
+
1. backend WS server in `src`. It runs webSocket server, and for each ws connection
|
|
368
|
+
runs an instance of browser with BiDi Mapper.
|
|
369
|
+
2. front-end BiDi Mapper in `src/bidiMapper`. Gets BiDi commands from the backend,
|
|
370
|
+
and map them to CDP commands.
|
|
241
371
|
|
|
242
|
-
|
|
372
|
+
### Contributing
|
|
243
373
|
|
|
244
|
-
The BiDi commands are processed in the `src/bidiMapper/commandProcessor.ts`. To
|
|
245
|
-
|
|
374
|
+
The BiDi commands are processed in the `src/bidiMapper/commandProcessor.ts`. To add a
|
|
375
|
+
new command, add it to `_processCommand`, write and call processor for it.
|
|
246
376
|
|
|
247
|
-
|
|
377
|
+
### Publish new `npm` release
|
|
248
378
|
|
|
249
379
|
1. On the `main` branch, bump the chromium-bidi version number in `package.json`:
|
|
250
380
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2021 Google LLC.
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { BidiParser } from './CommandProcessor.js';
|
|
18
|
+
import { BidiTransport } from './BidiTransport.js';
|
|
19
|
+
import { BrowsingContextStorage } from './domains/context/browsingContextStorage.js';
|
|
20
|
+
import { CdpConnection } from './CdpConnection.js';
|
|
21
|
+
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
22
|
+
import { LoggerFn } from '../utils/log.js';
|
|
23
|
+
import type { Message } from '../protocol/protocol.js';
|
|
24
|
+
import { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
|
|
25
|
+
declare type BidiServerEvents = {
|
|
26
|
+
message: Message.RawCommandRequest;
|
|
27
|
+
};
|
|
28
|
+
export declare class BidiServer extends EventEmitter<BidiServerEvents> {
|
|
29
|
+
#private;
|
|
30
|
+
private constructor();
|
|
31
|
+
static createAndStart(bidiTransport: BidiTransport, cdpConnection: CdpConnection, selfTargetId: string, parser?: BidiParser, logger?: LoggerFn): Promise<BidiServer>;
|
|
32
|
+
topLevelContextsLoaded(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Sends BiDi message.
|
|
35
|
+
*/
|
|
36
|
+
emitOutgoingMessage(messageEntry: Promise<OutgoingBidiMessage>): void;
|
|
37
|
+
close(): void;
|
|
38
|
+
getBrowsingContextStorage(): BrowsingContextStorage;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2021 Google LLC.
|
|
4
|
+
* Copyright (c) Microsoft Corporation.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.BidiServer = void 0;
|
|
20
|
+
const CommandProcessor_js_1 = require("./CommandProcessor.js");
|
|
21
|
+
const browsingContextStorage_js_1 = require("./domains/context/browsingContextStorage.js");
|
|
22
|
+
const EventEmitter_js_1 = require("../utils/EventEmitter.js");
|
|
23
|
+
const EventManager_js_1 = require("./domains/events/EventManager.js");
|
|
24
|
+
const processingQueue_js_1 = require("../utils/processingQueue.js");
|
|
25
|
+
const realmStorage_js_1 = require("./domains/script/realmStorage.js");
|
|
26
|
+
class BidiServer extends EventEmitter_js_1.EventEmitter {
|
|
27
|
+
#messageQueue;
|
|
28
|
+
#transport;
|
|
29
|
+
#commandProcessor;
|
|
30
|
+
#browsingContextStorage;
|
|
31
|
+
#realmStorage;
|
|
32
|
+
#logger;
|
|
33
|
+
constructor(bidiTransport, cdpConnection, selfTargetId, parser, logger) {
|
|
34
|
+
super();
|
|
35
|
+
this.#logger = logger;
|
|
36
|
+
this.#browsingContextStorage = new browsingContextStorage_js_1.BrowsingContextStorage();
|
|
37
|
+
this.#realmStorage = new realmStorage_js_1.RealmStorage();
|
|
38
|
+
this.#messageQueue = new processingQueue_js_1.ProcessingQueue(this.#processOutgoingMessage, undefined, this.#logger);
|
|
39
|
+
this.#transport = bidiTransport;
|
|
40
|
+
this.#transport.setOnMessage(this.#handleIncomingMessage);
|
|
41
|
+
this.#commandProcessor = new CommandProcessor_js_1.CommandProcessor(this.#realmStorage, cdpConnection, new EventManager_js_1.EventManager(this), selfTargetId, parser, this.#browsingContextStorage, this.#logger);
|
|
42
|
+
this.#commandProcessor.on('response', (response) => {
|
|
43
|
+
this.emitOutgoingMessage(response);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
static async createAndStart(bidiTransport, cdpConnection, selfTargetId, parser, logger) {
|
|
47
|
+
const server = new BidiServer(bidiTransport, cdpConnection, selfTargetId, parser, logger);
|
|
48
|
+
const cdpClient = cdpConnection.browserClient();
|
|
49
|
+
// Needed to get events about new targets.
|
|
50
|
+
await cdpClient.sendCommand('Target.setDiscoverTargets', { discover: true });
|
|
51
|
+
// Needed to automatically attach to new targets.
|
|
52
|
+
await cdpClient.sendCommand('Target.setAutoAttach', {
|
|
53
|
+
autoAttach: true,
|
|
54
|
+
waitForDebuggerOnStart: true,
|
|
55
|
+
flatten: true,
|
|
56
|
+
});
|
|
57
|
+
await server.topLevelContextsLoaded();
|
|
58
|
+
return server;
|
|
59
|
+
}
|
|
60
|
+
async topLevelContextsLoaded() {
|
|
61
|
+
await Promise.all(this.#browsingContextStorage
|
|
62
|
+
.getTopLevelContexts()
|
|
63
|
+
.map((c) => c.awaitLoaded()));
|
|
64
|
+
}
|
|
65
|
+
#processOutgoingMessage = async (messageEntry) => {
|
|
66
|
+
const message = messageEntry.message;
|
|
67
|
+
if (messageEntry.channel !== null) {
|
|
68
|
+
message['channel'] = messageEntry.channel;
|
|
69
|
+
}
|
|
70
|
+
await this.#transport.sendMessage(message);
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Sends BiDi message.
|
|
74
|
+
*/
|
|
75
|
+
emitOutgoingMessage(messageEntry) {
|
|
76
|
+
this.#messageQueue.add(messageEntry);
|
|
77
|
+
}
|
|
78
|
+
close() {
|
|
79
|
+
this.#transport.close();
|
|
80
|
+
}
|
|
81
|
+
#handleIncomingMessage = async (message) => {
|
|
82
|
+
this.#commandProcessor.processCommand(message);
|
|
83
|
+
};
|
|
84
|
+
getBrowsingContextStorage() {
|
|
85
|
+
return this.#browsingContextStorage;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.BidiServer = BidiServer;
|
|
89
|
+
//# sourceMappingURL=BidiServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BidiServer.js","sourceRoot":"","sources":["../../../src/bidiMapper/BidiServer.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2022 Google LLC.
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { Message } from '../protocol/protocol.js';
|
|
18
|
+
export interface BidiTransport {
|
|
19
|
+
setOnMessage: (handler: (message: Message.RawCommandRequest) => Promise<void>) => void;
|
|
20
|
+
sendMessage: (message: Message.OutgoingMessage) => Promise<void>;
|
|
21
|
+
close(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2022 Google LLC.
|
|
4
|
+
* Copyright (c) Microsoft Corporation.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
//# sourceMappingURL=BidiTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BidiTransport.js","sourceRoot":"","sources":["../../../src/bidiMapper/BidiTransport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2022 Google LLC.
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
18
|
+
import type { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';
|
|
19
|
+
declare type CdpEvents = {
|
|
20
|
+
[Property in keyof ProtocolMapping.Events]: ProtocolMapping.Events[Property][0];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* CDP interfaces that BiDi Mapper expects.
|
|
24
|
+
*/
|
|
25
|
+
export interface CdpConnection {
|
|
26
|
+
browserClient(): CdpClient;
|
|
27
|
+
getCdpClient(sessionId: string): CdpClient;
|
|
28
|
+
}
|
|
29
|
+
export interface CdpClient extends EventEmitter<CdpEvents> {
|
|
30
|
+
sendCommand<T extends keyof ProtocolMapping.Commands>(method: T, ...params: ProtocolMapping.Commands[T]['paramsType']): Promise<ProtocolMapping.Commands[T]['returnType']>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2022 Google LLC.
|
|
4
|
+
* Copyright (c) Microsoft Corporation.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
//# sourceMappingURL=CdpConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CdpConnection.js","sourceRoot":"","sources":["../../../src/bidiMapper/CdpConnection.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2021 Google LLC.
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { BrowsingContext, CDP, Message, Script, Session } from '../protocol/protocol.js';
|
|
18
|
+
import { BrowsingContextStorage } from './domains/context/browsingContextStorage.js';
|
|
19
|
+
import { CdpConnection } from './CdpConnection.js';
|
|
20
|
+
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
21
|
+
import { IEventManager } from './domains/events/EventManager.js';
|
|
22
|
+
import { LoggerFn } from '../utils/log.js';
|
|
23
|
+
import { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
|
|
24
|
+
import { RealmStorage } from './domains/script/realmStorage.js';
|
|
25
|
+
declare type CommandProcessorEvents = {
|
|
26
|
+
response: Promise<OutgoingBidiMessage>;
|
|
27
|
+
};
|
|
28
|
+
export interface BidiParser {
|
|
29
|
+
parseGetRealmsParams(params: object): Script.GetRealmsParameters;
|
|
30
|
+
parseCallFunctionParams(params: object): Script.CallFunctionParameters;
|
|
31
|
+
parseEvaluateParams(params: object): Script.EvaluateParameters;
|
|
32
|
+
parseDisownParams(params: object): Script.DisownParameters;
|
|
33
|
+
parseSendCommandParams(params: object): CDP.SendCommandParams;
|
|
34
|
+
parseGetSessionParams(params: object): CDP.GetSessionParams;
|
|
35
|
+
parseNavigateParams(params: object): BrowsingContext.NavigateParameters;
|
|
36
|
+
parseGetTreeParams(params: object): BrowsingContext.GetTreeParameters;
|
|
37
|
+
parseSubscribeParams(params: object): Session.SubscribeParameters;
|
|
38
|
+
parseCreateParams(params: object): BrowsingContext.CreateParameters;
|
|
39
|
+
parseCloseParams(params: object): BrowsingContext.CloseParameters;
|
|
40
|
+
}
|
|
41
|
+
export declare class CommandProcessor extends EventEmitter<CommandProcessorEvents> {
|
|
42
|
+
#private;
|
|
43
|
+
constructor(realmStorage: RealmStorage, cdpConnection: CdpConnection, eventManager: IEventManager, selfTargetId: string, parser: BidiParser | undefined, browsingContextStorage: BrowsingContextStorage, logger?: LoggerFn);
|
|
44
|
+
processCommand: (command: Message.RawCommandRequest) => Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export {};
|