diff --git a/src/server/common/domErrors.ts b/src/server/common/domErrors.ts deleted file mode 100644 index 7b43195754..0000000000 --- a/src/server/common/domErrors.ts +++ /dev/null @@ -1,30 +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 type FatalDOMError = - 'error:notelement' | - 'error:nothtmlelement' | - 'error:notfillableelement' | - 'error:notfillableinputtype' | - 'error:notfillablenumberinput' | - 'error:notvaliddate' | - 'error:notinput' | - 'error:hasnovalue' | - 'error:notselect' | - 'error:notcheckbox' | - 'error:notmultiplefileinput'; - -export type RetargetableDOMError = 'error:notconnected'; diff --git a/src/server/dom.ts b/src/server/dom.ts index ec34dd4230..a0a1bff37d 100644 --- a/src/server/dom.ts +++ b/src/server/dom.ts @@ -17,7 +17,6 @@ import * as mime from 'mime'; import * as injectedScriptSource from '../generated/injectedScriptSource'; import * as channels from '../protocol/channels'; -import { FatalDOMError, RetargetableDOMError } from './common/domErrors'; import { isSessionClosedError } from './common/protocolError'; import * as frames from './frames'; import type { InjectedScript, InjectedScriptPoll, LogEntry } from './injected/injectedScript'; @@ -98,6 +97,7 @@ export class FrameExecutionContext extends js.ExecutionContext { return new pwExport( ${this.frame._page._delegate.rafCountForStablePosition()}, ${!!process.env.PWTEST_USE_TIMEOUT_FOR_RAF}, + "${this.frame._page._browserContext._browser.options.name}", [${custom.join(',\n')}] ); })(); @@ -182,21 +182,21 @@ export class ElementHandle extends js.JSHandle { } async getAttribute(name: string): Promise { - return throwFatalDOMError(throwRetargetableDOMError(await this.evaluateInUtility(([injeced, node, name]) => { + return throwRetargetableDOMError(await this.evaluateInUtility(([injected, node, name]) => { if (node.nodeType !== Node.ELEMENT_NODE) - return 'error:notelement'; + throw injected.createStacklessError('Node is not an element'); const element = node as unknown as Element; return { value: element.getAttribute(name) }; - }, name))).value; + }, name)).value; } async inputValue(): Promise { - return throwFatalDOMError(throwRetargetableDOMError(await this.evaluateInUtility(([injeced, node]) => { + return throwRetargetableDOMError(await this.evaluateInUtility(([injected, node]) => { if (node.nodeType !== Node.ELEMENT_NODE || (node.nodeName !== 'INPUT' && node.nodeName !== 'TEXTAREA' && node.nodeName !== 'SELECT')) - return 'error:hasnovalue'; + throw injected.createStacklessError('Node is not an ,