diff options
Diffstat (limited to '')
-rw-r--r-- | testing/web-platform/tests/webstorage/storage_length.window.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webstorage/storage_length.window.js b/testing/web-platform/tests/webstorage/storage_length.window.js new file mode 100644 index 0000000000..9648e48c8d --- /dev/null +++ b/testing/web-platform/tests/webstorage/storage_length.window.js @@ -0,0 +1,23 @@ +["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)"); +}); |