mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00

This patch: 1. Changes `SimpleChannel` to buffer messages to the namespace that hasn't been registered yet. This allows us to create `SimpleChannel` per target on the browser side right away. 2. Removes multisession support. Now there's only one `PageAgent` in the content process, which talks to a single `PageHandler` on the browser side. Both ends can be created as-soon-as-needed; thanks to `SimpleChannel` bufferring, no messages will be lost and all messages will be delivered in proper order. (This is currently the reason why build 1178 flakes on windows). 3. Straightens up the target reporting. Targets are reported as soon as they appear on the browser side. **NOTE:** this doesn't yet remove sessions from protocol. References #3995
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
const {Helper} = ChromeUtils.import('chrome://juggler/content/Helper.js');
|
|
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|
|
|
const Cc = Components.classes;
|
|
const Ci = Components.interfaces;
|
|
const Cu = Components.utils;
|
|
const helper = new Helper();
|
|
|
|
class RuntimeHandler {
|
|
constructor(session, contentChannel) {
|
|
this._contentRuntime = contentChannel.connect('runtime');
|
|
|
|
const emitProtocolEvent = eventName => {
|
|
return (...args) => session.emitEvent(eventName, ...args);
|
|
}
|
|
|
|
this._eventListeners = [
|
|
contentChannel.register('runtime', {
|
|
runtimeConsole: emitProtocolEvent('Runtime.console'),
|
|
runtimeExecutionContextCreated: emitProtocolEvent('Runtime.executionContextCreated'),
|
|
runtimeExecutionContextDestroyed: emitProtocolEvent('Runtime.executionContextDestroyed'),
|
|
}),
|
|
];
|
|
}
|
|
|
|
async evaluate(options) {
|
|
return await this._contentRuntime.send('evaluate', options);
|
|
}
|
|
|
|
async callFunction(options) {
|
|
return await this._contentRuntime.send('callFunction', options);
|
|
}
|
|
|
|
async getObjectProperties(options) {
|
|
return await this._contentRuntime.send('getObjectProperties', options);
|
|
}
|
|
|
|
async disposeObject(options) {
|
|
return await this._contentRuntime.send('disposeObject', options);
|
|
}
|
|
|
|
dispose() {
|
|
this._contentRuntime.dispose();
|
|
helper.removeListeners(this._eventListeners);
|
|
}
|
|
}
|
|
|
|
var EXPORTED_SYMBOLS = ['RuntimeHandler'];
|
|
this.RuntimeHandler = RuntimeHandler;
|