address comments
This commit is contained in:
parent
dbd8756a68
commit
3a0df6a945
|
|
@ -46,7 +46,7 @@ export class Playwright extends ChannelOwner<channels.PlaywrightChannel> {
|
||||||
this.webkit._playwright = this;
|
this.webkit._playwright = this;
|
||||||
this._android = Android.from(initializer.android);
|
this._android = Android.from(initializer.android);
|
||||||
this._electron = Electron.from(initializer.electron);
|
this._electron = Electron.from(initializer.electron);
|
||||||
this._experimentalBidiFirefox = BrowserType.from(initializer.bidiFirefox);
|
this._experimentalBidiFirefox = BrowserType.from(initializer.bidi);
|
||||||
this._experimentalBidiFirefox._playwright = this;
|
this._experimentalBidiFirefox._playwright = this;
|
||||||
this.devices = this._connection.localUtils()?.devices ?? {};
|
this.devices = this._connection.localUtils()?.devices ?? {};
|
||||||
this.selectors = new Selectors();
|
this.selectors = new Selectors();
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ scheme.RootInitializeResult = tObject({
|
||||||
});
|
});
|
||||||
scheme.PlaywrightInitializer = tObject({
|
scheme.PlaywrightInitializer = tObject({
|
||||||
chromium: tChannel(['BrowserType']),
|
chromium: tChannel(['BrowserType']),
|
||||||
bidiFirefox: tChannel(['BrowserType']),
|
bidi: tChannel(['BrowserType']),
|
||||||
firefox: tChannel(['BrowserType']),
|
firefox: tChannel(['BrowserType']),
|
||||||
webkit: tChannel(['BrowserType']),
|
webkit: tChannel(['BrowserType']),
|
||||||
android: tChannel(['Android']),
|
android: tChannel(['Android']),
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import { kBrowserCloseMessageId } from './bidiConnection';
|
||||||
|
|
||||||
export class BidiFirefox extends BrowserType {
|
export class BidiFirefox extends BrowserType {
|
||||||
constructor(parent: SdkObject) {
|
constructor(parent: SdkObject) {
|
||||||
super(parent, 'bidi-firefox');
|
super(parent, 'firefox');
|
||||||
this._useBidi = true;
|
this._useBidi = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ export class BidiPage implements PageDelegate {
|
||||||
readonly rawKeyboard: RawKeyboardImpl;
|
readonly rawKeyboard: RawKeyboardImpl;
|
||||||
readonly rawTouchscreen: RawTouchscreenImpl;
|
readonly rawTouchscreen: RawTouchscreenImpl;
|
||||||
readonly _page: Page;
|
readonly _page: Page;
|
||||||
// private readonly _pagePromise = new ManualPromise<Page | Error>();
|
|
||||||
private readonly _pagePromise: Promise<Page | Error>;
|
private readonly _pagePromise: Promise<Page | Error>;
|
||||||
readonly _session: BidiSession;
|
readonly _session: BidiSession;
|
||||||
readonly _opener: BidiPage | null;
|
readonly _opener: BidiPage | null;
|
||||||
|
|
@ -98,7 +97,6 @@ export class BidiPage implements PageDelegate {
|
||||||
|
|
||||||
private _handleFrameTree(frameTree: bidi.BrowsingContext.Info) {
|
private _handleFrameTree(frameTree: bidi.BrowsingContext.Info) {
|
||||||
this._onFrameAttached(frameTree.context, frameTree.parent || null);
|
this._onFrameAttached(frameTree.context, frameTree.parent || null);
|
||||||
// this._onFrameNavigated(frameTree.context, true);
|
|
||||||
if (!frameTree.children)
|
if (!frameTree.children)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -144,17 +142,18 @@ export class BidiPage implements PageDelegate {
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return;
|
return;
|
||||||
const delegate = new BidiExecutionContext(this._session, realmInfo);
|
const delegate = new BidiExecutionContext(this._session, realmInfo);
|
||||||
let worldName: types.World|null = null;
|
let worldName: types.World;
|
||||||
if (!realmInfo.sandbox) {
|
if (!realmInfo.sandbox) {
|
||||||
worldName = 'main';
|
worldName = 'main';
|
||||||
// Force creating utility world every time the main world is created (e.g. due to navigation).
|
// Force creating utility world every time the main world is created (e.g. due to navigation).
|
||||||
this._touchUtilityWorld(realmInfo.context);
|
this._touchUtilityWorld(realmInfo.context);
|
||||||
} else if (realmInfo.sandbox === UTILITY_WORLD_NAME) {
|
} else if (realmInfo.sandbox === UTILITY_WORLD_NAME) {
|
||||||
worldName = 'utility';
|
worldName = 'utility';
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
||||||
(context as any)[contextDelegateSymbol] = delegate;
|
(context as any)[contextDelegateSymbol] = delegate;
|
||||||
if (worldName)
|
|
||||||
frame._contextCreated(worldName, context);
|
frame._contextCreated(worldName, context);
|
||||||
this._realmToContext.set(realmInfo.realm, context);
|
this._realmToContext.set(realmInfo.realm, context);
|
||||||
}
|
}
|
||||||
|
|
@ -426,7 +425,7 @@ export class BidiPage implements PageDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
rafCountForStablePosition(): number {
|
rafCountForStablePosition(): number {
|
||||||
return process.platform === 'win32' ? 5 : 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getContentQuads(handle: dom.ElementHandle<Element>): Promise<types.Quad[] | null | 'error:notconnected'> {
|
async getContentQuads(handle: dom.ElementHandle<Element>): Promise<types.Quad[] | null | 'error:notconnected'> {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ export class PlaywrightDispatcher extends Dispatcher<Playwright, channels.Playwr
|
||||||
const prelaunchedAndroidDeviceDispatcher = prelaunchedAndroidDevice ? new AndroidDeviceDispatcher(android, prelaunchedAndroidDevice) : undefined;
|
const prelaunchedAndroidDeviceDispatcher = prelaunchedAndroidDevice ? new AndroidDeviceDispatcher(android, prelaunchedAndroidDevice) : undefined;
|
||||||
super(scope, playwright, 'Playwright', {
|
super(scope, playwright, 'Playwright', {
|
||||||
chromium: new BrowserTypeDispatcher(scope, playwright.chromium),
|
chromium: new BrowserTypeDispatcher(scope, playwright.chromium),
|
||||||
bidiFirefox: new BrowserTypeDispatcher(scope, playwright.bidiFirefox),
|
bidi: new BrowserTypeDispatcher(scope, playwright.bidi),
|
||||||
firefox: new BrowserTypeDispatcher(scope, playwright.firefox),
|
firefox: new BrowserTypeDispatcher(scope, playwright.firefox),
|
||||||
webkit: new BrowserTypeDispatcher(scope, playwright.webkit),
|
webkit: new BrowserTypeDispatcher(scope, playwright.webkit),
|
||||||
android,
|
android,
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,7 @@ export class Request extends SdkObject {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(bidi): remove once post body is available.
|
||||||
_setBodySize(size: number) {
|
_setBodySize(size: number) {
|
||||||
this._bodySize = size;
|
this._bodySize = size;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export class Playwright extends SdkObject {
|
||||||
readonly chromium: BrowserType;
|
readonly chromium: BrowserType;
|
||||||
readonly android: Android;
|
readonly android: Android;
|
||||||
readonly electron: Electron;
|
readonly electron: Electron;
|
||||||
readonly bidiFirefox;
|
readonly bidi;
|
||||||
readonly firefox: BrowserType;
|
readonly firefox: BrowserType;
|
||||||
readonly webkit: BrowserType;
|
readonly webkit: BrowserType;
|
||||||
readonly options: PlaywrightOptions;
|
readonly options: PlaywrightOptions;
|
||||||
|
|
@ -64,7 +64,7 @@ export class Playwright extends SdkObject {
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
this.chromium = new Chromium(this);
|
this.chromium = new Chromium(this);
|
||||||
this.bidiFirefox = new BidiFirefox(this);
|
this.bidi = new BidiFirefox(this);
|
||||||
this.firefox = new Firefox(this);
|
this.firefox = new Firefox(this);
|
||||||
this.webkit = new WebKit(this);
|
this.webkit = new WebKit(this);
|
||||||
this.electron = new Electron(this);
|
this.electron = new Electron(this);
|
||||||
|
|
|
||||||
|
|
@ -382,8 +382,8 @@ function readDescriptors(browsersJSON: BrowsersJSON) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BrowserName = 'chromium' | 'firefox' | 'webkit' | 'bidi-firefox';
|
export type BrowserName = 'chromium' | 'firefox' | 'webkit';
|
||||||
type InternalTool = 'ffmpeg' | 'firefox-beta' | 'chromium-tip-of-tree' | 'android';
|
type InternalTool = 'ffmpeg' | 'firefox-beta' | 'chromium-tip-of-tree' | 'android' | 'bidi-firefox';
|
||||||
type BidiFirefoxChannel = 'bidi-firefox-stable';
|
type BidiFirefoxChannel = 'bidi-firefox-stable';
|
||||||
type ChromiumChannel = 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary';
|
type ChromiumChannel = 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary';
|
||||||
const allDownloadable = ['chromium', 'firefox', 'webkit', 'ffmpeg', 'firefox-beta', 'chromium-tip-of-tree'];
|
const allDownloadable = ['chromium', 'firefox', 'webkit', 'ffmpeg', 'firefox-beta', 'chromium-tip-of-tree'];
|
||||||
|
|
@ -662,12 +662,12 @@ export class Registry {
|
||||||
this._executables.push({
|
this._executables.push({
|
||||||
type: 'browser',
|
type: 'browser',
|
||||||
name: 'bidi-firefox',
|
name: 'bidi-firefox',
|
||||||
browserName: 'bidi-firefox',
|
browserName: 'firefox',
|
||||||
directory: bidiFirefox.dir,
|
directory: bidiFirefox.dir,
|
||||||
executablePath: () => bidiFirefoxExecutable,
|
executablePath: () => bidiFirefoxExecutable,
|
||||||
executablePathOrDie: (sdkLanguage: string) => executablePathOrDie('bidi-firefox', bidiFirefoxExecutable, bidiFirefox.installByDefault, sdkLanguage),
|
executablePathOrDie: (sdkLanguage: string) => executablePathOrDie('bidi-firefox', bidiFirefoxExecutable, bidiFirefox.installByDefault, sdkLanguage),
|
||||||
installType: bidiFirefox.installByDefault ? 'download-by-default' : 'download-on-demand',
|
installType: bidiFirefox.installByDefault ? 'download-by-default' : 'download-on-demand',
|
||||||
_validateHostRequirements: (sdkLanguage: string) => this._validateHostRequirements(sdkLanguage, 'bidi-firefox', bidiFirefox.dir, ['firefox'], [], ['firefox']),
|
_validateHostRequirements: (sdkLanguage: string) => this._validateHostRequirements(sdkLanguage, 'firefox', bidiFirefox.dir, ['firefox'], [], ['firefox']),
|
||||||
downloadURLs: this._downloadURLs(bidiFirefox),
|
downloadURLs: this._downloadURLs(bidiFirefox),
|
||||||
browserVersion: bidiFirefox.browserVersion,
|
browserVersion: bidiFirefox.browserVersion,
|
||||||
_install: () => this._downloadExecutable(bidiFirefox, bidiFirefoxExecutable),
|
_install: () => this._downloadExecutable(bidiFirefox, bidiFirefoxExecutable),
|
||||||
|
|
@ -741,7 +741,7 @@ export class Registry {
|
||||||
return {
|
return {
|
||||||
type: 'channel',
|
type: 'channel',
|
||||||
name,
|
name,
|
||||||
browserName: 'bidi-firefox',
|
browserName: 'firefox',
|
||||||
directory: undefined,
|
directory: undefined,
|
||||||
executablePath: (sdkLanguage: string) => executablePath(sdkLanguage, false),
|
executablePath: (sdkLanguage: string) => executablePath(sdkLanguage, false),
|
||||||
executablePathOrDie: (sdkLanguage: string) => executablePath(sdkLanguage, true)!,
|
executablePathOrDie: (sdkLanguage: string) => executablePath(sdkLanguage, true)!,
|
||||||
|
|
|
||||||
|
|
@ -560,7 +560,7 @@ export interface RootEvents {
|
||||||
// ----------- Playwright -----------
|
// ----------- Playwright -----------
|
||||||
export type PlaywrightInitializer = {
|
export type PlaywrightInitializer = {
|
||||||
chromium: BrowserTypeChannel,
|
chromium: BrowserTypeChannel,
|
||||||
bidiFirefox: BrowserTypeChannel,
|
bidi: BrowserTypeChannel,
|
||||||
firefox: BrowserTypeChannel,
|
firefox: BrowserTypeChannel,
|
||||||
webkit: BrowserTypeChannel,
|
webkit: BrowserTypeChannel,
|
||||||
android: AndroidChannel,
|
android: AndroidChannel,
|
||||||
|
|
|
||||||
|
|
@ -668,7 +668,7 @@ Playwright:
|
||||||
|
|
||||||
initializer:
|
initializer:
|
||||||
chromium: BrowserType
|
chromium: BrowserType
|
||||||
bidiFirefox: BrowserType
|
bidi: BrowserType
|
||||||
firefox: BrowserType
|
firefox: BrowserType
|
||||||
webkit: BrowserType
|
webkit: BrowserType
|
||||||
android: Android
|
android: Android
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,6 @@
|
||||||
import { kTargetClosedErrorMessage } from '../config/errors';
|
import { kTargetClosedErrorMessage } from '../config/errors';
|
||||||
import { browserTest as test, expect } from '../config/browserTest';
|
import { browserTest as test, expect } from '../config/browserTest';
|
||||||
|
|
||||||
|
|
||||||
test('create 2 pages', async ({ browser, browserType }) => {
|
|
||||||
const context = await browser.newContext();
|
|
||||||
const page = await context.newPage();
|
|
||||||
await page.close();
|
|
||||||
await context.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return browserType', function({ browser, browserType }) {
|
test('should return browserType', function({ browser, browserType }) {
|
||||||
expect(browser.browserType()).toBe(browserType);
|
expect(browser.browserType()).toBe(browserType);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue