Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / domstorage / localstorage / enumerate-with-length-and-key.html
bloba99a3cbec2d119dc515770f078d8f7e3d840b811
1 <html>
2 <head>
3 <script>
5 if (window.testRunner)
6 testRunner.dumpAsText();
8 function log(a)
10 document.getElementById("logger").innerHTML += a + "<br>";
13 function startTest()
15 if (!window.localStorage) {
16 log("window.localStorage DOES NOT exist");
17 return;
19 localStorage.clear();
21 Storage.prototype.prototypeTestKey = "prototypeTestValue";
22 localStorage.foo = "bar";
23 localStorage.fu = "baz";
24 localStorage.batman = "bin suparman";
25 localStorage.bar = "foo";
26 localStorage.alpha = "beta";
27 localStorage.zeta = "gamma";
29 // Enumerate localStorage, appending each key onto an array
30 var enumeratedArray = new Array();
31 for (var i=0; i<localStorage.length; ++i)
32 enumeratedArray.push(localStorage.key(i));
34 // Sort the array, since the storage order isn't guaranteed
35 enumeratedArray.sort();
37 for (var n in enumeratedArray)
38 log(enumeratedArray[n]);
41 </script>
42 </head>
43 <body onload="startTest();">
44 This test attempts to enumerate all the keys in localStorage with .length + .key(). The built-in properties of the Storage object should be ignored. The test operates on the localStorage object.<br>
45 <div id="logger"></div>
46 </body>
47 </html>