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

nativeAutomation: Rename proxyless internal #7613

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"source-map-support": "^0.5.16",
"strip-bom": "^2.0.0",
"testcafe-browser-tools": "2.0.23",
"testcafe-hammerhead": "30.1.0",
"testcafe-hammerhead": "https://github.com/Artem-Babich/test-packages/files/11168259/testcafe-hammerhead-31.0.0.tar.gz",
"testcafe-legacy-api": "5.1.6",
"testcafe-reporter-dashboard": "^0.2.10",
"testcafe-reporter-json": "^2.1.0",
Expand Down
38 changes: 19 additions & 19 deletions src/browser/connection/gateway/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { Dictionary } from '../../../configuration/interfaces';
import BrowserConnection from '../index';
import { IncomingMessage, ServerResponse } from 'http';
import SERVICE_ROUTES from '../service-routes';
import EMPTY_PAGE_MARKUP from '../../../proxyless/empty-page-markup';
import PROXYLESS_ERROR_ROUTE from '../../../proxyless/error-route';
import EMPTY_PAGE_MARKUP from '../../../native-automation/empty-page-markup';
import NATIVE_AUTOMATION_ERROR_ROUTE from '../../../native-automation/error-route';
import { initSelector } from '../../../test-run/commands/validations/initializers';
import TestRun from '../../../test-run';
import { TestCafeStartOptions } from '../../../configuration/testcafe-configuration';
Expand All @@ -25,12 +25,12 @@ import { EventEmitter } from 'events';

export interface BrowserConnectionGatewayOptions {
retryTestPages: boolean;
proxyless: boolean;
nativeAutomation: boolean;
}

const DEFAULT_BROWSER_CONNECTION_GATEWAY_OPTIONS = {
retryTestPages: false,
proxyless: false,
retryTestPages: false,
nativeAutomation: false,
};

