node/test/fixtures/wpt/webstorage/storage_length.window.js
cjihrig 3d09e579d3 deps,lib,src: add experimental web storage
This commit introduces an experimental implementation of the Web
Storage API using SQLite as the backing data store.

PR-URL: https://github.com/nodejs/node/pull/52435
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
2024-06-14 18:40:04 +00:00

24 lines
702 B
JavaScript

["localStorage", "sessionStorage"].forEach(function(name) {
test(function() {
var storage = window[name];
storage.clear();
assert_equals(storage.length, 0, "storage.length")
storage["name"] = "user1";
storage["age"] = "20";
assert_equals(storage.length, 2, "storage.length")
}, name + ".length (method access)");
test(function() {
var storage = window[name];
storage.clear();
assert_equals(storage.length, 0, "storage.length")
storage.setItem("name", "user1");
storage.setItem("age", "20");
assert_equals(storage.length, 2, "storage.length")
}, name + ".length (proprty access)");
});