GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add coverage for webstorage quota · nodejs/node@5dbff81

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-webstorage.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-webstorage.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-webstorage.js
+37-1Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const tmpdir = require('../common/tmpdir');
44
const assert = require('node:assert');
55
const { join } = require('node:path');
66
const { readdir } = require('node:fs/promises');
7-
const { test } = require('node:test');
7+
const { test, describe } = require('node:test');
88
const { spawnPromisified } = common;
99
let cnt = 0;
1010

@@ -109,3 +109,39 @@ test('localStorage is persisted if it is used', async () => {
109109
assert.strictEqual(cp.code, 0);
110110
assert.match(cp.stdout, /barbaz/);
111111
});
112+
113+
114+
describe('webstorage quota for localStorage and sessionStorage', () => {
115+
const MAX_STORAGE_SIZE = 10 * 1024 * 1024;
116+
117+
test('localStorage can store and retrieve a max of 10 MB quota', async () => {
118+
const localStorageFile = nextLocalStorage();
119+
const cp = await spawnPromisified(process.execPath, [
120+
'--experimental-webstorage',
121+
'--localstorage-file', localStorageFile,
122+
// Each character is 2 bytes
123+
'-pe', `
124+
localStorage['a'.repeat(${MAX_STORAGE_SIZE} / 2)] = '';
125+
console.error('filled');
126+
localStorage.anything = 'should fail';
127+
`,
128+
]);
129+
130+
assert.match(cp.stderr, /filled/);
131+
assert.match(cp.stderr, /QuotaExceededError: Setting the value exceeded the quota/);
132+
});
133+
134+
test('sessionStorage can store a max of 10 MB quota', async () => {
135+
const cp = await spawnPromisified(process.execPath, [
136+
'--experimental-webstorage',
137+
// Each character is 2 bytes
138+
'-pe', `sessionStorage['a'.repeat(${MAX_STORAGE_SIZE} / 2)] = '';
139+
console.error('filled');
140+
sessionStorage.anything = 'should fail';
141+
`,
142+
]);
143+
144+
assert.match(cp.stderr, /filled/);
145+
assert.match(cp.stderr, /QuotaExceededError/);
146+
});
147+
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.