mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(firefox): support consoleMessage.location() (#4002)
This commit is contained in:
parent
2275c3c0c8
commit
e3b76b2beb
@ -2344,8 +2344,8 @@ puppeteer.launch().then(async browser => {
|
|||||||
#### consoleMessage.location()
|
#### consoleMessage.location()
|
||||||
- returns: <[Object]>
|
- returns: <[Object]>
|
||||||
- `url` <[string]> URL of the resource if known or `undefined` otherwise.
|
- `url` <[string]> URL of the resource if known or `undefined` otherwise.
|
||||||
- `lineNumber` <[number]> line number in the resource if known or `undefined` otherwise.
|
- `lineNumber` <[number]> 0-based line number in the resource if known or `undefined` otherwise.
|
||||||
- `columnNumber` <[number]> column number in the resource if known or `undefined` otherwise.
|
- `columnNumber` <[number]> 0-based column number in the resource if known or `undefined` otherwise.
|
||||||
|
|
||||||
#### consoleMessage.text()
|
#### consoleMessage.text()
|
||||||
- returns: <[string]>
|
- returns: <[string]>
|
||||||
|
@ -571,9 +571,9 @@ class Page extends EventEmitter {
|
|||||||
this.emit(Events.Page.Close);
|
this.emit(Events.Page.Close);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onConsole({type, args, frameId}) {
|
_onConsole({type, args, frameId, location}) {
|
||||||
const frame = this._frameManager.frame(frameId);
|
const frame = this._frameManager.frame(frameId);
|
||||||
this.emit(Events.Page.Console, new ConsoleMessage(type, args.map(arg => createHandle(frame._executionContext, arg))));
|
this.emit(Events.Page.Console, new ConsoleMessage(type, args.map(arg => createHandle(frame._executionContext, arg)), location));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -589,9 +589,14 @@ class ConsoleMessage {
|
|||||||
* @param {string} type
|
* @param {string} type
|
||||||
* @param {!Array<!JSHandle>} args
|
* @param {!Array<!JSHandle>} args
|
||||||
*/
|
*/
|
||||||
constructor(type, args) {
|
constructor(type, args, location) {
|
||||||
this._type = type;
|
this._type = type;
|
||||||
this._args = args;
|
this._args = args;
|
||||||
|
this._location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
location() {
|
||||||
|
return this._location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"node": ">=8.9.4"
|
"node": ">=8.9.4"
|
||||||
},
|
},
|
||||||
"puppeteer": {
|
"puppeteer": {
|
||||||
"firefox_revision": "6186c850885f1fa486e9987b5119d2b4bcb53499"
|
"firefox_revision": "0647e24cc0b90c07c8ddb32e63ce333839329527"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "node install.js",
|
"install": "node install.js",
|
||||||
|
@ -25,7 +25,7 @@ try {
|
|||||||
asyncawait = false;
|
asyncawait = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.addTests = function({testRunner, expect, headless, Errors, DeviceDescriptors}) {
|
module.exports.addTests = function({testRunner, expect, headless, Errors, DeviceDescriptors, CHROME}) {
|
||||||
const {describe, xdescribe, fdescribe, describe_fails_ffox} = testRunner;
|
const {describe, xdescribe, fdescribe, describe_fails_ffox} = testRunner;
|
||||||
const {it, fit, xit, it_fails_ffox} = testRunner;
|
const {it, fit, xit, it_fails_ffox} = testRunner;
|
||||||
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
||||||
@ -344,7 +344,7 @@ module.exports.addTests = function({testRunner, expect, headless, Errors, Device
|
|||||||
lineNumber: undefined
|
lineNumber: undefined
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it_fails_ffox('should have location for console API calls', async({page, server}) => {
|
it('should have location for console API calls', async({page, server}) => {
|
||||||
await page.goto(server.EMPTY_PAGE);
|
await page.goto(server.EMPTY_PAGE);
|
||||||
const [message] = await Promise.all([
|
const [message] = await Promise.all([
|
||||||
waitEvent(page, 'console'),
|
waitEvent(page, 'console'),
|
||||||
@ -355,7 +355,7 @@ module.exports.addTests = function({testRunner, expect, headless, Errors, Device
|
|||||||
expect(message.location()).toEqual({
|
expect(message.location()).toEqual({
|
||||||
url: server.PREFIX + '/consolelog.html',
|
url: server.PREFIX + '/consolelog.html',
|
||||||
lineNumber: 7,
|
lineNumber: 7,
|
||||||
columnNumber: 14,
|
columnNumber: CHROME ? 14 : 6, // console.|log vs |console.log
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// @see https://github.com/GoogleChrome/puppeteer/issues/3865
|
// @see https://github.com/GoogleChrome/puppeteer/issues/3865
|
||||||
|
Loading…
Reference in New Issue
Block a user