fix: correctly propagate title updates for window with no navigation entries (#29946)
This commit is contained in:
parent
675bbfe092
commit
a8b3c22518
2 changed files with 15 additions and 0 deletions
|
@ -1752,6 +1752,8 @@ void WebContents::TitleWasSet(content::NavigationEntry* entry) {
|
||||||
} else {
|
} else {
|
||||||
final_title = title;
|
final_title = title;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
final_title = web_contents()->GetTitle();
|
||||||
}
|
}
|
||||||
for (ExtendedWebContentsObserver& observer : observers_)
|
for (ExtendedWebContentsObserver& observer : observers_)
|
||||||
observer.OnPageTitleUpdated(final_title, explicit_set);
|
observer.OnPageTitleUpdated(final_title, explicit_set);
|
||||||
|
|
|
@ -2024,6 +2024,19 @@ describe('webContents module', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('page-title-updated event', () => {
|
||||||
|
afterEach(closeAllWindows);
|
||||||
|
it('is emitted with a full title for pages with no navigation', async () => {
|
||||||
|
const bw = new BrowserWindow({ show: false, webPreferences: { nativeWindowOpen: true } });
|
||||||
|
await bw.loadURL('about:blank');
|
||||||
|
bw.webContents.executeJavaScript('child = window.open("", "", "show=no"); null');
|
||||||
|
const [, child] = await emittedOnce(app, 'web-contents-created');
|
||||||
|
bw.webContents.executeJavaScript('child.document.title = "new title"');
|
||||||
|
const [, title] = await emittedOnce(child, 'page-title-updated');
|
||||||
|
expect(title).to.equal('new title');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('crashed event', () => {
|
describe('crashed event', () => {
|
||||||
it('does not crash main process when destroying WebContents in it', (done) => {
|
it('does not crash main process when destroying WebContents in it', (done) => {
|
||||||
const contents = (webContents as any).create({ nodeIntegration: true });
|
const contents = (webContents as any).create({ nodeIntegration: true });
|
||||||
|
|
Loading…
Reference in a new issue