refactor: use WidgetDelegate::SetAccessibleTitle() (#46765)

* refactor: use WidgetDelegate::SetAccessibleTitle()

* test: add window.accessibleTitle tests
This commit is contained in:
Charles Kerr 2025-05-07 10:44:53 -05:00 committed by GitHub
commit 924a8da940
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 14 deletions

View file

@ -16,6 +16,7 @@ import { setTimeout } from 'node:timers/promises';
import * as nodeUrl from 'node:url';
import { emittedUntil, emittedNTimes } from './lib/events-helpers';
import { randomString } from './lib/net-helpers';
import { HexColors, hasCapturableScreen, ScreenCapture } from './lib/screen-helpers';
import { ifit, ifdescribe, defer, listen, waitUntil } from './lib/spec-helpers';
import { closeWindow, closeAllWindows } from './lib/window-helpers';
@ -232,6 +233,36 @@ describe('BrowserWindow module', () => {
});
});
describe('window.accessibleTitle', () => {
const title = 'Window Title';
let w: BrowserWindow;
beforeEach(() => {
w = new BrowserWindow({ show: false, title, webPreferences: { nodeIntegration: true, contextIsolation: false } });
});
afterEach(async () => {
await closeWindow(w);
w = null as unknown as BrowserWindow;
});
it('should default to the window title', async () => {
expect(w.accessibleTitle).to.equal(title);
});
it('should be mutable', async () => {
const accessibleTitle = randomString(20);
w.accessibleTitle = accessibleTitle;
expect(w.accessibleTitle).to.equal(accessibleTitle);
});
it('should be clearable', async () => {
const accessibleTitle = randomString(20);
w.accessibleTitle = accessibleTitle;
expect(w.accessibleTitle).to.equal(accessibleTitle);
w.accessibleTitle = '';
expect(w.accessibleTitle).to.equal(title);
});
});
describe('window.close()', () => {
let w: BrowserWindow;
beforeEach(() => {