8000 fix: correctly propagate title updates for window with no navigation entries by trop[bot] · Pull Request #29959 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: correctly propagate title updates for window with no navigation entries #29959

8000 New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions shell/browser/api/electron_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,8 @@ void WebContents::TitleWasSet(content::NavigationEntry* entry) {
} else {
final_title = title;
}
} else {
final_title = web_contents()->GetTitle();
}
for (ExtendedWebContentsObserver& observer : observers_)
observer.OnPageTitleUpdated(final_title, explicit_set);
Expand Down
13 changes: 13 additions & 0 deletions spec-main/api-web-contents-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
it('does not crash main process when destroying WebContents in it', (done) => {
const contents = (webContents as any).create({ nodeIntegration: true });
Expand Down
0