Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: move webkit to src/server/webkit (#3589)

Dmitry Gozman6a53b205e5b4
diff --git a/.eslintignore b/.eslintignore
index c805ab0203..d2764af1a2 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -8,7 +8,7 @@ lib/
src/generated/*
src/server/chromium/protocol.ts
src/firefox/protocol.ts
-src/webkit/protocol.ts
+src/server/webkit/protocol.ts
/types/*
/index.d.ts
/electron-types.d.ts
diff --git a/src/server/playwright.ts b/src/server/playwright.ts
index 2aafdd7e95..a472603030 100644
--- a/src/server/playwright.ts
+++ b/src/server/playwright.ts
@@ -15,7 +15,7 @@
*/
import { Chromium } from './chromium/chromium';
-import { WebKit } from './webkit';
+import { WebKit } from './webkit/webkit';
import { Firefox } from './firefox';
import { selectors } from '../selectors';
import * as browserPaths from '../utils/browserPaths';
diff --git a/src/webkit/protocol.ts b/src/server/webkit/protocol.ts
similarity index 100%
rename from src/webkit/protocol.ts
rename to src/server/webkit/protocol.ts
diff --git a/src/server/webkit.ts b/src/server/webkit/webkit.ts
similarity index 90%
rename from src/server/webkit.ts
rename to src/server/webkit/webkit.ts
index 7c3a27259c..b45ce85ad9 100644
--- a/src/server/webkit.ts
+++ b/src/server/webkit/webkit.ts
@@ -16,14 +16,14 @@
*/
import { WKBrowser } from '../webkit/wkBrowser';
-import { Env } from './processLauncher';
+import { Env } from '../processLauncher';
import * as path from 'path';
-import { kBrowserCloseMessageId } from '../webkit/wkConnection';
-import { BrowserTypeBase } from './browserType';
-import { ConnectionTransport } from '../transport';
-import { BrowserOptions } from '../browser';
-import { BrowserDescriptor } from '../utils/browserPaths';
-import * as types from '../types';
+import { kBrowserCloseMessageId } from './wkConnection';
+import { BrowserTypeBase } from '../browserType';
+import { ConnectionTransport } from '../../transport';
+import { BrowserOptions } from '../../browser';
+import { BrowserDescriptor } from '../../utils/browserPaths';
+import * as types from '../../types';
export class WebKit extends BrowserTypeBase {
constructor(packagePath: string, browser: BrowserDescriptor) {
diff --git a/src/webkit/wkAccessibility.ts b/src/server/webkit/wkAccessibility.ts
similarity index 98%
rename from src/webkit/wkAccessibility.ts
rename to src/server/webkit/wkAccessibility.ts
index 320fb16832..e111815af9 100644
--- a/src/webkit/wkAccessibility.ts
+++ b/src/server/webkit/wkAccessibility.ts
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import * as accessibility from '../accessibility';
+import * as accessibility from '../../accessibility';
import { WKSession } from './wkConnection';
import { Protocol } from './protocol';
-import * as dom from '../dom';
-import * as types from '../types';
+import * as dom from '../../dom';
+import * as types from '../../types';
export async function getAccessibilityTree(session: WKSession, needle?: dom.ElementHandle) {
const objectId = needle ? needle._objectId : undefined;
diff --git a/src/webkit/wkBrowser.ts b/src/server/webkit/wkBrowser.ts
similarity index 97%
rename from src/webkit/wkBrowser.ts
rename to src/server/webkit/wkBrowser.ts
index 962bbd42aa..23ff967c26 100644
--- a/src/webkit/wkBrowser.ts
+++ b/src/server/webkit/wkBrowser.ts
@@ -15,15 +15,15 @@
* limitations under the License.
*/
-import { Browser, BrowserOptions } from '../browser';
-import { assertBrowserContextIsNotOwned, BrowserContext, validateBrowserContextOptions, verifyGeolocation } from '../browserContext';
-import { helper, RegisteredListener } from '../helper';
-import { assert } from '../utils/utils';
-import * as network from '../network';
-import { Page, PageBinding } from '../page';
+import { Browser, BrowserOptions } from '../../browser';
+import { assertBrowserContextIsNotOwned, BrowserContext, validateBrowserContextOptions, verifyGeolocation } from '../../browserContext';
+import { helper, RegisteredListener } from '../../helper';
+import { assert } from '../../utils/utils';
+import * as network from '../../network';
+import { Page, PageBinding } from '../../page';
import * as path from 'path';
-import { ConnectionTransport } from '../transport';
-import * as types from '../types';
+import { ConnectionTransport } from '../../transport';
+import * as types from '../../types';
import { Protocol } from './protocol';
import { kPageProxyMessageReceived, PageProxyMessageReceivedPayload, WKConnection, WKSession } from './wkConnection';
import { WKPage } from './wkPage';
diff --git a/src/webkit/wkConnection.ts b/src/server/webkit/wkConnection.ts
similarity index 97%
rename from src/webkit/wkConnection.ts
rename to src/server/webkit/wkConnection.ts
index 5b90fa3ce8..8225e88d3e 100644
--- a/src/webkit/wkConnection.ts
+++ b/src/server/webkit/wkConnection.ts
@@ -16,11 +16,11 @@
*/
import { EventEmitter } from 'events';
-import { assert } from '../utils/utils';
-import { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../transport';
+import { assert } from '../../utils/utils';
+import { ConnectionTransport, ProtocolRequest, ProtocolResponse } from '../../transport';
import { Protocol } from './protocol';
-import { rewriteErrorMessage } from '../utils/stackTrace';
-import { debugLogger } from '../utils/debugLogger';
+import { rewriteErrorMessage } from '../../utils/stackTrace';
+import { debugLogger } from '../../utils/debugLogger';
// WKPlaywright uses this special id to issue Browser.close command which we
// should ignore.
diff --git a/src/webkit/wkExecutionContext.ts b/src/server/webkit/wkExecutionContext.ts
similarity index 97%
rename from src/webkit/wkExecutionContext.ts
rename to src/server/webkit/wkExecutionContext.ts
index c09847e22c..ce8e1e567a 100644
--- a/src/webkit/wkExecutionContext.ts
+++ b/src/server/webkit/wkExecutionContext.ts
@@ -17,9 +17,9 @@
import { WKSession, isSwappedOutError } from './wkConnection';
import { Protocol } from './protocol';
-import * as js from '../javascript';
-import { parseEvaluationResultValue } from '../common/utilityScriptSerializers';
-import * as sourceMap from '../utils/sourceMap';
+import * as js from '../../javascript';
+import { parseEvaluationResultValue } from '../../common/utilityScriptSerializers';
+import * as sourceMap from '../../utils/sourceMap';
export class WKExecutionContext implements js.ExecutionContextDelegate {
private readonly _session: WKSession;
diff --git a/src/webkit/wkInput.ts b/src/server/webkit/wkInput.ts
similarity index 95%
rename from src/webkit/wkInput.ts
rename to src/server/webkit/wkInput.ts
index 0999131971..82b30275ba 100644
--- a/src/webkit/wkInput.ts
+++ b/src/server/webkit/wkInput.ts
@@ -15,11 +15,11 @@
* limitations under the License.
*/
-import * as input from '../input';
-import * as types from '../types';
-import { macEditingCommands } from '../macEditingCommands';
+import * as input from '../../input';
+import * as types from '../../types';
+import { macEditingCommands } from '../../macEditingCommands';
import { WKSession } from './wkConnection';
-import { isString } from '../utils/utils';
+import { isString } from '../../utils/utils';
function toModifiersMask(modifiers: Set<types.KeyboardModifier>): number {
// From Source/WebKit/Shared/WebEvent.h
diff --git a/src/webkit/wkInterceptableRequest.ts b/src/server/webkit/wkInterceptableRequest.ts
similarity index 97%
rename from src/webkit/wkInterceptableRequest.ts
rename to src/server/webkit/wkInterceptableRequest.ts
index 1f28b278f1..2205a03918 100644
--- a/src/webkit/wkInterceptableRequest.ts
+++ b/src/server/webkit/wkInterceptableRequest.ts
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-import * as frames from '../frames';
-import * as network from '../network';
-import * as types from '../types';
+import * as frames from '../../frames';
+import * as network from '../../network';
+import * as types from '../../types';
import { Protocol } from './protocol';
import { WKSession } from './wkConnection';
-import { assert, headersObjectToArray, headersArrayToObject } from '../utils/utils';
+import { assert, headersObjectToArray, headersArrayToObject } from '../../utils/utils';
const errorReasons: { [reason: string]: Protocol.Network.ResourceErrorType } = {
'aborted': 'Cancellation',
diff --git a/src/webkit/wkPage.ts b/src/server/webkit/wkPage.ts
similarity index 98%
rename from src/webkit/wkPage.ts
rename to src/server/webkit/wkPage.ts
index e4d1ea26d8..6cb922d1f2 100644
--- a/src/webkit/wkPage.ts
+++ b/src/server/webkit/wkPage.ts
@@ -15,29 +15,29 @@
* limitations under the License.
*/
-import { Screencast, BrowserContext } from '../browserContext';
-import * as frames from '../frames';
-import { helper, RegisteredListener } from '../helper';
-import * as dom from '../dom';
-import * as network from '../network';
+import { Screencast, BrowserContext } from '../../browserContext';
+import * as frames from '../../frames';
+import { helper, RegisteredListener } from '../../helper';
+import * as dom from '../../dom';
+import * as network from '../../network';
import { WKSession } from './wkConnection';
import { WKExecutionContext } from './wkExecutionContext';
import { WKInterceptableRequest } from './wkInterceptableRequest';
import { WKWorkers } from './wkWorkers';
-import { Page, PageDelegate, PageBinding } from '../page';
+import { Page, PageDelegate, PageBinding } from '../../page';
import { Protocol } from './protocol';
-import * as dialog from '../dialog';
+import * as dialog from '../../dialog';
import { RawMouseImpl, RawKeyboardImpl } from './wkInput';
-import * as types from '../types';
-import * as accessibility from '../accessibility';
+import * as types from '../../types';
+import * as accessibility from '../../accessibility';
import { getAccessibilityTree } from './wkAccessibility';
import { WKProvisionalPage } from './wkProvisionalPage';
import { WKBrowserContext } from './wkBrowser';
-import { selectors } from '../selectors';
+import { selectors } from '../../selectors';
import * as jpeg from 'jpeg-js';
import * as png from 'pngjs';
-import { JSHandle } from '../javascript';
-import { assert, debugAssert, headersArrayToObject } from '../utils/utils';
+import { JSHandle } from '../../javascript';
+import { assert, debugAssert, headersArrayToObject } from '../../utils/utils';
const UTILITY_WORLD_NAME = '__playwright_utility_world__';
const BINDING_CALL_MESSAGE = '__playwright_binding_call__';
diff --git a/src/webkit/wkProvisionalPage.ts b/src/server/webkit/wkProvisionalPage.ts
similarity index 96%
rename from src/webkit/wkProvisionalPage.ts
rename to src/server/webkit/wkProvisionalPage.ts
index afcc5de4f2..62e13b04f7 100644
--- a/src/webkit/wkProvisionalPage.ts
+++ b/src/server/webkit/wkProvisionalPage.ts
@@ -16,9 +16,9 @@
import { WKSession } from './wkConnection';
import { WKPage } from './wkPage';
-import { RegisteredListener, helper } from '../helper';
+import { RegisteredListener, helper } from '../../helper';
import { Protocol } from './protocol';
-import { assert } from '../utils/utils';
+import { assert } from '../../utils/utils';
export class WKProvisionalPage {
readonly _session: WKSession;
diff --git a/src/webkit/wkWorkers.ts b/src/server/webkit/wkWorkers.ts
similarity index 96%
rename from src/webkit/wkWorkers.ts
rename to src/server/webkit/wkWorkers.ts
index f1041abcee..eaee964b40 100644
--- a/src/webkit/wkWorkers.ts
+++ b/src/server/webkit/wkWorkers.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import { helper, RegisteredListener } from '../helper';
-import { Page, Worker } from '../page';
+import { helper, RegisteredListener } from '../../helper';
+import { Page, Worker } from '../../page';
import { Protocol } from './protocol';
import { WKSession } from './wkConnection';
import { WKExecutionContext } from './wkExecutionContext';
-import * as types from '../types';
+import * as types from '../../types';
export class WKWorkers {
private _sessionListeners: RegisteredListener[] = [];
diff --git a/utils/check_deps.js b/utils/check_deps.js
index dd3e174d47..db0f6b360b 100644
--- a/utils/check_deps.js
+++ b/utils/check_deps.js
@@ -75,6 +75,8 @@ const DEPS = new Map([
['src/protocol/', ['src/protocol/', 'src/utils/']],
['src/install/', ['src/install/', 'src/utils/']],
['src/server/chromium/', ['src/server/chromium/', 'src/utils/', 'src/', 'src/common/', 'src/server/']],
+ ['src/server/electron/', ['src/server/electron/', 'src/server/chromium/', 'src/utils/', 'src/', 'src/server/']],
+ ['src/server/webkit/', ['src/server/webkit/', 'src/utils/', 'src/', 'src/common/', 'src/server/']],
['src/client/', ['src/client/', 'src/utils/', 'src/protocol/', 'src/server/chromium/protocol.ts']],
]);
diff --git a/utils/protocol-types-generator/index.js b/utils/protocol-types-generator/index.js
index a02c8d9d93..d650ed821b 100644
--- a/utils/protocol-types-generator/index.js
+++ b/utils/protocol-types-generator/index.js
@@ -29,7 +29,7 @@ async function generateChromiumProtocol(executablePath) {
}
async function generateWebKitProtocol(folderPath) {
- const outputPath = path.join(__dirname, '..', '..', 'src', 'webkit', 'protocol.ts');
+ const outputPath = path.join(__dirname, '..', '..', 'src', 'server', 'webkit', 'protocol.ts');
const json = JSON.parse(await fs.promises.readFile(path.join(folderPath, '..', 'protocol.json'), 'utf8'));
await fs.promises.writeFile(outputPath, jsonToTS({domains: json}));
console.log(`Wrote protocol.ts for WebKit to ${path.relative(process.cwd(), outputPath)}`);