experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

test(window-url): cover URL-reuse skip when caller provides explicit key

+30
+30
tests/desktop/window-url.spec.ts
··· 117 117 await closeWindow(sharedBgWindow, result2.id); 118 118 }); 119 119 120 + test('opening a URL with a key does NOT reuse a keyless window with the same URL', async () => { 121 + // Regression: slides set address=http://localhost/ and key=address:edge. 122 + // When a page-host already has http://localhost/ open (no key), pressing 123 + // Option+Up used to fall through key-reuse → URL-reuse → got attached to 124 + // the page-host's window instead of opening a fresh edge-anchored slide. 125 + // An explicit key signals "I manage identity by key" — URL-reuse must skip. 126 + const url = 'https://example.com/keyless-vs-keyed'; 127 + 128 + // Open WITHOUT a key (the "existing page-host" stand-in) 129 + const keylessResult = await openUrl(sharedBgWindow, url); 130 + expect(keylessResult.success).toBe(true); 131 + expect(keylessResult.reused).toBeFalsy(); 132 + 133 + // Open SAME URL but WITH a key — must NOT reuse the keyless window 134 + const keyedResult = await openUrl(sharedBgWindow, url, { key: 'keyed-slot-A' }); 135 + expect(keyedResult.success).toBe(true); 136 + expect(keyedResult.reused).toBeFalsy(); 137 + expect(keyedResult.id).not.toBe(keylessResult.id); 138 + 139 + // Opening with the same key again reuses the keyed window (key-reuse) 140 + const keyedAgain = await openUrl(sharedBgWindow, url, { key: 'keyed-slot-A' }); 141 + expect(keyedAgain.success).toBe(true); 142 + expect(keyedAgain.reused).toBe(true); 143 + expect(keyedAgain.id).toBe(keyedResult.id); 144 + 145 + // Clean up 146 + await closeWindow(sharedBgWindow, keylessResult.id); 147 + await closeWindow(sharedBgWindow, keyedResult.id); 148 + }); 149 + 120 150 test('key-based window reuse still works', async () => { 121 151 const url = 'https://example.com/key-test'; 122 152 const key = 'test-key-reuse';