Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix: handle failures of adoptElementHandle (#134)
Dmitry Gozman3f554b3273e8
diff --git a/src/chromium/JSHandle.ts b/src/chromium/JSHandle.tsindex 0c0d2ddf89..a1e0a82e61 100644--- a/src/chromium/JSHandle.ts+++ b/src/chromium/JSHandle.ts@@ -202,11 +202,13 @@ export class DOMWorldDelegate implements dom.DOMWorldDelegate {}async adoptBackendNodeId(backendNodeId: Protocol.DOM.BackendNodeId, to: dom.DOMWorld): Promise<dom.ElementHandle> {- const {object} = await this._client.send('DOM.resolveNode', {+ const result = await this._client.send('DOM.resolveNode', {backendNodeId,executionContextId: (to.context._delegate as ExecutionContextDelegate)._contextId,- });- return to.context._createHandle(object).asElement()!;+ }).catch(debugError);+ if (!result)+ throw new Error('Unable to adopt element handle from a different document');+ return to.context._createHandle(result.object).asElement()!;}}diff --git a/src/dom.ts b/src/dom.tsindex aee6927cd6..e4ada5e096 100644--- a/src/dom.ts+++ b/src/dom.ts@@ -344,9 +344,8 @@ export function waitForFunctionTask(pageFunction: Function | string, options: ty}, await domWorld.injected(), predicateBody, polling, options.timeout, ...args);}-export function waitForSelectorTask(selector: string | ScopedSelector, timeout: number): Task {+export function waitForSelectorTask(selector: string | types.Selector, timeout: number): Task {return async (domWorld: DOMWorld) => {- // TODO: we should not be able to adopt selector scope from a different document - handle this case.const resolved = await domWorld.resolveSelector(selector);return domWorld.context.evaluateHandle((injected: Injected, selector: string, scope: SelectorRoot | undefined, visible: boolean | undefined, timeout: number) => {if (visible !== undefined)