@@ -36,6 +36,8 @@ function sleep(time) {
3636
3737// ===========================================================================
3838class Recorder {
39+ recordStorage = true ;
40+
3941 constructor ( ) {
4042 // @ts -expect-error - TS2339 - Property 'flatMode' does not exist on type 'Recorder'.
4143 this . flatMode = false ;
@@ -1488,7 +1490,7 @@ class Recorder {
14881490 data . extraOpts . pixelRatio = this . pixelRatio ;
14891491
14901492 // handle storage
1491- const storage = await this . getStorage ( reqresp . url ) ;
1493+ const storage = await this . getStorage ( sessions ) ;
14921494
14931495 if ( storage ) {
14941496 data . extraOpts . storage = storage ;
@@ -1508,31 +1510,81 @@ class Recorder {
15081510 //delete this._fetchPending[requestId];
15091511 }
15101512
1511- // @ts -expect-error - TS7006 - Parameter 'url' implicitly has an ' any' type.
1512- async getStorage ( url ) {
1513+ // eslint-disable-next-line @typescript-eslint/no-explicit- any
1514+ async getStorage ( sessions : any ) {
15131515 // check if recording storage is allowed
1514- // @ts -expect-error - TS2339 - Property 'recordStorage' does not exist on type 'Recorder'.
15151516 if ( ! this . recordStorage ) {
15161517 return null ;
15171518 }
15181519
1519- const securityOrigin = new URL ( url ) . origin ;
1520- const storageId = { securityOrigin, isLocalStorage : true } ;
1520+ const extractStorage = ( ) => {
1521+ const local : [ string , string ] [ ] = [ ] ;
1522+ for ( let i = 0 ; i < localStorage . length ; i ++ ) {
1523+ const key = localStorage . key ( i ) ;
1524+ if ( ! key ) continue ;
1525+ const value = localStorage . getItem ( key ) ;
1526+ if ( ! value ) continue ;
1527+ local . push ( [ key , value ] ) ;
1528+ }
1529+ const session : [ string , string ] [ ] = [ ] ;
1530+ for ( let i = 0 ; i < sessionStorage . length ; i ++ ) {
1531+ const key = sessionStorage . key ( i ) ;
1532+ if ( ! key ) continue ;
1533+ const value = sessionStorage . getItem ( key ) ;
1534+ if ( ! value ) continue ;
1535+ session . push ( [ key , value ] ) ;
1536+ }
1537+ return JSON . stringify ( { local, session } ) ;
1538+ } ;
15211539
1522- // @ts -expect-error - TS2345 - Argument of type '{ storageId: { securityOrigin: string; isLocalStorage: boolean; }; }' is not assignable to parameter of type 'null | undefined'.
1523- const local = await this . send ( "DOMStorage.getDOMStorageItems" , {
1524- storageId ,
1525- } ) ;
1526- storageId . isLocalStorage = false ;
1540+ const { result } = await this . pageEval (
1541+ "__awp_extract_storage" ,
1542+ `( ${ extractStorage . toString ( ) } )();` ,
1543+ sessions ,
1544+ ) ;
15271545
1528- // @ts -expect-error - TS2345 - Argument of type '{ storageId: { securityOrigin: string; isLocalStorage: boolean; }; }' is not assignable to parameter of type 'null | undefined'.
1529- const session = await this . send ( "DOMStorage.getDOMStorageItems" , {
1530- storageId,
1531- } ) ;
1546+ if ( result && result . type === "string" ) {
1547+ return result . value ;
1548+ } else {
1549+ return null ;
1550+ }
1551+
1552+ // const securityOrigin = new URL(url).origin;
1553+ // const storageId = {securityOrigin, isLocalStorage: true};
1554+
1555+ // const local = await this.send("DOMStorage.getDOMStorageItems", {storageId}, sessions);
1556+ // storageId.isLocalStorage = false;
15321557
1533- return JSON . stringify ( { local : local . entries , session : session . entries } ) ;
1558+ // const session = await this.send("DOMStorage.getDOMStorageItems", {storageId}, sessions);
1559+
1560+ //return JSON.stringify({local: local.entries, session: session.entries});
15341561 }
15351562
1563+ // // @ts -expect-error - TS7006 - Parameter 'url' implicitly has an 'any' type.
1564+ // async getStorage(url) {
1565+ // // check if recording storage is allowed
1566+ // // @ts -expect-error - TS2339 - Property 'recordStorage' does not exist on type 'Recorder'.
1567+ // if (!this.recordStorage) {
1568+ // return null;
1569+ // }
1570+
1571+ // const securityOrigin = new URL(url).origin;
1572+ // const storageId = { securityOrigin, isLocalStorage: true };
1573+
1574+ // // @ts -expect-error - TS2345 - Argument of type '{ storageId: { securityOrigin: string; isLocalStorage: boolean; }; }' is not assignable to parameter of type 'null | undefined'.
1575+ // const local = await this.send("DOMStorage.getDOMStorageItems", {
1576+ // storageId,
1577+ // });
1578+ // storageId.isLocalStorage = false;
1579+
1580+ // // @ts -expect-error - TS2345 - Argument of type '{ storageId: { securityOrigin: string; isLocalStorage: boolean; }; }' is not assignable to parameter of type 'null | undefined'.
1581+ // const session = await this.send("DOMStorage.getDOMStorageItems", {
1582+ // storageId,
1583+ // });
1584+
1585+ // return JSON.stringify({ local: local.entries, session: session.entries });
1586+ // }
1587+
15361588 // @ts -expect-error - TS7006 - Parameter 'params' implicitly has an 'any' type.
15371589 async handleRequestWillBeSent ( params ) {
15381590 if (
0 commit comments