mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(executioncontext): warn on nested js handle (#3591)
ExecutionContext.evaluateHandle accepts arguments that are either serializable, or JSHandles. A potential confusion is that it *does not* accept arguments that *contain* JSHandles. This patch adds a log message warning when it encounters that situation. Fixes #3562
This commit is contained in:
committed by
Andrey Lushnikov
parent
d346cb57b4
commit
7fabf32172
@@ -34,6 +34,15 @@ module.exports.addTests = function({testRunner, expect}) {
|
||||
const isFive = await page.evaluate(e => Object.is(e, 5), aHandle);
|
||||
expect(isFive).toBeTruthy();
|
||||
});
|
||||
it('should warn on nested object handles', async({page, server}) => {
|
||||
const aHandle = await page.evaluateHandle(() => document.body);
|
||||
let error = null;
|
||||
await page.evaluateHandle(
|
||||
opts => opts.elem.querySelector('p'),
|
||||
{ elem: aHandle }
|
||||
).catch(e => error = e);
|
||||
expect(error.message).toContain('Are you passing a nested JSHandle?');
|
||||
});
|
||||
});
|
||||
|
||||
describe('JSHandle.getProperty', function() {
|
||||
|
||||
Reference in New Issue
Block a user