blob: 7bce1051437ec8c79cb5cc4716b872b76dda8adb [file] [log] [blame]
<!DOCTYPE HTML>
<meta charset=utf-8>
<title>WebStorage Test: Storage - indexed getter</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();
storage["name"] = "user1";
storage["age"] = "42";
test(function() {
assert_equals(storage[-1], undefined);
assert_equals(storage[0], undefined);
assert_equals(storage[1], undefined);
assert_equals(storage[2], undefined);
}, "Getting number properties on " + name);
test(function() {
assert_equals(storage["-1"], undefined);
assert_equals(storage["0"], undefined);
assert_equals(storage["1"], undefined);
assert_equals(storage["2"], undefined);
}, "Getting number-valued string properties on " + name);
test(function() {
storage.setItem(1, "number");
assert_equals(storage[1], "number");
assert_equals(storage["1"], "number");
}, "Getting existing number-valued properties on " + name);
}, "Indexed getter on " + name);
});
</script>