mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix: errors in evaluate should be JavaScriptErrorInEvaluate (#28706)
Fixes https://github.com/microsoft/playwright/issues/28690
This commit is contained in:
parent
b33a04bc88
commit
afc1ac7063
@ -272,7 +272,7 @@ export async function evaluateExpression(context: ExecutionContext, expression:
|
|||||||
if (!handle._objectId)
|
if (!handle._objectId)
|
||||||
return { fallThrough: handle._value };
|
return { fallThrough: handle._value };
|
||||||
if (handle._disposed)
|
if (handle._disposed)
|
||||||
throw new Error('JSHandle is disposed!');
|
throw new JavaScriptErrorInEvaluate('JSHandle is disposed!');
|
||||||
const adopted = context.adoptIfNeeded(handle);
|
const adopted = context.adoptIfNeeded(handle);
|
||||||
if (adopted === null)
|
if (adopted === null)
|
||||||
return { h: pushHandle(Promise.resolve(handle)) };
|
return { h: pushHandle(Promise.resolve(handle)) };
|
||||||
@ -285,7 +285,7 @@ export async function evaluateExpression(context: ExecutionContext, expression:
|
|||||||
const utilityScriptObjectIds: ObjectId[] = [];
|
const utilityScriptObjectIds: ObjectId[] = [];
|
||||||
for (const handle of await Promise.all(handles)) {
|
for (const handle of await Promise.all(handles)) {
|
||||||
if (handle._context !== context)
|
if (handle._context !== context)
|
||||||
throw new Error('JSHandles can be evaluated only in the context they were created!');
|
throw new JavaScriptErrorInEvaluate('JSHandles can be evaluated only in the context they were created!');
|
||||||
utilityScriptObjectIds.push(handle._objectId!);
|
utilityScriptObjectIds.push(handle._objectId!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -215,3 +215,17 @@ it('should dispatch device motion event', async ({ page, server, isAndroid }) =>
|
|||||||
expect(await page.evaluate('rotationRate.gamma')).toBe(15);
|
expect(await page.evaluate('rotationRate.gamma')).toBe(15);
|
||||||
expect(await page.evaluate('interval')).toBe(16);
|
expect(await page.evaluate('interval')).toBe(16);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should throw if argument is from different frame', async ({ page, server }) => {
|
||||||
|
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/28690' });
|
||||||
|
await page.goto(server.PREFIX + '/frames/one-frame.html');
|
||||||
|
{
|
||||||
|
const dataTransfer = await page.frames()[1].evaluateHandle(() => new DataTransfer());
|
||||||
|
await page.frameLocator('iframe').locator('div').dispatchEvent('drop', { dataTransfer });
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const dataTransfer = await page.evaluateHandle(() => new DataTransfer());
|
||||||
|
await expect(page.frameLocator('iframe').locator('div').dispatchEvent('drop', { dataTransfer }))
|
||||||
|
.rejects.toThrow('JSHandles can be evaluated only in the context they were created!');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user