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 #12711

Openmgarcia-improving(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12711/headopened View on GitHub

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

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/devtools-pip-origin-window-name.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/query-devtools': patch
+---
+​
+fix(query-devtools): use an origin-specific picture-in-picture window name so a popup opened by another origin is never reused
15 additions and 2 deletionspackages/query-devtools/src/__tests__/contexts/PiPContext.test.tsxModified
View file
@@ -93,11 +93,24 @@
​
expect(open).toHaveBeenCalledWith(
'',
- 'TSQD-Devtools-Panel',
+ `TSQD-Devtools-Panel-${window.location.origin}`,
'width=640,height=480,popup',
})
​
+ it('should use a window name that is specific to the current origin', () => {
+ const { open } = stubPipWindow()
+ vi.stubGlobal('location', { ...window.location, origin: 'http://a.test' })
+ renderAndAct((pip) => pip().requestPipWindow(640, 480))
+ vi.stubGlobal('location', { ...window.location, origin: 'http://b.test' })
+ renderAndAct((pip) => pip().requestPipWindow(640, 480))
+​
+ expect(open.mock.calls.map(([, name]) => name)).toStrictEqual([
+ 'TSQD-Devtools-Panel-http://a.test',
+ 'TSQD-Devtools-Panel-http://b.test',
+ ])
+ })