@@ -109,3 +109,39 @@ test('localStorage is persisted if it is used', async () => {
109109 assert . strictEqual ( cp . code , 0 ) ;
110110 assert . match ( cp . stdout , / b a r b a z / ) ;
111111} ) ;
112+
113+ test ( 'localStorage can store and retrieve a max of 10 MB quota' , async ( ) => {
114+ const localStorageFile = nextLocalStorage ( ) ;
115+ const cpToFill = await spawnPromisified ( process . execPath , [
116+ '--experimental-webstorage' ,
117+ '--localstorage-file' , localStorageFile ,
118+ // Each character is 2 bytes
119+ '-pe' , `for (let i = 0; i < 10; i++) {
120+ localStorage[i.toString().repeat(1 * 1024 * 1024 / 2)] = '';
121+ }
122+ ` ,
123+ ] ) ;
124+ const cpToVerify = await spawnPromisified ( process . execPath , [
125+ '--experimental-webstorage' ,
126+ '--localstorage-file' , localStorageFile ,
127+ '-pe' , `localStorage.anything = 'should fail';` ,
128+ ] ) ;
129+
130+ assert . doesNotMatch ( cpToFill . stderr , / Q u o t a E x c e e d e d E r r o r / ) ;
131+ assert . match ( cpToVerify . stderr , / Q u o t a E x c e e d e d E r r o r : S e t t i n g t h e v a l u e e x c e e d e d t h e q u o t a / ) ;
132+ } ) ;
133+
134+ test ( 'sessionStorage can store a max of 10 MB quota' , async ( ) => {
135+ const cpToFill = await spawnPromisified ( process . execPath , [
136+ '--experimental-webstorage' ,
137+ // Each character is 2 bytes
138+ '-pe' , `for (let i = 0; i < 10; i++) {
139+ sessionStorage[i.toString().repeat(1 * 1024 * 1024 / 2)] = '';
140+ }
141+
142+ sessionStorage.anything = 'should fail';
143+ ` ,
144+ ] ) ;
145+
146+ assert . match ( cpToFill . stderr , / Q u o t a E x c e e d e d E r r o r / ) ;
147+ } ) ;
0 commit comments