blob: 70c7f286fcb727cfa51194e4f412ffccdd444dd3 [file] [log] [blame]
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Tests storage with named item access and Symbol properties.");
knownSymbol = Symbol();
localStorage.clear();
localStorage[Symbol()] = 1;
shouldBeTrue("localStorage.length === 0");
shouldBeTrue("localStorage[Symbol()] === undefined");
localStorage[knownSymbol] = 2;
shouldBeTrue("localStorage.length === 0");
shouldBeTrue("localStorage[knownSymbol] === 2"); // number
shouldNotThrow("delete localStorage[knownSymbol]");
shouldBeTrue("localStorage.length === 0");
shouldBeTrue("localStorage[knownSymbol] === undefined");
localStorage["Symbol()"] = 3;
shouldBeTrue("localStorage.length === 1");
shouldBeTrue("localStorage['Symbol()'] === '3'"); // string
shouldBeTrue("localStorage.key(0) === 'Symbol()'");
shouldBeTrue("localStorage[''] === undefined");
localStorage[''] = 4;
shouldBeTrue("localStorage[''] === '4'"); // string
shouldBeTrue("localStorage.length === 2");
shouldNotThrow("delete localStorage['Symbol()']");
shouldBeTrue("localStorage.length === 1");
shouldBeTrue("localStorage['Symbol()'] === undefined"); // string
shouldNotThrow("delete localStorage['']");
shouldBeTrue("localStorage.length === 0");
shouldBeTrue("localStorage[''] === undefined"); // string
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>