Skip to content
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

fix: don't set delegate for QLPreviewPanel #37530

Merged
merged 1 commit into from
Mar 14, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions shell/browser/ui/cocoa/electron_ns_window.mm
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,10 @@ - (BOOL)acceptsPreviewPanelControl:(QLPreviewPanel*)panel {
}

- (void)beginPreviewPanelControl:(QLPreviewPanel*)panel {
panel.delegate = [self delegate];
panel.dataSource = static_cast<id<QLPreviewPanelDataSource>>([self delegate]);
}

- (void)endPreviewPanelControl:(QLPreviewPanel*)panel {
panel.delegate = nil;
panel.dataSource = nil;
}

Expand Down
16 changes: 16 additions & 0 deletions spec/api-browser-window-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5275,6 +5275,22 @@ describe('BrowserWindow module', () => {
w.closeFilePreview();
}).to.not.throw();
});

it('should not call BrowserWindow show event', async () => {
const w = new BrowserWindow({ show: false });
const shown = once(w, 'show');
w.show();
await shown;

let showCalled = false;
w.on('show', () => {
showCalled = true;
});

w.previewFile(__filename);
await setTimeout(500);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out a great way to test this without adding another internal event just for testing. I also tried await waitUntil(() => !w.isFocused()); but that didn't wait long enough for the second show.

I would have also liked to create a test with another window covering the QuickLook window but that doesn't work either.

expect(showCalled).to.equal(false, 'should not have called show twice');
});
});

// TODO (jkleinsc) renable these tests on mas arm64
Expand Down