Skip to content
Source
Sign inSign up
TanStack/query

fix(query-devtools): name the PiP window per origin so another origin's popup is never reused #12702

Openimadization(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12702/headopened View on GitHub

Showing 4 changed files with 32 additions and 3 deletions (loading 1).

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/query-devtools-pip-window-per-origin.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/query-devtools': patch
+---
+​
+The picture-in-picture window is now named per origin, so two apps on different origins no longer try to share one popup (which threw a cross-origin SecurityError).
26 additions and 2 deletionspackages/query-devtools/src/__tests__/contexts/PiPContext.test.tsxModified
View file
@@ -93,7 +93,31 @@
​
expect(open).toHaveBeenCalledWith(
'',
- 'TSQD-Devtools-Panel',
+ 'TSQD-Devtools-Panel-http://localhost:3000',
+ 'width=640,height=480,popup',
+ )
+ })
+​
+ it('should give each origin a popup of its own', () => {
+ const { open } = stubPipWindow()
+​
+ for (const origin of ['http://localhost:3001', 'http://localhost:3002']) {
+ // Each origin has its own storage, so no persisted "pip_open" carries over.
+ localStorage.clear()
+ vi.stubGlobal('location', { ...window.location, origin })
+ renderAndAct((pip) => pip().requestPipWindow(640, 480))
+ }
+​
+ expect(open).toHaveBeenNthCalledWith(
+ 1,