export default class BrowserConnectionGateway extends EventEmitter {
Expand Down Expand Up @@ -62,7 +62,7 @@ export default class BrowserConnectionGateway extends EventEmitter {

preventCaching(res);

if (this._options.proxyless)
if (this._options.nativeAutomation)
acceptCrossOrigin(res);

if (connection)
Expand Down Expand Up @@ -92,9 +92,9 @@ export default class BrowserConnectionGateway extends EventEmitter {
this._dispatch(`${SERVICE_ROUTES.activeWindowId}/{id}`, proxy, BrowserConnectionGateway._onSetActiveWindowIdRequest, 'POST');
this._dispatch(`${SERVICE_ROUTES.closeWindow}/{id}`, proxy, BrowserConnectionGateway._onCloseWindowRequest, 'POST');
this._dispatch(`${SERVICE_ROUTES.openFileProtocol}/{id}`, proxy, BrowserConnectionGateway._onOpenFileProtocolRequest, 'POST');
this._dispatch(`${SERVICE_ROUTES.dispatchProxylessEvent}/{id}`, proxy, BrowserConnectionGateway._onDispatchProxylessEvent, 'POST');
this._dispatch(`${SERVICE_ROUTES.dispatchNativeAutomationEvent}/{id}`, proxy, BrowserConnectionGateway._onDispatchNativeAutomationEvent, 'POST');
this._dispatch(`${SERVICE_ROUTES.parseSelector}/{id}`, proxy, BrowserConnectionGateway._parseSelector, 'POST');
this._dispatch(`${SERVICE_ROUTES.dispatchProxylessEventSequence}/{id}`, proxy, BrowserConnectionGateway._onDispatchProxylessEventSequence, 'POST');
this._dispatch(`${SERVICE_ROUTES.dispatchNativeAutomationEventSequence}/{id}`, proxy, BrowserConnectionGateway._onDispatchNativeAutomationEventSequence, 'POST');

proxy.GET(SERVICE_ROUTES.connect, (req: IncomingMessage, res: ServerResponse) => this._connectNextRemoteBrowser(req, res));
proxy.GET(SERVICE_ROUTES.connectWithTrailingSlash, (req: IncomingMessage, res: ServerResponse) => this._connectNextRemoteBrowser(req, res));
Expand All @@ -104,8 +104,8 @@ export default class BrowserConnectionGateway extends EventEmitter {
proxy.GET(SERVICE_ROUTES.assets.styles, { content: idlePageStyle, contentType: 'text/css' });
proxy.GET(SERVICE_ROUTES.assets.logo, { content: idlePageLogo, contentType: 'image/svg+xml' });

if (this._options.proxyless) {
proxy.GET(PROXYLESS_ERROR_ROUTE, (req: IncomingMessage, res: ServerResponse) => {
if (this._options.nativeAutomation) {
proxy.GET(NATIVE_AUTOMATION_ERROR_ROUTE, (req: IncomingMessage, res: ServerResponse) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(EMPTY_PAGE_MARKUP);
});
Expand Down Expand Up @@ -244,25 +244,25 @@ export default class BrowserConnectionGateway extends EventEmitter {
}
}

private static _onDispatchProxylessEvent (req: IncomingMessage, res: ServerResponse, connection: BrowserConnection): void {
private static _onDispatchNativeAutomationEvent (req: IncomingMessage, res: ServerResponse, connection: BrowserConnection): void {
if (BrowserConnectionGateway._ensureConnectionReady(res, connection)) {
BrowserConnectionGateway._fetchRequestData(req, data => {
const { type, options } = JSON.parse(data);

connection.dispatchProxylessEvent(type, options)
connection.dispatchNativeAutomationEvent(type, options)
.then(() => {
respondWithJSON(res);
});
});
}
}

private static _onDispatchProxylessEventSequence (req: IncomingMessage, res: ServerResponse, connection: BrowserConnection): void {
private static _onDispatchNativeAutomationEventSequence (req: IncomingMessage, res: ServerResponse, connection: BrowserConnection): void {
if (BrowserConnectionGateway._ensureConnectionReady(res, connection)) {
BrowserConnectionGateway._fetchRequestData(req, data => {
const eventSequence = JSON.parse(data);

connection.dispatchProxylessEventSequence(eventSequence)
connection.dispatchNativeAutomationEventSequence(eventSequence)
.then(() => {
respondWithJSON(res);
});
Expand Down Expand Up @@ -338,8 +338,8 @@ export default class BrowserConnectionGateway extends EventEmitter {
return this._connections;
}

public get proxyless (): boolean {
return this._options.proxyless;
public get nativeAutomation (): boolean {
return this._options.nativeAutomation;
}

public get status (): BrowserConnectionGatewayStatus {
Expand All @@ -364,10 +364,10 @@ export default class BrowserConnectionGateway extends EventEmitter {
this.emit('initialized');
}

public switchToProxyless (): void {
this._options.proxyless = true;
public switchToNativeAutomation (): void {
this._options.nativeAutomation = true;

this.proxy.switchToProxyless();
this.proxy.switchToNativeAutomation();
}
}

30 changes: 15 additions & 15 deletions src/browser/connection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import TestRun from '../../test-run';
import { TestRun as LegacyTestRun } from 'testcafe-legacy-api';
import { Proxy } from 'testcafe-hammerhead';
import { NextTestRunInfo, OpenBrowserAdditionalOptions } from '../../shared/types';
import { EventType } from '../../proxyless/types';
import { EventType } from '../../native-automation/types';

const getBrowserConnectionDebugScope = (id: string): string => `testcafe:browser:connection:${id}`;

Expand Down Expand Up @@ -89,13 +89,13 @@ export interface BrowserInfo {
export interface BrowserConnectionOptions {
disableMultipleWindows: boolean;
developmentMode: boolean;
proxyless: boolean;
nativeAutomation: boolean;
}

const DEFAULT_BROWSER_CONNECTION_OPTIONS = {
disableMultipleWindows: false,
developmentMode: false,
proxyless: false,
nativeAutomation: false,
};

export default class BrowserConnection extends EventEmitter {
Expand Down Expand Up @@ -129,8 +129,8 @@ export default class BrowserConnection extends EventEmitter {
public idleRelativeUrl = '';
public openFileProtocolRelativeUrl = '';
public openFileProtocolUrl = '';
public dispatchProxylessEventRelativeUrl = '';
public dispatchProxylessEventSequenceRelativeUrl = '';
public dispatchNativeAutomationEventRelativeUrl = '';
public dispatchNativeAutomationEventSequenceRelativeUrl = '';
public parseSelectorRelativeUrl = '';
private readonly debugLogger: debug.Debugger;
private osInfo: OSInfo | null = null;
Expand Down Expand Up @@ -208,9 +208,9 @@ export default class BrowserConnection extends EventEmitter {
this.activeWindowIdUrl = `${SERVICE_ROUTES.activeWindowId}/${this.id}`;
this.closeWindowUrl = `${SERVICE_ROUTES.closeWindow}/${this.id}`;
this.openFileProtocolRelativeUrl = `${SERVICE_ROUTES.openFileProtocol}/${this.id}`;
this.dispatchProxylessEventRelativeUrl = `${SERVICE_ROUTES.dispatchProxylessEvent}/${this.id}`;
this.dispatchProxylessEventSequenceRelativeUrl = `${SERVICE_ROUTES.dispatchProxylessEventSequence}/${this.id}`;
this.parseSelectorRelativeUrl = `${SERVICE_ROUTES.parseSelector}/${this.id}`;
this.dispatchNativeAutomationEventRelativeUrl = `${SERVICE_ROUTES.dispatchNativeAutomationEvent}/${this.id}`;
this.dispatchNativeAutomationEventSequenceRelativeUrl = `${SERVICE_ROUTES.dispatchNativeAutomationEventSequence}/${this.id}`;
this.parseSelectorRelativeUrl = `${SERVICE_ROUTES.parseSelector}/${this.id}`;

this.idleUrl = proxy.resolveRelativeServiceUrl(this.idleRelativeUrl);
this.heartbeatUrl = proxy.resolveRelativeServiceUrl(this.heartbeatRelativeUrl);
Expand Down Expand Up @@ -269,8 +269,8 @@ export default class BrowserConnection extends EventEmitter {
disableMultipleWindows: this._options.disableMultipleWindows,
} as OpenBrowserAdditionalOptions;

if (this._options.proxyless) {
options.proxyless = {
if (this._options.nativeAutomation) {
options.nativeAutomation = {
serviceDomains: [
this.browserConnectionGateway.proxy.server1Info.domain,
this.browserConnectionGateway.proxy.server2Info.domain,
Expand Down Expand Up @@ -571,7 +571,7 @@ export default class BrowserConnection extends EventEmitter {
initScriptUrl: this.initScriptUrl,
openFileProtocolUrl: this.openFileProtocolUrl,
retryTestPages: !!this.browserConnectionGateway.retryTestPages,
proxyless: this._options.proxyless,
nativeAutomation: this._options.nativeAutomation,
});
}

Expand Down Expand Up @@ -639,12 +639,12 @@ export default class BrowserConnection extends EventEmitter {
return this.provider.openFileProtocol(this.id, url);
}

public async dispatchProxylessEvent (type: EventType, options: any): Promise<void> {
return this.provider.dispatchProxylessEvent(this.id, type, options);
public async dispatchNativeAutomationEvent (type: EventType, options: any): Promise<void> {
return this.provider.dispatchNativeAutomationEvent(this.id, type, options);
}

public async dispatchProxylessEventSequence (eventSequence: []): Promise<void> {
return this.provider.dispatchProxylessEventSequence(this.id, eventSequence);
public async dispatchNativeAutomationEventSequence (eventSequence: []): Promise<void> {
return this.provider.dispatchNativeAutomationEventSequence(this.id, eventSequence);
}

public async canUseDefaultWindowActions (): Promise<boolean> {
Expand Down
30 changes: 15 additions & 15 deletions src/browser/connection/service-routes.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export default {
connect: '/browser/connect',
connectWithTrailingSlash: '/browser/connect/',
heartbeat: '/browser/heartbeat',
status: '/browser/status',
statusDone: '/browser/status-done',
initScript: '/browser/init-script',
idle: '/browser/idle',
idleForced: '/browser/idle-forced',
activeWindowId: '/browser/active-window-id',
closeWindow: '/browser/close-window',
serviceWorker: '/service-worker.js',
openFileProtocol: '/browser/open-file-protocol',
dispatchProxylessEvent: '/browser/dispatch-proxyless-event',
dispatchProxylessEventSequence: '/browser/dispatch-proxyless-event-sequence',
parseSelector: '/parse-selector',
connect: '/browser/connect',
connectWithTrailingSlash: '/browser/connect/',
heartbeat: '/browser/heartbeat',
status: '/browser/status',
statusDone: '/browser/status-done',
initScript: '/browser/init-script',
idle: '/browser/idle',
idleForced: '/browser/idle-forced',
activeWindowId: '/browser/active-window-id',
closeWindow: '/browser/close-window',
serviceWorker: '/service-worker.js',
openFileProtocol: '/browser/open-file-protocol',
dispatchNativeAutomationEvent: '/browser/dispatch-native-automation-event',
dispatchNativeAutomationEventSequence: '/browser/dispatch-native-automation-event-sequence',
parseSelector: '/parse-selector',

assets: {
index: '/browser/assets/index.js',
Expand Down
34 changes: 17 additions & 17 deletions src/browser/provider/built-in/dedicated/chrome/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
} from './local-chrome';
import { GET_WINDOW_DIMENSIONS_INFO_SCRIPT } from '../../../utils/client-functions';
import { BrowserClient } from './cdp-client';
import { dispatchEvent as dispatchProxylessEvent, navigateTo } from '../../../../../proxyless/utils/cdp';
import Proxyless from '../../../../../proxyless';
import { dispatchEvent as dispatchNativeAutomationEvent, navigateTo } from '../../../../../native-automation/utils/cdp';
import NativeAutomation from '../../../../../native-automation';
import { chromeBrowserProviderLogger } from '../../../../../utils/debug-loggers';
import { EventType } from '../../../../../proxyless/types';
import { EventType } from '../../../../../native-automation/types';
import delay from '../../../../../utils/delay';

const MIN_AVAILABLE_DIMENSION = 50;
Expand Down Expand Up @@ -55,16 +55,16 @@ export default {
this.setUserAgentMetaInfo(browserId, metaInfo, options);
},

async _setupProxyless ({ browserId, browserClient, runtimeInfo, proxylessOptions }) {
async _setupNativeAutomation ({ browserId, browserClient, runtimeInfo, nativeAutomationOptions }) {
const cdpClient = await browserClient.getActiveClient();
const proxyless = new Proxyless(browserId, cdpClient);
const nativeAutomation = new NativeAutomation(browserId, cdpClient);

await proxyless.init(proxylessOptions);
await nativeAutomation.init(nativeAutomationOptions);

runtimeInfo.proxyless = proxyless;
runtimeInfo.nativeAutomation = nativeAutomation;
},

async openBrowser (browserId, pageUrl, config, { disableMultipleWindows, proxyless }) {
async openBrowser (browserId, pageUrl, config, { disableMultipleWindows, nativeAutomation }) {
const parsedPageUrl = parseUrl(pageUrl);
const runtimeInfo = await this._createRunTimeInfo(parsedPageUrl.hostname, config, disableMultipleWindows);

Expand Down Expand Up @@ -101,17 +101,17 @@ export default {

this._setUserAgentMetaInfoForEmulatingDevice(browserId, runtimeInfo.config);

if (proxyless)
await this._setupProxyless({ browserId, browserClient, runtimeInfo, proxylessOptions: proxyless });
if (nativeAutomation)
await this._setupNativeAutomation({ browserId, browserClient, runtimeInfo, nativeAutomationOptions: nativeAutomation });

chromeBrowserProviderLogger('browser opened %s', browserId);
},

async closeBrowser (browserId, closingInfo = {}) {
const runtimeInfo = this.openedBrowsers[browserId];

if (runtimeInfo.proxyless)
await runtimeInfo.proxyless.dispose();
if (runtimeInfo.nativeAutomation)
await runtimeInfo.nativeAutomation.dispose();

if (runtimeInfo.browserClient.isHeadlessTab())
await runtimeInfo.browserClient.closeTab();
Expand Down Expand Up @@ -190,24 +190,24 @@ export default {
await navigateTo(cdpClient, url);
},

async dispatchProxylessEvent (browserId, type, options) {
async dispatchNativeAutomationEvent (browserId, type, options) {
const cdpClient = await this._getActiveCDPClient(browserId);

await dispatchProxylessEvent(cdpClient, type, options);
await dispatchNativeAutomationEvent(cdpClient, type, options);
},

async dispatchProxylessEventSequence (browserId, eventSequence) {
async dispatchNativeAutomationEventSequence (browserId, eventSequence) {
const cdpClient = await this._getActiveCDPClient(browserId);

for (const event of eventSequence) {
if (event.type === EventType.Delay)
await delay(event.options.delay);
else
await dispatchProxylessEvent(cdpClient, event.type, event.options);
await dispatchNativeAutomationEvent(cdpClient, event.type, event.options);
}
},

supportProxyless () {
supportNativeAutomation () {
return true;
},
};
2 changes: 1 addition & 1 deletion src/browser/provider/built-in/dedicated/edge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
return EdgeRunTimeInfo.create(hostName, configString, disableMultipleWindows);
},

supportProxyless () {
supportNativeAutomation () {
return true;
},
};
14 changes: 7 additions & 7 deletions src/browser/provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Dictionary } from '../../configuration/interfaces';
import { WindowDimentionsInfo } from '../interfaces';
import getLocalOSInfo, { OSInfo } from 'get-os-info';
import { OpenBrowserAdditionalOptions } from '../../shared/types';
import { EventType } from '../../proxyless/types';
import { EventType } from '../../native-automation/types';


const DEBUG_LOGGER = debug('testcafe:browser:provider');
Expand Down Expand Up @@ -451,15 +451,15 @@ export default class BrowserProvider {
await this.plugin.closeBrowserChildWindow(browserId);
}

public async dispatchProxylessEvent (browserId: string, type: EventType, options: any): Promise<void> {
await this.plugin.dispatchProxylessEvent(browserId, type, options);
public async dispatchNativeAutomationEvent (browserId: string, type: EventType, options: any): Promise<void> {
await this.plugin.dispatchNativeAutomationEvent(browserId, type, options);
}

public async dispatchProxylessEventSequence (browserId: string, sequence: []): Promise<void> {
await this.plugin.dispatchProxylessEventSequence(browserId, sequence);
public async dispatchNativeAutomationEventSequence (browserId: string, sequence: []): Promise<void> {
await this.plugin.dispatchNativeAutomationEventSequence(browserId, sequence);
}

public supportProxyless (): boolean {
return this.plugin.supportProxyless();
public supportNativeAutomation (): boolean {
return this.plugin.supportNativeAutomation();
}
}
2 changes: 1 addition & 1 deletion src/browser/provider/plugin-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export default class BrowserProviderPluginHost {
return null;
}

supportProxyless () {
supportNativeAutomation () {
return false;
}
}
2 changes: 1 addition & 1 deletion src/cli/argument-parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ interface CommandLineOptions {
videoEncodingOptions?: string | Dictionary<number | string | boolean>;
compilerOptions?: string | Dictionary<number | string | boolean>;
configFile?: string;
proxyless?: boolean;
nativeAutomation?: boolean;
v8Flags?: string[];
dashboardOptions?: string | Dictionary<string | boolean | number>;
baseUrl?: string;
Expand Down
Loading