puppeteer / puppeteer

Node.js API for Chrome

Home Page:https://pptr.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In mixed-content page page.exposeFunction is stuck indefinitely

yujiosaka opened this issue · comments

Steps to reproduce

Tell us about your environment:

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. Access to a mixed-content page.
  2. expose a function by page.exposeFunction.
  3. the execution is stuck indefinitely.
const puppeteer = require('puppeteer');
(async() => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  await page.goto('https://www.bennish.net/mixed-content.html');
  await page.exposeFunction('compute', function(a, b) {
    return Promise.resolve(a * b);
  });
  const result = await page.evaluate(async function() {
    return await compute(3, 5);
  });
  console.log(result);
  await browser.close();
})();

What is the expected result?

Expose function successfully or at lease throws an error.

What happens instead?

The execution is is stuck indefinitely.

For the record: this happens because execution contexts are not created for iframes that failed to load.

Upstream CL: https://chromium-review.googlesource.com/c/chromium/src/+/1102154

Hi, i am getting protocol error only in version 1.18.0
it works fine in version 1.17.0
{"name":"PDFGenerator","hostname":"26b7bc9c5bbd","pid":59,"level":30,"err":{"message":"Protocol error (IO.read): Invalid parameters handle: string value expected","name":"Error","stack":"Error: Protocol error (IO.read): Invalid parameters handle: string value expected\n at Promise (/usr/app/node_modules/puppeteer/lib/Connection.js:183:56)\n at new Promise ()\n at CDPSession.send (/usr/app/node_modules/puppeteer/lib/Connection.js:182:12)\n at Function.readProtocolStream (/usr/app/node_modules/puppeteer/lib/helper.js:238:37)\n at \n -- ASYNC --\n at Page. (/usr/app/node_modules/puppeteer/lib/helper.js:111:15)\n at /usr/app/pdf-creator/index.js:228:14\n at \n at process._tickCallback (internal/process/next_tick.js:189:7)"},"msg":"Failed on PDF generation page one","time":"2019-06-24T08:07:32.960Z","v":0}