@@ -218,6 +218,61 @@ document.querySelector('#session').innerHTML = [session1,session2,session3].join
218218 await tab2 . close ( ) ;
219219 } ) ;
220220
221+ it ( "should keep profile information for sites that aren't loaded in a session" , async ( ) => {
222+ const meta = await connection . createSession ( {
223+ userProfile : {
224+ cookies : [ ] ,
225+ storage : {
226+ [ koaServer . baseUrl ] : {
227+ indexedDB : [ ] ,
228+ localStorage : [
229+ [ 'Test1' , 'value0' ] ,
230+ [ 'test2' , 'value1' ] ,
231+ ] ,
232+ sessionStorage : [ ] ,
233+ } ,
234+ 'https://previousSite.org' : {
235+ indexedDB : [ ] ,
236+ localStorage : [ [ 'test' , 'site1.org' ] ] ,
237+ sessionStorage : [ ] ,
238+ } ,
239+ 'https://site2.org' : {
240+ indexedDB : [ ] ,
241+ localStorage : [ [ 'test2' , 'site2.org' ] ] ,
242+ sessionStorage : [ ] ,
243+ } ,
244+ } ,
245+ } ,
246+ } ) ;
247+ const tab = Session . getTab ( meta ) ;
248+ Helpers . needsClosing . push ( tab . session ) ;
249+
250+ koaServer . get ( '/unloaded' , ctx => {
251+ ctx . body = `<body>
252+ <h1>storage page</h1>
253+ <script>
254+ localStorage.setItem('Test1', 'value1');
255+ </script>
256+ </body>` ;
257+ } ) ;
258+
259+ await tab . goto ( `${ koaServer . baseUrl } /unloaded` ) ;
260+ await tab . waitForLoad ( 'PaintingStable' ) ;
261+
262+ const profile = await tab . session . exportUserProfile ( ) ;
263+ expect ( profile . cookies ) . toHaveLength ( 0 ) ;
264+ expect ( profile . storage [ koaServer . baseUrl ] ?. localStorage ) . toHaveLength ( 2 ) ;
265+ expect ( profile . storage [ koaServer . baseUrl ] ?. localStorage . find ( x => x [ 0 ] === 'Test1' ) ) . toEqual ( [
266+ 'Test1' ,
267+ 'value1' ,
268+ ] ) ;
269+ expect ( profile . storage [ 'https://previousSite.org' ] . localStorage ) . toEqual ( [
270+ [ 'test' , 'site1.org' ] ,
271+ ] ) ;
272+ expect ( profile . storage [ 'https://site2.org' ] . localStorage ) . toEqual ( [ [ 'test2' , 'site2.org' ] ] ) ;
273+ await tab . close ( ) ;
274+ } ) ;
275+
221276 it ( 'should not make requests to end sites during profile "install"' , async ( ) => {
222277 const mitmSpy = jest . spyOn ( HttpRequestHandler , 'onRequest' ) ;
223278 await connection . createSession ( {
0 commit comments