chore: revert changes

This commit is contained in:
karishmas6
2024-10-22 15:23:57 +05:30
parent 2e3da36f51
commit 43eaf01137

View File

@@ -30,18 +30,8 @@ export class RemoteBrowser {
*/ */
private browser: Browser | null = null; private browser: Browser | null = null;
/**
* Playwright's [browser context](https://playwright.dev/docs/api/class-browsercontext) instance.
* @private
*/
private context: BrowserContext | null = null; private context: BrowserContext | null = null;
/**
* The viewport size of the browser.
* @private
*/
private viewportSize: { width: number, height: number } = { width: 900, height: 400 };
/** /**
* The Playwright's [CDPSession](https://playwright.dev/docs/api/class-cdpsession) instance, * The Playwright's [CDPSession](https://playwright.dev/docs/api/class-cdpsession) instance,
* used to talk raw Chrome Devtools Protocol. * used to talk raw Chrome Devtools Protocol.
@@ -103,10 +93,10 @@ export class RemoteBrowser {
public initialize = async (options: RemoteBrowserOptions): Promise<void> => { public initialize = async (options: RemoteBrowserOptions): Promise<void> => {
this.browser = <Browser>(await options.browser.launch(options.launchOptions)); this.browser = <Browser>(await options.browser.launch(options.launchOptions));
this.context = await this.browser.newContext( this.context = await this.browser.newContext(
// { {
// viewport: { height: 400, width: 900 }, viewport: { height: 400, width: 900 },
// // recordVideo: { dir: 'videos/' } // recordVideo: { dir: 'videos/' }
// } }
); );
this.currentPage = await this.context.newPage(); this.currentPage = await this.context.newPage();
const blocker = await PlaywrightBlocker.fromPrebuiltAdsAndTracking(fetch); const blocker = await PlaywrightBlocker.fromPrebuiltAdsAndTracking(fetch);
@@ -154,8 +144,6 @@ export class RemoteBrowser {
const { width, height } = data; const { width, height } = data;
logger.log('debug', `Received viewport size: width=${width}, height=${height}`); logger.log('debug', `Received viewport size: width=${width}, height=${height}`);
this.viewportSize = { width, height };
// Update the browser context's viewport dynamically // Update the browser context's viewport dynamically
if (this.context && this.browser) { if (this.context && this.browser) {
this.context = await this.browser.newContext({ viewport: { width, height } }); this.context = await this.browser.newContext({ viewport: { width, height } });
@@ -304,7 +292,7 @@ export class RemoteBrowser {
if (page) { if (page) {
await this.stopScreencast(); await this.stopScreencast();
this.currentPage = page; this.currentPage = page;
await this.currentPage.setViewportSize(this.viewportSize); //await this.currentPage.setViewportSize({ height: 400, width: 900 })
this.client = await this.currentPage.context().newCDPSession(this.currentPage); this.client = await this.currentPage.context().newCDPSession(this.currentPage);
this.socket.emit('urlChanged', this.currentPage.url()); this.socket.emit('urlChanged', this.currentPage.url());
await this.makeAndEmitScreenshot(); await this.makeAndEmitScreenshot();