1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>localStorage key order test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<!--
Check we preserve order of keys in localStorage when
keys are just modified. When a new key is added or
a key is removed order is again unspecified.
-->
<script type="text/javascript">
function startTest()
{
try
{
var keyNames = new Array;
localStorage.a = "1";
localStorage.b = "2";
localStorage.c = "3";
localStorage.d = "4";
localStorage.e = "5";
is(localStorage.a, "1", "a = 1");
is(localStorage.b, "2", "b = 2");
is(localStorage.c, "3", "c = 3");
is(localStorage.d, "4", "d = 4");
is(localStorage.e, "5", "e = 5");
is(localStorage.length, 5, "length = 5");
for (var i = 0; i < localStorage.length; ++i)
keyNames[i] = localStorage.key(i);
localStorage.a = "10";
localStorage.b = "20";
localStorage.c = "30";
localStorage.d = "40";
localStorage.e = "50";
is(localStorage.a, "10", "a = 10");
is(localStorage.b, "20", "b = 20");
is(localStorage.c, "30", "c = 30");
is(localStorage.d, "40", "d = 40");
is(localStorage.e, "50", "e = 50");
is(localStorage.length, 5, "length = 5");
for (var i = 0; i < localStorage.length; ++i)
is(keyNames[i], localStorage.key(i), "key "+keyNames[i]+" on same index");
keyNamesStringify = "[\"" + keyNames.join("\",\"") + "\"]";
frame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/localstorage/frameOrder.html?" +
keyNamesStringify;
}
catch (ex)
{
localStorage.clear();
throw ex;
}
}
SimpleTest.waitForExplicitFinish();
</script>
</head>
<body onload="startTest();">
<iframe src="" name="frame"></frame>
</body>
</html>
|