Merge pull request #11056 from ajmacd/allow-browser-window-logs
Allow BrowserWindows to emit `console-message` events.
This commit is contained in:
commit
a06a8a6f79
3 changed files with 25 additions and 1 deletions
|
@ -480,7 +480,7 @@ bool WebContents::DidAddMessageToConsole(content::WebContents* source,
|
||||||
const base::string16& message,
|
const base::string16& message,
|
||||||
int32_t line_no,
|
int32_t line_no,
|
||||||
const base::string16& source_id) {
|
const base::string16& source_id) {
|
||||||
if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) {
|
if (type_ == OFF_SCREEN) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Emit("console-message", level, message, line_no, source_id);
|
Emit("console-message", level, message, line_no, source_id);
|
||||||
|
|
|
@ -591,6 +591,18 @@ Returns:
|
||||||
|
|
||||||
Emitted when a `<webview>` has been attached to this web contents.
|
Emitted when a `<webview>` has been attached to this web contents.
|
||||||
|
|
||||||
|
#### Event: 'console-message'
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
* `level` Integer
|
||||||
|
* `message` String
|
||||||
|
* `line` Integer
|
||||||
|
* `sourceId` String
|
||||||
|
|
||||||
|
Emitted when the associated window logs a console message. Will not be emitted
|
||||||
|
for windows with *offscreen rendering* enabled.
|
||||||
|
|
||||||
### Instance Methods
|
### Instance Methods
|
||||||
|
|
||||||
#### `contents.loadURL(url[, options])`
|
#### `contents.loadURL(url[, options])`
|
||||||
|
|
|
@ -667,4 +667,16 @@ describe('webContents module', () => {
|
||||||
w.loadURL(`file://${path.join(__dirname, 'fixtures', 'pages', 'theme-color.html')}`)
|
w.loadURL(`file://${path.join(__dirname, 'fixtures', 'pages', 'theme-color.html')}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('console-message event', () => {
|
||||||
|
it('is triggered with correct log message', (done) => {
|
||||||
|
w.webContents.on('console-message', (e, level, message) => {
|
||||||
|
// Don't just assert as Chromium might emit other logs that we should ignore.
|
||||||
|
if (message === 'a') {
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
w.loadURL(`file://${fixtures}/pages/a.html`)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue