Skip to content

Commit b4cdc2d

Browse files
mihar-22claude
andcommitted
fix(core): guard webkit pip exit and fix api check order
- Check standard `requestPictureInPicture` before webkit fallback in `isPictureInPictureEnabled`, matching `requestPictureInPicture` order. - Guard `exitPictureInPicture` webkit path with presentation mode check to avoid accidentally exiting fullscreen. - Update fullscreen button test to expect error propagation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 516fbba commit b4cdc2d

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

packages/core/src/core/ui/fullscreen-button/tests/fullscreen-button-core.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ describe('FullscreenButtonCore', () => {
158158
expect(media.requestFullscreen).not.toHaveBeenCalled();
159159
});
160160

161-
it('catches fullscreen errors silently', () => {
161+
it('propagates fullscreen errors to caller', async () => {
162162
const core = new FullscreenButtonCore();
163163
const media = createMediaState({
164164
requestFullscreen: vi.fn(async () => {
165165
throw new Error('permission denied');
166166
}),
167167
});
168-
expect(() => core.toggle(media)).not.toThrow();
168+
await expect(core.toggle(media)).rejects.toThrow('permission denied');
169169
});
170170
});
171171
});

packages/core/src/dom/presentation/pip.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ export function isPictureInPictureEnabled(media: Media): boolean {
77
const video = resolveHTMLVideoElement(media);
88
if (!video) return false;
99

10-
if (isWebKitVideoElement(video)) {
11-
return video.webkitSupportsPresentationMode('picture-in-picture');
12-
}
13-
1410
if (isFunction(video.requestPictureInPicture)) {
1511
return true;
1612
}
1713

14+
if (isWebKitVideoElement(video)) {
15+
return video.webkitSupportsPresentationMode('picture-in-picture');
16+
}
17+
1818
return false;
1919
}
2020

@@ -53,7 +53,7 @@ export function requestPictureInPicture(media: Media): Promise<unknown> {
5353
export function exitPictureInPicture(media?: Media): Promise<void> {
5454
const video = media && resolveHTMLVideoElement(media);
5555

56-
if (isWebKitVideoElement(video)) {
56+
if (isWebKitVideoElement(video) && video.webkitPresentationMode === 'picture-in-picture') {
5757
return Promise.resolve(video.webkitSetPresentationMode('inline'));
5858
}
5959

0 commit comments

Comments
 (0)