diff options
Diffstat (limited to 'testing/web-platform/tests/webstorage/storage_builtins.html')
-rw-r--r-- | testing/web-platform/tests/webstorage/storage_builtins.html | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webstorage/storage_builtins.html b/testing/web-platform/tests/webstorage/storage_builtins.html new file mode 100644 index 000000000..2ae06d55b --- /dev/null +++ b/testing/web-platform/tests/webstorage/storage_builtins.html @@ -0,0 +1,24 @@ +<!DOCTYPE HTML> +<meta charset=utf-8> +<title>WebStorage Test: Storage - builtins</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> +["localStorage", "sessionStorage"].forEach(function(name) { + test(function() { + var storage = window[name]; + storage.clear(); + assert_equals(storage.length, 0, "storage.length"); + + var builtins = ["key", "getItem", "setItem", "removeItem", "clear"]; + var origBuiltins = builtins.map(function(b) { return Storage.prototype[b]; }); + assert_array_equals(builtins.map(function(b) { return storage[b]; }), origBuiltins, "a"); + builtins.forEach(function(b) { storage[b] = b; }); + assert_array_equals(builtins.map(function(b) { return storage[b]; }), origBuiltins, "b"); + assert_array_equals(builtins.map(function(b) { return storage.getItem(b); }), builtins, "c"); + + assert_equals(storage.length, builtins.length, "storage.length"); + }, "Builtins in " + name); +}); +</script> |