diff options
Diffstat (limited to 'LayoutTests/storage/domstorage/localstorage/enumerate-with-length-and-key.html')
-rw-r--r-- | LayoutTests/storage/domstorage/localstorage/enumerate-with-length-and-key.html | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/LayoutTests/storage/domstorage/localstorage/enumerate-with-length-and-key.html b/LayoutTests/storage/domstorage/localstorage/enumerate-with-length-and-key.html new file mode 100644 index 0000000..aa77dcd --- /dev/null +++ b/LayoutTests/storage/domstorage/localstorage/enumerate-with-length-and-key.html @@ -0,0 +1,47 @@ +<html> +<head> +<script src="resources/clearLocalStorage.js"></script> +<script> + +if (window.layoutTestController) + layoutTestController.dumpAsText(); + +function log(a) +{ + document.getElementById("logger").innerHTML += a + "<br>"; +} + +function startTest() +{ + if (!window.localStorage) { + log("window.localStorage DOES NOT exist"); + return; + } + + Storage.prototype.prototypeTestKey = "prototypeTestValue"; + localStorage.foo = "bar"; + localStorage.fu = "baz"; + localStorage.batman = "bin suparman"; + localStorage.bar = "foo"; + localStorage.alpha = "beta"; + localStorage.zeta = "gamma"; + + // Enumerate localStorage, appending each key onto an array + var enumeratedArray = new Array(); + for (var i=0; i<localStorage.length; ++i) + enumeratedArray.push(localStorage.key(i)); + + // Sort the array, since the storage order isn't guaranteed + enumeratedArray.sort(); + + for (var n in enumeratedArray) + log(enumeratedArray[n]); +} + +</script> +</head> +<body onload="startTest();"> +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> +<div id="logger"></div> +</body> +</html> |