Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement readonly capabilities #2070

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/bidiMapper/CommandProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
preloadScriptStorage,
logger
);
this.#sessionProcessor = new SessionProcessor(eventManager);
this.#sessionProcessor = new SessionProcessor(
eventManager,
browserCdpClient
);
this.#storageProcessor = new StorageProcessor(
browserCdpClient,
browsingContextStorage,
Expand All @@ -147,7 +150,6 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {
): Promise<ChromiumBidi.ResultData> {
switch (command.method) {
case 'session.end':
case 'session.new':
// TODO: Implement.
break;

Expand Down Expand Up @@ -325,6 +327,8 @@ export class CommandProcessor extends EventEmitter<CommandProcessorEventsMap> {

// Session domain
// keep-sorted start block=yes
case 'session.new':
return await this.#sessionProcessor.create(command.params);
case 'session.status':
return this.#sessionProcessor.status();
case 'session.subscribe':
Expand Down
26 changes: 25 additions & 1 deletion src/bidiMapper/domains/session/SessionProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

import type {CdpClient} from '../../../cdp/CdpClient.js';
import type {BidiPlusChannel} from '../../../protocol/chromium-bidi.js';
import type {
ChromiumBidi,
Expand All @@ -26,15 +27,38 @@ import type {EventManager} from './EventManager.js';

export class SessionProcessor {
#eventManager: EventManager;
#browserCdpClient: CdpClient;

constructor(eventManager: EventManager) {
constructor(eventManager: EventManager, browserCdpClient: CdpClient) {
this.#eventManager = eventManager;
this.#browserCdpClient = browserCdpClient;
}

status(): Session.StatusResult {
return {ready: false, message: 'already connected'};
}

async create(_params: Session.NewParameters): Promise<Session.NewResult> {
// Since mapper exists, there is a session already.
// Still the mapper can handle capabilities for us.
// Currently, only Puppeteer calls here but, eventually, every client
// should delegrate capability processing here.
const version =
await this.#browserCdpClient.sendCommand('Browser.getVersion');
return {
sessionId: 'unknown',
capabilities: {
acceptInsecureCerts: false,
OrKoN marked this conversation as resolved.
Show resolved Hide resolved
browserName: version.product,
browserVersion: version.revision,
platformName: '',
setWindowRect: false,
webSocketUrl: '',
userAgent: version.userAgent,
},
};
}

async subscribe(
params: Session.SubscriptionRequest,
channel: BidiPlusChannel = null
Expand Down
Loading