fix: setContentProtection(true) after hide on Windows (#45889)

fix: content protection after hide on Windows

5789117

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot] 2025-03-05 06:13:36 +01:00 committed by GitHub
parent 179fde9278
commit 6eb4932c68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 60 additions and 11 deletions

View file

@ -296,6 +296,44 @@ describe('BrowserWindow module', () => {
});
});
ifdescribe(process.platform !== 'linux')('BrowserWindow.getContentProtection', () => {
afterEach(closeAllWindows);
it('can set content protection', async () => {
const w = new BrowserWindow({ show: false });
// @ts-expect-error This is a private API
expect(w._isContentProtected()).to.equal(false);
const shown = once(w, 'show');
w.show();
await shown;
w.setContentProtection(true);
// @ts-expect-error This is a private API
expect(w._isContentProtected()).to.equal(true);
});
it('does not remove content protection after the window is hidden and shown', async () => {
const w = new BrowserWindow({ show: false });
const hidden = once(w, 'hide');
const shown = once(w, 'show');
w.show();
await shown;
w.setContentProtection(true);
w.hide();
await hidden;
w.show();
await shown;
// @ts-expect-error This is a private API
expect(w._isContentProtected()).to.equal(true);
});
});
describe('BrowserWindow.loadURL(url)', () => {
let w: BrowserWindow;
const scheme = 'other';