diff --git a/packages/playwright-core/src/server/chromium/crConnection.ts b/packages/playwright-core/src/server/chromium/crConnection.ts index 5c2e00644c..660937b0ac 100644 --- a/packages/playwright-core/src/server/chromium/crConnection.ts +++ b/packages/playwright-core/src/server/chromium/crConnection.ts @@ -23,7 +23,7 @@ import { rewriteErrorMessage } from '../../utils/stackTrace'; import { debugLogger, RecentLogsCollector } from '../../utils/debugLogger'; import { ProtocolLogger } from '../types'; import { helper } from '../helper'; -import { ProtocolError } from '../common/protocolError'; +import { ProtocolError } from '../protocolError'; export const ConnectionEvents = { Disconnected: Symbol('ConnectionEvents.Disconnected') diff --git a/packages/playwright-core/src/server/chromium/crExecutionContext.ts b/packages/playwright-core/src/server/chromium/crExecutionContext.ts index e03e589d71..e7ce0b4712 100644 --- a/packages/playwright-core/src/server/chromium/crExecutionContext.ts +++ b/packages/playwright-core/src/server/chromium/crExecutionContext.ts @@ -21,7 +21,7 @@ import { Protocol } from './protocol'; import * as js from '../javascript'; import { rewriteErrorMessage } from '../../utils/stackTrace'; import { parseEvaluationResultValue } from '../common/utilityScriptSerializers'; -import { isSessionClosedError } from '../common/protocolError'; +import { isSessionClosedError } from '../protocolError'; export class CRExecutionContext implements js.ExecutionContextDelegate { _client: CRSession; diff --git a/packages/playwright-core/src/server/common/cssParser.ts b/packages/playwright-core/src/server/common/cssParser.ts index c41df11cba..976e5bb509 100644 --- a/packages/playwright-core/src/server/common/cssParser.ts +++ b/packages/playwright-core/src/server/common/cssParser.ts @@ -14,9 +14,15 @@ * limitations under the License. */ -import { InvalidSelectorError } from './selectorErrors'; import * as css from './cssTokenizer'; +export class InvalidSelectorError extends Error { +} + +export function isInvalidSelectorError(error: Error) { + return error instanceof InvalidSelectorError; +} + // Note: '>=' is used internally for text engine to preserve backwards compatibility. type ClauseCombinator = '' | '>' | '+' | '~' | '>='; // TODO: consider diff --git a/packages/playwright-core/src/server/common/selectorErrors.ts b/packages/playwright-core/src/server/common/selectorErrors.ts deleted file mode 100644 index a0d9f1e721..0000000000 --- a/packages/playwright-core/src/server/common/selectorErrors.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export class InvalidSelectorError extends Error { -} - -export function isInvalidSelectorError(error: Error) { - return error instanceof InvalidSelectorError; -} diff --git a/packages/playwright-core/src/server/common/selectorParser.ts b/packages/playwright-core/src/server/common/selectorParser.ts index 6adede7b5b..9b37b455ee 100644 --- a/packages/playwright-core/src/server/common/selectorParser.ts +++ b/packages/playwright-core/src/server/common/selectorParser.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { InvalidSelectorError } from './selectorErrors'; -import { CSSComplexSelectorList, parseCSS } from './cssParser'; +import { InvalidSelectorError, CSSComplexSelectorList, parseCSS } from './cssParser'; +export { InvalidSelectorError, isInvalidSelectorError } from './cssParser'; export type ParsedSelectorPart = { name: string, diff --git a/packages/playwright-core/src/server/dom.ts b/packages/playwright-core/src/server/dom.ts index 50b2a52df7..693b18985a 100644 --- a/packages/playwright-core/src/server/dom.ts +++ b/packages/playwright-core/src/server/dom.ts @@ -17,7 +17,7 @@ import * as mime from 'mime'; import * as injectedScriptSource from '../generated/injectedScriptSource'; import * as channels from '../protocol/channels'; -import { isSessionClosedError } from './common/protocolError'; +import { isSessionClosedError } from './protocolError'; import * as frames from './frames'; import type { InjectedScript, InjectedScriptPoll, LogEntry, HitTargetInterceptionResult } from './injected/injectedScript'; import { CallMetadata } from './instrumentation'; diff --git a/packages/playwright-core/src/server/firefox/ffConnection.ts b/packages/playwright-core/src/server/firefox/ffConnection.ts index 181210ea05..0611faf31c 100644 --- a/packages/playwright-core/src/server/firefox/ffConnection.ts +++ b/packages/playwright-core/src/server/firefox/ffConnection.ts @@ -23,7 +23,7 @@ import { rewriteErrorMessage } from '../../utils/stackTrace'; import { debugLogger, RecentLogsCollector } from '../../utils/debugLogger'; import { ProtocolLogger } from '../types'; import { helper } from '../helper'; -import { ProtocolError } from '../common/protocolError'; +import { ProtocolError } from '../protocolError'; export const ConnectionEvents = { Disconnected: Symbol('Disconnected'), diff --git a/packages/playwright-core/src/server/firefox/ffExecutionContext.ts b/packages/playwright-core/src/server/firefox/ffExecutionContext.ts index 96f7127a69..16b8c8d2b9 100644 --- a/packages/playwright-core/src/server/firefox/ffExecutionContext.ts +++ b/packages/playwright-core/src/server/firefox/ffExecutionContext.ts @@ -20,7 +20,7 @@ import { FFSession } from './ffConnection'; import { Protocol } from './protocol'; import { rewriteErrorMessage } from '../../utils/stackTrace'; import { parseEvaluationResultValue } from '../common/utilityScriptSerializers'; -import { isSessionClosedError } from '../common/protocolError'; +import { isSessionClosedError } from '../protocolError'; export class FFExecutionContext implements js.ExecutionContextDelegate { _session: FFSession; diff --git a/packages/playwright-core/src/server/frames.ts b/packages/playwright-core/src/server/frames.ts index 10793ed2f1..54ef7fb139 100644 --- a/packages/playwright-core/src/server/frames.ts +++ b/packages/playwright-core/src/server/frames.ts @@ -32,10 +32,9 @@ import { debugLogger } from '../utils/debugLogger'; import { CallMetadata, internalCallMetadata, SdkObject } from './instrumentation'; import type InjectedScript from './injected/injectedScript'; import type { ElementStateWithoutStable, FrameExpectParams, InjectedScriptPoll, InjectedScriptProgress } from './injected/injectedScript'; -import { isSessionClosedError } from './common/protocolError'; -import { splitSelectorByFrame, stringifySelector } from './common/selectorParser'; +import { isSessionClosedError } from './protocolError'; +import { isInvalidSelectorError, splitSelectorByFrame, stringifySelector } from './common/selectorParser'; import { SelectorInfo } from './selectors'; -import { isInvalidSelectorError } from './common/selectorErrors'; type ContextData = { contextPromise: ManualPromise; diff --git a/packages/playwright-core/src/server/common/componentUtils.ts b/packages/playwright-core/src/server/injected/componentUtils.ts similarity index 100% rename from packages/playwright-core/src/server/common/componentUtils.ts rename to packages/playwright-core/src/server/injected/componentUtils.ts diff --git a/packages/playwright-core/src/server/injected/reactSelectorEngine.ts b/packages/playwright-core/src/server/injected/reactSelectorEngine.ts index 42c6b81415..31713e58d5 100644 --- a/packages/playwright-core/src/server/injected/reactSelectorEngine.ts +++ b/packages/playwright-core/src/server/injected/reactSelectorEngine.ts @@ -16,7 +16,7 @@ import { SelectorEngine, SelectorRoot } from './selectorEngine'; import { isInsideScope } from './selectorEvaluator'; -import { checkComponentAttribute, parseComponentSelector } from '../common/componentUtils'; +import { checkComponentAttribute, parseComponentSelector } from './componentUtils'; type ComponentNode = { name: string, diff --git a/packages/playwright-core/src/server/injected/vueSelectorEngine.ts b/packages/playwright-core/src/server/injected/vueSelectorEngine.ts index 8fe6a6316b..66e4b5f113 100644 --- a/packages/playwright-core/src/server/injected/vueSelectorEngine.ts +++ b/packages/playwright-core/src/server/injected/vueSelectorEngine.ts @@ -16,7 +16,7 @@ import { SelectorEngine, SelectorRoot } from './selectorEngine'; import { isInsideScope } from './selectorEvaluator'; -import { checkComponentAttribute, parseComponentSelector } from '../common/componentUtils'; +import { checkComponentAttribute, parseComponentSelector } from './componentUtils'; type ComponentNode = { name: string, diff --git a/packages/playwright-core/src/server/common/protocolError.ts b/packages/playwright-core/src/server/protocolError.ts similarity index 100% rename from packages/playwright-core/src/server/common/protocolError.ts rename to packages/playwright-core/src/server/protocolError.ts diff --git a/packages/playwright-core/src/server/selectors.ts b/packages/playwright-core/src/server/selectors.ts index 44c9829254..f9d7310f17 100644 --- a/packages/playwright-core/src/server/selectors.ts +++ b/packages/playwright-core/src/server/selectors.ts @@ -18,8 +18,7 @@ import * as dom from './dom'; import * as frames from './frames'; import * as js from './javascript'; import * as types from './types'; -import { ParsedSelector, parseSelector, stringifySelector } from './common/selectorParser'; -import { InvalidSelectorError } from './common/selectorErrors'; +import { InvalidSelectorError, ParsedSelector, parseSelector, stringifySelector } from './common/selectorParser'; import { createGuid } from '../utils/utils'; export type SelectorInfo = { diff --git a/packages/playwright-core/src/server/webkit/wkConnection.ts b/packages/playwright-core/src/server/webkit/wkConnection.ts index 6b86271076..d3b452d5f3 100644 --- a/packages/playwright-core/src/server/webkit/wkConnection.ts +++ b/packages/playwright-core/src/server/webkit/wkConnection.ts @@ -24,7 +24,7 @@ import { debugLogger, RecentLogsCollector } from '../../utils/debugLogger'; import { ProtocolLogger } from '../types'; import { helper } from '../helper'; import { kBrowserClosedError } from '../../utils/errors'; -import { ProtocolError } from '../common/protocolError'; +import { ProtocolError } from '../protocolError'; // WKPlaywright uses this special id to issue Browser.close command which we // should ignore. diff --git a/packages/playwright-core/src/server/webkit/wkExecutionContext.ts b/packages/playwright-core/src/server/webkit/wkExecutionContext.ts index f450070142..5a5b25ba76 100644 --- a/packages/playwright-core/src/server/webkit/wkExecutionContext.ts +++ b/packages/playwright-core/src/server/webkit/wkExecutionContext.ts @@ -19,7 +19,7 @@ import { WKSession } from './wkConnection'; import { Protocol } from './protocol'; import * as js from '../javascript'; import { parseEvaluationResultValue } from '../common/utilityScriptSerializers'; -import { isSessionClosedError } from '../common/protocolError'; +import { isSessionClosedError } from '../protocolError'; export class WKExecutionContext implements js.ExecutionContextDelegate { private readonly _session: WKSession; diff --git a/tests/component-parser.spec.ts b/tests/component-parser.spec.ts index ea5e0ca2d1..1de3da074d 100644 --- a/tests/component-parser.spec.ts +++ b/tests/component-parser.spec.ts @@ -15,8 +15,7 @@ */ import { playwrightTest as it, expect } from './config/browserTest'; -import type { ParsedComponentSelector } from '../packages/playwright-core/src/server/common/componentUtils'; -import { parseComponentSelector } from '../packages/playwright-core/lib/server/common/componentUtils'; +import { ParsedComponentSelector, parseComponentSelector } from '../packages/playwright-core/src/server/injected/componentUtils'; const parse = parseComponentSelector; const serialize = (parsed: ParsedComponentSelector) => {