-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Closed
Labels
Description
- Puppeteer version: 1.0.0-post, chromium_revision 526987
- Platform / OS version: Windows 7 x64
- Node.js version: 9.4.0
What steps will reproduce the problem?
'use strict';
const puppeteer = require('puppeteer');
(async function main() {
try {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
page.on('console', (msg) => { console.log(msg.text()); });
page.on('pageerror', (exceptionMessage) => { console.log(exceptionMessage); });
const result = await page.evaluate(async () => {
try {
const status = await new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status === 200) resolve(`good status: ${xhr.status}`);
else reject(`bad status: ${xhr.status}`);
}
};
xhr.onerror = () => { reject('xhr error'); };
xhr.open('GET', 'https://example.org/');
xhr.send();
});
return status;
} catch (err) {
return err;
}
});
console.log(result);
} catch (err) {
console.error(err);
}
})();What is the expected result?
CORS error message is transferred to puppeteer
What happens instead?
Only bad status: 0 in the Node.js console, while this error message in the browser console:
Is there a way to catch this error message, while page.on('console') and page.on('pageerror') seem to not work here?
dostu, CommanderXL, oliviertassinari, Muniek, yanivefraim and 2 more