chromium-bidi 0.4.18 → 0.4.20
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/.browser +1 -1
- package/README.md +17 -0
- package/lib/cjs/bidiMapper/BidiServer.d.ts +2 -2
- package/lib/cjs/bidiMapper/BidiServer.js +7 -8
- package/lib/cjs/bidiMapper/BidiServer.js.map +1 -1
- package/lib/cjs/bidiMapper/CommandProcessor.d.ts +3 -2
- package/lib/cjs/bidiMapper/CommandProcessor.js +33 -33
- package/lib/cjs/bidiMapper/CommandProcessor.js.map +1 -1
- package/lib/cjs/bidiMapper/OutgoingBidiMessage.d.ts +3 -2
- package/lib/cjs/bidiMapper/OutgoingBidiMessage.js +15 -4
- package/lib/cjs/bidiMapper/OutgoingBidiMessage.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/browser/BrowserProcessor.d.ts +23 -0
- package/lib/cjs/bidiMapper/domains/browser/BrowserProcessor.js +34 -0
- package/lib/cjs/bidiMapper/domains/browser/BrowserProcessor.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/cdp/CdpProcessor.d.ts +25 -0
- package/lib/cjs/bidiMapper/domains/cdp/CdpProcessor.js +47 -0
- package/lib/cjs/bidiMapper/domains/cdp/CdpProcessor.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.d.ts +3 -2
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.js +8 -16
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.d.ts +11 -13
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.js +88 -106
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/cdpTarget.d.ts +6 -9
- package/lib/cjs/bidiMapper/domains/context/cdpTarget.js +10 -19
- package/lib/cjs/bidiMapper/domains/context/cdpTarget.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/events/EventManager.d.ts +5 -6
- package/lib/cjs/bidiMapper/domains/events/EventManager.js +5 -32
- package/lib/cjs/bidiMapper/domains/events/EventManager.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/log/logManager.js +32 -29
- package/lib/cjs/bidiMapper/domains/log/logManager.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/network/{networkProcessor.d.ts → NetworkManager.d.ts} +2 -2
- package/lib/cjs/bidiMapper/domains/network/{networkProcessor.js → NetworkManager.js} +13 -14
- package/lib/cjs/bidiMapper/domains/network/NetworkManager.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/network/networkRequest.js +64 -16
- package/lib/cjs/bidiMapper/domains/network/networkRequest.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/script/ScriptProcessor.d.ts +2 -2
- package/lib/cjs/bidiMapper/domains/script/ScriptProcessor.js +14 -14
- package/lib/cjs/bidiMapper/domains/script/ScriptProcessor.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/script/bidiPreloadScript.d.ts +3 -2
- package/lib/cjs/bidiMapper/domains/script/bidiPreloadScript.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/script/realm.d.ts +2 -2
- package/lib/cjs/bidiMapper/domains/script/realm.js +10 -6
- package/lib/cjs/bidiMapper/domains/script/realm.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/script/realmStorage.d.ts +1 -1
- package/lib/cjs/bidiMapper/domains/session/SessionProcessor.d.ts +25 -0
- package/lib/cjs/bidiMapper/domains/session/SessionProcessor.js +38 -0
- package/lib/cjs/bidiMapper/domains/session/SessionProcessor.js.map +1 -0
- package/lib/cjs/bidiMapper/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/bidiServer/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/bidiTab/bidiTab.js +3 -1
- package/lib/cjs/bidiTab/bidiTab.js.map +1 -1
- package/lib/cjs/bidiTab/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/cdp/cdpClient.d.ts +5 -6
- package/lib/cjs/cdp/cdpClient.js.map +1 -1
- package/lib/cjs/cdp/cdpConnection.d.ts +4 -3
- package/lib/cjs/cdp/cdpConnection.js.map +1 -1
- package/lib/cjs/cdp/cdpMessage.d.ts +2 -1
- package/lib/cjs/cdp/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/protocol/ErrorResponse.d.ts +13 -7
- package/lib/cjs/protocol/ErrorResponse.js +32 -36
- package/lib/cjs/protocol/ErrorResponse.js.map +1 -1
- package/lib/cjs/protocol/cdp.d.ts +5 -4
- package/lib/cjs/protocol/chromium-bidi.d.ts +3 -1
- package/lib/cjs/protocol/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/protocol/webdriver-bidi.d.ts +68 -40
- package/lib/cjs/protocol-parser/protocol-parser.d.ts +2 -2
- package/lib/cjs/protocol-parser/protocol-parser.js.map +1 -1
- package/lib/cjs/protocol-parser/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/protocol-parser/webdriver-bidi.d.ts +46 -0
- package/lib/cjs/protocol-parser/webdriver-bidi.js +2 -0
- package/lib/cjs/protocol-parser/webdriver-bidi.js.map +1 -1
- package/lib/cjs/utils/assert.js +2 -2
- package/lib/cjs/utils/assert.js.map +1 -1
- package/lib/cjs/utils/deferred.js +8 -4
- package/lib/cjs/utils/deferred.js.map +1 -1
- package/lib/cjs/utils/processingQueue.d.ts +2 -1
- package/lib/cjs/utils/processingQueue.js +7 -1
- package/lib/cjs/utils/processingQueue.js.map +1 -1
- package/lib/cjs/utils/result.d.ts +23 -0
- package/lib/cjs/utils/result.js +19 -0
- package/lib/cjs/utils/result.js.map +1 -0
- package/lib/cjs/utils/tsconfig.tsbuildinfo +1 -1
- package/lib/iife/mapperTab.js +2 -2
- package/lib/iife/mapperTab.js.map +1 -1
- package/package.json +2 -1
- package/lib/cjs/bidiMapper/domains/network/networkProcessor.js.map +0 -1
package/.browser
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
chrome@117.0.
|
|
1
|
+
chrome@117.0.5920.0
|
package/README.md
CHANGED
|
@@ -399,3 +399,20 @@ We use [release-please](https://github.com/googleapis/release-please) to automat
|
|
|
399
399
|
|
|
400
400
|
1. After the PR is reviewed, [create a GitHub release](https://github.com/GoogleChromeLabs/chromium-bidi/releases/new) specifying the tag name matching the bumped version.
|
|
401
401
|
Our CI then automatically publishes the new release to npm based on the tag name.
|
|
402
|
+
|
|
403
|
+
#### Roll into Chromium
|
|
404
|
+
|
|
405
|
+
> Assuming that you already have a Chromium set-up locally, and knowledge on how to submit changes to the repo.
|
|
406
|
+
> Else submit an issue for a project maintainer to do.
|
|
407
|
+
|
|
408
|
+
1. Create a new branch.
|
|
409
|
+
2. Navigate to `third_party/bidimapper/`.
|
|
410
|
+
3. Then run the following commands:
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
./pull.sh
|
|
414
|
+
./build.sh
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
4. Submit a CL with bug `chromedriver:4226`
|
|
418
|
+
5. Add appropriate reviewers or comment the CL link on the PR
|
|
@@ -18,6 +18,7 @@ import type { ICdpConnection } from '../cdp/cdpConnection.js';
|
|
|
18
18
|
import type { ChromiumBidi } from '../protocol/protocol.js';
|
|
19
19
|
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
20
20
|
import { type LoggerFn } from '../utils/log.js';
|
|
21
|
+
import type { Result } from '../utils/result.js';
|
|
21
22
|
import type { IBidiParser } from './BidiParser.js';
|
|
22
23
|
import type { IBidiTransport } from './BidiTransport.js';
|
|
23
24
|
import type { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
|
|
@@ -29,11 +30,10 @@ export declare class BidiServer extends EventEmitter<BidiServerEvent> {
|
|
|
29
30
|
#private;
|
|
30
31
|
private constructor();
|
|
31
32
|
static createAndStart(bidiTransport: IBidiTransport, cdpConnection: ICdpConnection, selfTargetId: string, parser?: IBidiParser, logger?: LoggerFn): Promise<BidiServer>;
|
|
32
|
-
topLevelContextsLoaded(): Promise<void>;
|
|
33
33
|
/**
|
|
34
34
|
* Sends BiDi message.
|
|
35
35
|
*/
|
|
36
|
-
emitOutgoingMessage(messageEntry: Promise<OutgoingBidiMessage
|
|
36
|
+
emitOutgoingMessage(messageEntry: Promise<Result<OutgoingBidiMessage>>): void;
|
|
37
37
|
close(): void;
|
|
38
38
|
getBrowsingContextStorage(): BrowsingContextStorage;
|
|
39
39
|
}
|
|
@@ -29,7 +29,6 @@ class BidiServer extends EventEmitter_js_1.EventEmitter {
|
|
|
29
29
|
#transport;
|
|
30
30
|
#commandProcessor;
|
|
31
31
|
#browsingContextStorage = new browsingContextStorage_js_1.BrowsingContextStorage();
|
|
32
|
-
#realmStorage = new realmStorage_js_1.RealmStorage();
|
|
33
32
|
#logger;
|
|
34
33
|
#handleIncomingMessage = (message) => {
|
|
35
34
|
void this.#commandProcessor.processCommand(message).catch((error) => {
|
|
@@ -49,7 +48,7 @@ class BidiServer extends EventEmitter_js_1.EventEmitter {
|
|
|
49
48
|
this.#messageQueue = new processingQueue_js_1.ProcessingQueue(this.#processOutgoingMessage, this.#logger);
|
|
50
49
|
this.#transport = bidiTransport;
|
|
51
50
|
this.#transport.setOnMessage(this.#handleIncomingMessage);
|
|
52
|
-
this.#commandProcessor = new CommandProcessor_js_1.CommandProcessor(cdpConnection, new EventManager_js_1.EventManager(this), selfTargetId,
|
|
51
|
+
this.#commandProcessor = new CommandProcessor_js_1.CommandProcessor(cdpConnection, new EventManager_js_1.EventManager(this), selfTargetId, this.#browsingContextStorage, new realmStorage_js_1.RealmStorage(), parser, this.#logger);
|
|
53
52
|
this.#commandProcessor.on('response', (response) => {
|
|
54
53
|
this.emitOutgoingMessage(response);
|
|
55
54
|
});
|
|
@@ -65,14 +64,9 @@ class BidiServer extends EventEmitter_js_1.EventEmitter {
|
|
|
65
64
|
waitForDebuggerOnStart: true,
|
|
66
65
|
flatten: true,
|
|
67
66
|
});
|
|
68
|
-
await server
|
|
67
|
+
await server.#topLevelContextsLoaded();
|
|
69
68
|
return server;
|
|
70
69
|
}
|
|
71
|
-
async topLevelContextsLoaded() {
|
|
72
|
-
await Promise.all(this.#browsingContextStorage
|
|
73
|
-
.getTopLevelContexts()
|
|
74
|
-
.map((c) => c.awaitLoaded()));
|
|
75
|
-
}
|
|
76
70
|
/**
|
|
77
71
|
* Sends BiDi message.
|
|
78
72
|
*/
|
|
@@ -85,6 +79,11 @@ class BidiServer extends EventEmitter_js_1.EventEmitter {
|
|
|
85
79
|
getBrowsingContextStorage() {
|
|
86
80
|
return this.#browsingContextStorage;
|
|
87
81
|
}
|
|
82
|
+
async #topLevelContextsLoaded() {
|
|
83
|
+
await Promise.all(this.#browsingContextStorage
|
|
84
|
+
.getTopLevelContexts()
|
|
85
|
+
.map((c) => c.lifecycleLoaded()));
|
|
86
|
+
}
|
|
88
87
|
}
|
|
89
88
|
exports.BidiServer = BidiServer;
|
|
90
89
|
//# sourceMappingURL=BidiServer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BidiServer.js","sourceRoot":"","sources":["../../../src/bidiMapper/BidiServer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAIH,8DAAsD;AACtD,4CAAuD;AACvD,oEAA4D;
|
|
1
|
+
{"version":3,"file":"BidiServer.js","sourceRoot":"","sources":["../../../src/bidiMapper/BidiServer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAIH,8DAAsD;AACtD,4CAAuD;AACvD,oEAA4D;AAK5D,+DAAuD;AAEvD,2FAAmF;AACnF,sEAA8D;AAC9D,sEAA8D;AAM9D,MAAa,UAAW,SAAQ,8BAA6B;IAC3D,aAAa,CAAuC;IACpD,UAAU,CAAiB;IAC3B,iBAAiB,CAAmB;IACpC,uBAAuB,GAAG,IAAI,kDAAsB,EAAE,CAAC;IACvD,OAAO,CAAY;IAEnB,sBAAsB,GAAG,CAAC,OAA6B,EAAE,EAAE;QACzD,KAAK,IAAI,CAA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CAAC;IAED,MAAM,CAAC,KAAK,CAAC,cAAc,CACzB,aAA6B,EAC7B,aAA6B,EAC7B,YAAoB,EACpB,MAAoB,EACpB,MAAiB;QAEjB,MAAM,MAAM,GAAG,IAAI,UAAU,CAC3B,aAAa,EACb,aAAa,EACb,YAAY,EACZ,MAAM,EACN,MAAM,CACP,CAAC;QACF,MAAM,SAAS,GAAG,aAAa,CAAC,aAAa,EAAE,CAAC;QAEhD,0CAA0C;QAC1C,MAAM,SAAS,CAAC,WAAW,CAAC,2BAA2B,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;QAE3E,iDAAiD;QACjD,MAAM,SAAS,CAAC,WAAW,CAAC,sBAAsB,EAAE;YAClD,UAAU,EAAE,IAAI;YAChB,sBAAsB,EAAE,IAAI;YAC5B,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,uBAAuB,EAAE,CAAC;QACvC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,mBAAmB,CACjB,YAAkD;QAElD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED,yBAAyB;QACvB,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,uBAAuB;QAC3B,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,uBAAuB;aACzB,mBAAmB,EAAE;aACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CACnC,CAAC;IACJ,CAAC;CACF;AA7GD,gCA6GC"}
|
|
@@ -18,17 +18,18 @@ import type { ICdpConnection } from '../cdp/cdpConnection.js';
|
|
|
18
18
|
import { type ChromiumBidi } from '../protocol/protocol.js';
|
|
19
19
|
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
20
20
|
import { type LoggerFn } from '../utils/log.js';
|
|
21
|
+
import type { Result } from '../utils/result.js';
|
|
21
22
|
import type { IBidiParser } from './BidiParser.js';
|
|
22
23
|
import { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
|
|
23
24
|
import type { BrowsingContextStorage } from './domains/context/browsingContextStorage.js';
|
|
24
25
|
import type { IEventManager } from './domains/events/EventManager.js';
|
|
25
26
|
import type { RealmStorage } from './domains/script/realmStorage.js';
|
|
26
27
|
type CommandProcessorEvents = {
|
|
27
|
-
response: Promise<OutgoingBidiMessage
|
|
28
|
+
response: Promise<Result<OutgoingBidiMessage>>;
|
|
28
29
|
};
|
|
29
30
|
export declare class CommandProcessor extends EventEmitter<CommandProcessorEvents> {
|
|
30
31
|
#private;
|
|
31
|
-
constructor(cdpConnection: ICdpConnection, eventManager: IEventManager, selfTargetId: string,
|
|
32
|
+
constructor(cdpConnection: ICdpConnection, eventManager: IEventManager, selfTargetId: string, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, parser?: IBidiParser, logger?: LoggerFn);
|
|
32
33
|
processCommand(command: ChromiumBidi.Command): Promise<void>;
|
|
33
34
|
}
|
|
34
35
|
export {};
|
|
@@ -22,74 +22,74 @@ const EventEmitter_js_1 = require("../utils/EventEmitter.js");
|
|
|
22
22
|
const log_js_1 = require("../utils/log.js");
|
|
23
23
|
const BidiNoOpParser_js_1 = require("./BidiNoOpParser.js");
|
|
24
24
|
const OutgoingBidiMessage_js_1 = require("./OutgoingBidiMessage.js");
|
|
25
|
+
const BrowserProcessor_js_1 = require("./domains/browser/BrowserProcessor.js");
|
|
26
|
+
const CdpProcessor_js_1 = require("./domains/cdp/CdpProcessor.js");
|
|
25
27
|
const browsingContextProcessor_js_1 = require("./domains/context/browsingContextProcessor.js");
|
|
26
28
|
const InputProcessor_js_1 = require("./domains/input/InputProcessor.js");
|
|
27
29
|
const PreloadScriptStorage_js_1 = require("./domains/script/PreloadScriptStorage.js");
|
|
28
30
|
const ScriptProcessor_js_1 = require("./domains/script/ScriptProcessor.js");
|
|
31
|
+
const SessionProcessor_js_1 = require("./domains/session/SessionProcessor.js");
|
|
29
32
|
class CommandProcessor extends EventEmitter_js_1.EventEmitter {
|
|
33
|
+
#browserProcessor;
|
|
30
34
|
#browsingContextProcessor;
|
|
31
35
|
#inputProcessor;
|
|
32
36
|
#scriptProcessor;
|
|
33
|
-
#
|
|
37
|
+
#sessionProcessor;
|
|
38
|
+
#cdpProcessor;
|
|
34
39
|
#parser;
|
|
35
40
|
#logger;
|
|
36
|
-
constructor(cdpConnection, eventManager, selfTargetId, parser = new BidiNoOpParser_js_1.BidiNoOpParser(),
|
|
41
|
+
constructor(cdpConnection, eventManager, selfTargetId, browsingContextStorage, realmStorage, parser = new BidiNoOpParser_js_1.BidiNoOpParser(), logger) {
|
|
37
42
|
super();
|
|
38
|
-
this.#eventManager = eventManager;
|
|
39
43
|
this.#parser = parser;
|
|
40
44
|
this.#logger = logger;
|
|
41
45
|
const preloadScriptStorage = new PreloadScriptStorage_js_1.PreloadScriptStorage();
|
|
46
|
+
this.#browserProcessor = new BrowserProcessor_js_1.BrowserProcessor(cdpConnection);
|
|
42
47
|
this.#browsingContextProcessor = new browsingContextProcessor_js_1.BrowsingContextProcessor(cdpConnection, selfTargetId, eventManager, browsingContextStorage, realmStorage, preloadScriptStorage, logger);
|
|
43
48
|
this.#inputProcessor = InputProcessor_js_1.InputProcessor.create(browsingContextStorage);
|
|
44
49
|
this.#scriptProcessor = new ScriptProcessor_js_1.ScriptProcessor(browsingContextStorage, realmStorage, preloadScriptStorage);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return { ready: false, message: 'already connected' };
|
|
48
|
-
}
|
|
49
|
-
async #process_session_subscribe(params, channel) {
|
|
50
|
-
await this.#eventManager.subscribe(params.events, params.contexts ?? [null], channel);
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
53
|
-
async #process_session_unsubscribe(params, channel) {
|
|
54
|
-
await this.#eventManager.unsubscribe(params.events, params.contexts ?? [null], channel);
|
|
55
|
-
return {};
|
|
50
|
+
this.#sessionProcessor = new SessionProcessor_js_1.SessionProcessor(eventManager);
|
|
51
|
+
this.#cdpProcessor = new CdpProcessor_js_1.CdpProcessor(browsingContextStorage, cdpConnection);
|
|
56
52
|
}
|
|
57
53
|
async #processCommand(command) {
|
|
58
54
|
switch (command.method) {
|
|
59
|
-
case 'browser.close':
|
|
60
55
|
case 'session.end':
|
|
61
56
|
case 'session.new':
|
|
62
57
|
// TODO: Implement.
|
|
63
58
|
break;
|
|
59
|
+
// Browser domain
|
|
60
|
+
// keep-sorted start block=yes
|
|
61
|
+
case 'browser.close':
|
|
62
|
+
return this.#browserProcessor.close();
|
|
63
|
+
// keep-sorted end
|
|
64
64
|
// Browsing Context domain
|
|
65
65
|
// keep-sorted start block=yes
|
|
66
66
|
case 'browsingContext.activate':
|
|
67
|
-
return this.#browsingContextProcessor.
|
|
67
|
+
return this.#browsingContextProcessor.activate(this.#parser.parseActivateParams(command.params));
|
|
68
68
|
case 'browsingContext.captureScreenshot':
|
|
69
|
-
return this.#browsingContextProcessor.
|
|
69
|
+
return this.#browsingContextProcessor.captureScreenshot(this.#parser.parseCaptureScreenshotParams(command.params));
|
|
70
70
|
case 'browsingContext.close':
|
|
71
|
-
return this.#browsingContextProcessor.
|
|
71
|
+
return this.#browsingContextProcessor.close(this.#parser.parseCloseParams(command.params));
|
|
72
72
|
case 'browsingContext.create':
|
|
73
|
-
return this.#browsingContextProcessor.
|
|
73
|
+
return this.#browsingContextProcessor.create(this.#parser.parseCreateParams(command.params));
|
|
74
74
|
case 'browsingContext.getTree':
|
|
75
|
-
return this.#browsingContextProcessor.
|
|
75
|
+
return this.#browsingContextProcessor.getTree(this.#parser.parseGetTreeParams(command.params));
|
|
76
76
|
case 'browsingContext.handleUserPrompt':
|
|
77
|
-
return this.#browsingContextProcessor.
|
|
77
|
+
return this.#browsingContextProcessor.handleUserPrompt(this.#parser.parseHandleUserPromptParams(command.params));
|
|
78
78
|
case 'browsingContext.navigate':
|
|
79
|
-
return this.#browsingContextProcessor.
|
|
79
|
+
return this.#browsingContextProcessor.navigate(this.#parser.parseNavigateParams(command.params));
|
|
80
80
|
case 'browsingContext.print':
|
|
81
|
-
return this.#browsingContextProcessor.
|
|
81
|
+
return this.#browsingContextProcessor.print(this.#parser.parsePrintParams(command.params));
|
|
82
82
|
case 'browsingContext.reload':
|
|
83
|
-
return this.#browsingContextProcessor.
|
|
83
|
+
return this.#browsingContextProcessor.reload(this.#parser.parseReloadParams(command.params));
|
|
84
84
|
case 'browsingContext.setViewport':
|
|
85
|
-
return this.#browsingContextProcessor.
|
|
85
|
+
return this.#browsingContextProcessor.setViewport(this.#parser.parseSetViewportParams(command.params));
|
|
86
86
|
// keep-sorted end
|
|
87
87
|
// CDP domain
|
|
88
88
|
// keep-sorted start block=yes
|
|
89
89
|
case 'cdp.getSession':
|
|
90
|
-
return this.#
|
|
90
|
+
return this.#cdpProcessor.getSession(this.#parser.parseGetSessionParams(command.params));
|
|
91
91
|
case 'cdp.sendCommand':
|
|
92
|
-
return this.#
|
|
92
|
+
return this.#cdpProcessor.sendCommand(this.#parser.parseSendCommandParams(command.params));
|
|
93
93
|
// keep-sorted end
|
|
94
94
|
// Input domain
|
|
95
95
|
// keep-sorted start block=yes
|
|
@@ -116,11 +116,11 @@ class CommandProcessor extends EventEmitter_js_1.EventEmitter {
|
|
|
116
116
|
// Session domain
|
|
117
117
|
// keep-sorted start block=yes
|
|
118
118
|
case 'session.status':
|
|
119
|
-
return
|
|
119
|
+
return this.#sessionProcessor.status();
|
|
120
120
|
case 'session.subscribe':
|
|
121
|
-
return this.#
|
|
121
|
+
return this.#sessionProcessor.subscribe(this.#parser.parseSubscribeParams(command.params), command.channel);
|
|
122
122
|
case 'session.unsubscribe':
|
|
123
|
-
return this.#
|
|
123
|
+
return this.#sessionProcessor.unsubscribe(this.#parser.parseSubscribeParams(command.params), command.channel);
|
|
124
124
|
// keep-sorted end
|
|
125
125
|
}
|
|
126
126
|
// Intentionally kept outside of the switch statement to ensure that
|
|
@@ -136,17 +136,17 @@ class CommandProcessor extends EventEmitter_js_1.EventEmitter {
|
|
|
136
136
|
id: command.id,
|
|
137
137
|
result,
|
|
138
138
|
};
|
|
139
|
-
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(response, command.channel
|
|
139
|
+
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(response, command.channel));
|
|
140
140
|
}
|
|
141
141
|
catch (e) {
|
|
142
142
|
if (e instanceof protocol_js_1.Exception) {
|
|
143
143
|
const errorResponse = e;
|
|
144
|
-
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(errorResponse.toErrorResponse(command.id), command.channel
|
|
144
|
+
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(errorResponse.toErrorResponse(command.id), command.channel));
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
147
|
const error = e;
|
|
148
148
|
this.#logger?.(log_js_1.LogType.bidi, error);
|
|
149
|
-
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(new protocol_js_1.UnknownErrorException(error.message, error.stack).toErrorResponse(command.id), command.channel
|
|
149
|
+
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(new protocol_js_1.UnknownErrorException(error.message, error.stack).toErrorResponse(command.id), command.channel));
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandProcessor.js","sourceRoot":"","sources":["../../../src/bidiMapper/CommandProcessor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAGH,
|
|
1
|
+
{"version":3,"file":"CommandProcessor.js","sourceRoot":"","sources":["../../../src/bidiMapper/CommandProcessor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAGH,yDAKiC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CACF,CAAC;aACH;SACF;IACH,CAAC;CACF;AA7ND,4CA6NC"}
|
|
@@ -15,11 +15,12 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import type { ChromiumBidi } from '../protocol/protocol.js';
|
|
18
|
+
import type { Result } from '../utils/result.js';
|
|
18
19
|
export declare class OutgoingBidiMessage {
|
|
19
20
|
#private;
|
|
20
21
|
private constructor();
|
|
21
|
-
static createFromPromise(messagePromise: Promise<ChromiumBidi.Message
|
|
22
|
-
static createResolved(message: ChromiumBidi.Message, channel
|
|
22
|
+
static createFromPromise(messagePromise: Promise<Result<ChromiumBidi.Message>>, channel: string | null): Promise<Result<OutgoingBidiMessage>>;
|
|
23
|
+
static createResolved(message: ChromiumBidi.Message, channel?: string | null): Promise<Result<OutgoingBidiMessage>>;
|
|
23
24
|
get message(): ChromiumBidi.Message;
|
|
24
25
|
get channel(): string | null;
|
|
25
26
|
}
|
|
@@ -20,15 +20,26 @@ exports.OutgoingBidiMessage = void 0;
|
|
|
20
20
|
class OutgoingBidiMessage {
|
|
21
21
|
#message;
|
|
22
22
|
#channel;
|
|
23
|
-
constructor(message, channel) {
|
|
23
|
+
constructor(message, channel = null) {
|
|
24
24
|
this.#message = message;
|
|
25
25
|
this.#channel = channel;
|
|
26
26
|
}
|
|
27
|
-
static
|
|
28
|
-
return messagePromise.then((message) =>
|
|
27
|
+
static createFromPromise(messagePromise, channel) {
|
|
28
|
+
return messagePromise.then((message) => {
|
|
29
|
+
if (message.kind === 'success') {
|
|
30
|
+
return {
|
|
31
|
+
kind: 'success',
|
|
32
|
+
value: new OutgoingBidiMessage(message.value, channel),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return message;
|
|
36
|
+
});
|
|
29
37
|
}
|
|
30
38
|
static createResolved(message, channel) {
|
|
31
|
-
return Promise.resolve(
|
|
39
|
+
return Promise.resolve({
|
|
40
|
+
kind: 'success',
|
|
41
|
+
value: new OutgoingBidiMessage(message, channel),
|
|
42
|
+
});
|
|
32
43
|
}
|
|
33
44
|
get message() {
|
|
34
45
|
return this.#message;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OutgoingBidiMessage.js","sourceRoot":"","sources":["../../../src/bidiMapper/OutgoingBidiMessage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;
|
|
1
|
+
{"version":3,"file":"OutgoingBidiMessage.js","sourceRoot":"","sources":["../../../src/bidiMapper/OutgoingBidiMessage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAKH,MAAa,mBAAmB;IACrB,QAAQ,CAAuB;IAC/B,QAAQ,CAAgB;IAEjC,YACE,OAA6B,EAC7B,UAAyB,IAAI;QAE7B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,cAAqD,EACrD,OAAsB;QAEtB,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;YACrC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;gBAC9B,OAAO;oBACL,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,IAAI,mBAAmB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC;iBACvD,CAAC;aACH;YACD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,cAAc,CACnB,OAA6B,EAC7B,OAAuB;QAEvB,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,IAAI,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC;SACjD,CAAC,CAAC;IACL,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AA5CD,kDA4CC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 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 { EmptyResult } from '../../../protocol/protocol.js';
|
|
18
|
+
import type { ICdpConnection } from '../../bidiMapper';
|
|
19
|
+
export declare class BrowserProcessor {
|
|
20
|
+
#private;
|
|
21
|
+
constructor(cdpConnection: ICdpConnection);
|
|
22
|
+
close(): EmptyResult;
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023 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.BrowserProcessor = void 0;
|
|
20
|
+
class BrowserProcessor {
|
|
21
|
+
#cdpConnection;
|
|
22
|
+
constructor(cdpConnection) {
|
|
23
|
+
this.#cdpConnection = cdpConnection;
|
|
24
|
+
}
|
|
25
|
+
close() {
|
|
26
|
+
const client = this.#cdpConnection.browserClient();
|
|
27
|
+
// Insure that its put at the last place in the event loop
|
|
28
|
+
// That way we send back the response before closing in tab
|
|
29
|
+
setTimeout(() => client.sendCommand('Browser.close'), 0);
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.BrowserProcessor = BrowserProcessor;
|
|
34
|
+
//# sourceMappingURL=BrowserProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserProcessor.js","sourceRoot":"","sources":["../../../../../src/bidiMapper/domains/browser/BrowserProcessor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAKH,MAAa,gBAAgB;IAC3B,cAAc,CAAiB;IAE/B,YAAY,aAA6B;QACvC,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED,KAAK;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;QAEnD,0DAA0D;QAC1D,2DAA2D;QAC3D,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QAEzD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAhBD,4CAgBC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 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 { Cdp } from '../../../protocol/protocol.js';
|
|
18
|
+
import type { ICdpConnection } from '../../bidiMapper.js';
|
|
19
|
+
import type { BrowsingContextStorage } from '../context/browsingContextStorage.js';
|
|
20
|
+
export declare class CdpProcessor {
|
|
21
|
+
#private;
|
|
22
|
+
constructor(browsingContextStorage: BrowsingContextStorage, cdpConnection: ICdpConnection);
|
|
23
|
+
getSession(params: Cdp.GetSessionParameters): Cdp.GetSessionResult;
|
|
24
|
+
sendCommand(params: Cdp.SendCommandParameters): Promise<Cdp.SendCommandResult>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2023 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.CdpProcessor = void 0;
|
|
20
|
+
class CdpProcessor {
|
|
21
|
+
#browsingContextStorage;
|
|
22
|
+
#cdpConnection;
|
|
23
|
+
constructor(browsingContextStorage, cdpConnection) {
|
|
24
|
+
this.#browsingContextStorage = browsingContextStorage;
|
|
25
|
+
this.#cdpConnection = cdpConnection;
|
|
26
|
+
}
|
|
27
|
+
getSession(params) {
|
|
28
|
+
const context = params.context;
|
|
29
|
+
const sessionId = this.#browsingContextStorage.getContext(context).cdpTarget.cdpSessionId;
|
|
30
|
+
if (sessionId === undefined) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
return { session: sessionId };
|
|
34
|
+
}
|
|
35
|
+
async sendCommand(params) {
|
|
36
|
+
const client = params.session
|
|
37
|
+
? this.#cdpConnection.getCdpClient(params.session)
|
|
38
|
+
: this.#cdpConnection.browserClient();
|
|
39
|
+
const result = await client.sendCommand(params.method, params.params);
|
|
40
|
+
return {
|
|
41
|
+
result,
|
|
42
|
+
session: params.session,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CdpProcessor = CdpProcessor;
|
|
47
|
+
//# sourceMappingURL=CdpProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CdpProcessor.js","sourceRoot":"","sources":["../../../../../src/bidiMapper/domains/cdp/CdpProcessor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAMH,MAAa,YAAY;IACvB,uBAAuB,CAAyB;IAChD,cAAc,CAAiB;IAE/B,YACE,sBAA8C,EAC9C,aAA6B;QAE7B,IAAI,CAAC,uBAAuB,GAAG,sBAAsB,CAAC;QACtD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;IACtC,CAAC;IAED,UAAU,CAAC,MAAgC;QACzC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC/B,MAAM,SAAS,GACb,IAAI,CAAC,uBAAuB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC;QAC1E,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,OAAO,EAAE,CAAC;SACX;QACD,OAAO,EAAC,OAAO,EAAE,SAAS,EAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,WAAW,CACf,MAAiC;QAEjC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO;YAC3B,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC;YAClD,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACtE,OAAO;YACL,MAAM;YACN,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;IACJ,CAAC;CACF;AAlCD,oCAkCC"}
|
|
@@ -20,6 +20,7 @@ import { type LoggerFn } from '../../../utils/log.js';
|
|
|
20
20
|
import type { IEventManager } from '../events/EventManager.js';
|
|
21
21
|
import { Realm } from '../script/realm.js';
|
|
22
22
|
import type { RealmStorage } from '../script/realmStorage.js';
|
|
23
|
+
import type { Result } from '../../../utils/result.js';
|
|
23
24
|
import type { BrowsingContextStorage } from './browsingContextStorage.js';
|
|
24
25
|
import type { CdpTarget } from './cdpTarget.js';
|
|
25
26
|
export declare class BrowsingContextImpl {
|
|
@@ -52,8 +53,8 @@ export declare class BrowsingContextImpl {
|
|
|
52
53
|
get cdpTarget(): CdpTarget;
|
|
53
54
|
updateCdpTarget(cdpTarget: CdpTarget): void;
|
|
54
55
|
get url(): string;
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
lifecycleLoaded(): Promise<void>;
|
|
57
|
+
targetUnblocked(): Promise<Result<void>>;
|
|
57
58
|
getOrCreateSandbox(sandbox: string | undefined): Promise<Realm>;
|
|
58
59
|
serializeToBidiValue(maxDepth?: number, addParentField?: boolean): BrowsingContext.Info;
|
|
59
60
|
onTargetInfoChanged(params: Protocol.Target.TargetInfoChangedEvent): void;
|
|
@@ -34,7 +34,6 @@ class BrowsingContextImpl {
|
|
|
34
34
|
#children = new Set();
|
|
35
35
|
#browsingContextStorage;
|
|
36
36
|
#deferreds = {
|
|
37
|
-
documentInitialized: new deferred_js_1.Deferred(),
|
|
38
37
|
Page: {
|
|
39
38
|
navigatedWithinDocument: new deferred_js_1.Deferred(),
|
|
40
39
|
lifecycleEvent: {
|
|
@@ -165,10 +164,10 @@ class BrowsingContextImpl {
|
|
|
165
164
|
get url() {
|
|
166
165
|
return this.#url;
|
|
167
166
|
}
|
|
168
|
-
async
|
|
167
|
+
async lifecycleLoaded() {
|
|
169
168
|
await this.#deferreds.Page.lifecycleEvent.load;
|
|
170
169
|
}
|
|
171
|
-
|
|
170
|
+
targetUnblocked() {
|
|
172
171
|
return this.#cdpTarget.targetUnblocked;
|
|
173
172
|
}
|
|
174
173
|
async getOrCreateSandbox(sandbox) {
|
|
@@ -259,7 +258,6 @@ class BrowsingContextImpl {
|
|
|
259
258
|
}
|
|
260
259
|
if (params.name === 'init') {
|
|
261
260
|
this.#documentChanged(params.loaderId);
|
|
262
|
-
this.#deferreds.documentInitialized.resolve();
|
|
263
261
|
return;
|
|
264
262
|
}
|
|
265
263
|
if (params.name === 'commit') {
|
|
@@ -273,7 +271,6 @@ class BrowsingContextImpl {
|
|
|
273
271
|
const timestamp = BrowsingContextImpl.getTimestamp();
|
|
274
272
|
switch (params.name) {
|
|
275
273
|
case 'DOMContentLoaded':
|
|
276
|
-
this.#deferreds.Page.lifecycleEvent.DOMContentLoaded.resolve(params);
|
|
277
274
|
this.#eventManager.registerEvent({
|
|
278
275
|
type: 'event',
|
|
279
276
|
method: protocol_js_1.ChromiumBidi.BrowsingContext.EventNames.DomContentLoadedEvent,
|
|
@@ -284,9 +281,9 @@ class BrowsingContextImpl {
|
|
|
284
281
|
url: this.#url,
|
|
285
282
|
},
|
|
286
283
|
}, this.id);
|
|
284
|
+
this.#deferreds.Page.lifecycleEvent.DOMContentLoaded.resolve(params);
|
|
287
285
|
break;
|
|
288
286
|
case 'load':
|
|
289
|
-
this.#deferreds.Page.lifecycleEvent.load.resolve(params);
|
|
290
287
|
this.#eventManager.registerEvent({
|
|
291
288
|
type: 'event',
|
|
292
289
|
method: protocol_js_1.ChromiumBidi.BrowsingContext.EventNames.LoadEvent,
|
|
@@ -297,6 +294,7 @@ class BrowsingContextImpl {
|
|
|
297
294
|
url: this.#url,
|
|
298
295
|
},
|
|
299
296
|
}, this.id);
|
|
297
|
+
this.#deferreds.Page.lifecycleEvent.load.resolve(params);
|
|
300
298
|
break;
|
|
301
299
|
}
|
|
302
300
|
});
|
|
@@ -387,12 +385,6 @@ class BrowsingContextImpl {
|
|
|
387
385
|
this.#loaderId = loaderId;
|
|
388
386
|
}
|
|
389
387
|
#resetDeferredsIfFinished() {
|
|
390
|
-
if (this.#deferreds.documentInitialized.isFinished) {
|
|
391
|
-
this.#deferreds.documentInitialized = new deferred_js_1.Deferred();
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
394
|
-
this.#logger?.(log_js_1.LogType.browsingContexts, 'Document changed (document initialized)');
|
|
395
|
-
}
|
|
396
388
|
if (this.#deferreds.Page.lifecycleEvent.DOMContentLoaded.isFinished) {
|
|
397
389
|
this.#deferreds.Page.lifecycleEvent.DOMContentLoaded =
|
|
398
390
|
new deferred_js_1.Deferred();
|
|
@@ -415,7 +407,7 @@ class BrowsingContextImpl {
|
|
|
415
407
|
catch {
|
|
416
408
|
throw new protocol_js_1.InvalidArgumentException(`Invalid URL: ${url}`);
|
|
417
409
|
}
|
|
418
|
-
await this.
|
|
410
|
+
await this.targetUnblocked();
|
|
419
411
|
// TODO: handle loading errors.
|
|
420
412
|
const cdpNavigateResult = await this.#cdpTarget.cdpClient.sendCommand('Page.navigate', {
|
|
421
413
|
url,
|
|
@@ -443,7 +435,7 @@ class BrowsingContextImpl {
|
|
|
443
435
|
await this.#deferreds.Page.navigatedWithinDocument;
|
|
444
436
|
}
|
|
445
437
|
else {
|
|
446
|
-
await this.
|
|
438
|
+
await this.lifecycleLoaded();
|
|
447
439
|
}
|
|
448
440
|
break;
|
|
449
441
|
}
|
|
@@ -453,7 +445,7 @@ class BrowsingContextImpl {
|
|
|
453
445
|
};
|
|
454
446
|
}
|
|
455
447
|
async reload(ignoreCache, wait) {
|
|
456
|
-
await this.
|
|
448
|
+
await this.targetUnblocked();
|
|
457
449
|
await this.#cdpTarget.cdpClient.sendCommand('Page.reload', {
|
|
458
450
|
ignoreCache,
|
|
459
451
|
});
|
|
@@ -465,7 +457,7 @@ class BrowsingContextImpl {
|
|
|
465
457
|
await this.#deferreds.Page.lifecycleEvent.DOMContentLoaded;
|
|
466
458
|
break;
|
|
467
459
|
case "complete" /* BrowsingContext.ReadinessState.Complete */:
|
|
468
|
-
await this.
|
|
460
|
+
await this.lifecycleLoaded();
|
|
469
461
|
break;
|
|
470
462
|
}
|
|
471
463
|
return {};
|