fix: CHECK when adding view as its own child (#42067)

This commit is contained in:
Shelley Vohr 2024-05-09 15:47:47 +02:00 committed by GitHub
parent 731bc7a334
commit 6675f3ae65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -1,3 +1,4 @@
import { expect } from 'chai';
import { closeWindow } from './lib/window-helpers';
import { BaseWindow, View } from 'electron/main';
@ -10,6 +11,15 @@ describe('View', () => {
it('can be used as content view', () => {
w = new BaseWindow({ show: false });
w.setContentView(new View());
const v = new View();
w.setContentView(v);
expect(w.contentView).to.equal(v);
});
it('will throw when added as a child to itself', () => {
w = new BaseWindow({ show: false });
expect(() => {
w.contentView.addChildView(w.contentView);
}).to.throw('A view cannot be added as its own child');
});
});