forked from firebug/firebug
/
storage.js
123 lines (105 loc) · 4.63 KB
/
storage.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
var Fx13 = FBTest.compareFirefoxVersion("13.0a1") >= 0;
/**
* Test for DOM session and local storage.
*
* Related issues:
* Issue 3611: localStorage and sessionStorage not shown in DOM panel
*/
function runTest()
{
FBTest.sysout("storage.START");
FBTest.openNewTab(basePath + "dom/storage/storage.html", function(win)
{
FBTest.openFirebug();
FBTest.enableConsolePanel(function(win)
{
var tasks = new FBTest.TaskList();
tasks.push(testEmptySessionStorage, win);
tasks.push(FBTest.executeCommandAndVerify, "sessionStorage",
new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [0]) + "\\s*"),
"a", "objectLink-Storage");
tasks.push(testEmptyLocalStorage, win);
tasks.push(FBTest.executeCommandAndVerify, "localStorage",
new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [0]) + "\\s*"),
"a", "objectLink-Storage");
var expected = Fx13 ?
"\\s*name=\\\"item1\\\",\\s*issue=\\\"value1\\\"\\s*" :
"\\s*issue=\\\"value1\\\",\\s*name=\\\"item1\\\"\\s*";
tasks.push(testSessionStorageData, win);
tasks.push(FBTest.executeCommandAndVerify, "sessionStorage",
new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [2]) + expected),
"a", "objectLink-Storage");
var expected = Fx13 ?
"\\s*item6=\\\"6\\\", item7=\\\"7\\\", item0=\\\"0\\\", item8=\\\"8\\\", item1=\\\"1\\\", item2=\\\"2\\\", item3=\\\"3\\\", item9=\\\"9\\\", item4=\\\"4\\\", item5=\\\"5\\\"" :
"\\s*item6=\\\"6\\\", item3=\\\"3\\\", item8=\\\"8\\\", item0=\\\"0\\\", item5=\\\"5\\\", item2=\\\"2\\\", item7=\\\"7\\\", item4=\\\"4\\\", item9=\\\"9\\\", item1=\\\"1\\\"";
tasks.push(testLocalStorageData, win);
tasks.push(FBTest.executeCommandAndVerify, "localStorage",
new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [10]) + expected),
"a", "objectLink-Storage");
tasks.run(function()
{
FBTest.testDone("storage.DONE");
});
});
});
}
function testEmptySessionStorage(callback, win)
{
FBTest.waitForDOMProperty("sessionStorage", function(row)
{
FBTest.compare(new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [0]) + "\\s*"),
row.textContent, "The session storage must be empty now");
callback();
});
// Clear storage and refresh panel content.
FBTest.click(win.document.getElementById("clearStorage"));
var panel = FBTest.selectPanel("dom");
panel.rebuild(true);
}
function testEmptyLocalStorage(callback, win)
{
FBTest.waitForDOMProperty("localStorage", function(row)
{
FBTest.compare(new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [0]) + "\\s*"),
row.textContent, "The local storage must be empty now");
callback();
});
// Clear storage and refresh panel content.
FBTest.click(win.document.getElementById("clearStorage"));
var panel = FBTest.selectPanel("dom");
panel.rebuild(true);
}
function testSessionStorageData(callback, win)
{
FBTest.waitForDOMProperty("sessionStorage", function(row)
{
var expected = Fx13 ?
"\\s*name=\\\"item1\\\",\\s*issue=\\\"value1\\\"\\s*" :
"\\s*issue=\\\"value1\\\",\\s*name=\\\"item1\\\"\\s*";
FBTest.compare(
new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [2]) + expected),
row.textContent, "The session storage must have proper data");
callback();
});
// Init storage and refresh panel content.
FBTest.click(win.document.getElementById("initStorage"));
var panel = FBTest.selectPanel("dom");
panel.rebuild(true);
}
function testLocalStorageData(callback, win)
{
FBTest.waitForDOMProperty("localStorage", function(row)
{
var expected = Fx13 ?
"\\s*item6=\\\"6\\\",\\s*item7=\\\"7\\\",\\s*item0=\\\"0\\\",\\s*" + FW.FBL.$STR("firebug.reps.more") + "...\\s*" :
"\\s*item6=\\\"6\\\",\\s*item3=\\\"3\\\",\\s*" + FW.FBL.$STR("firebug.reps.more") + "...\\s*";
FBTest.compare(
new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [10]) + expected),
row.textContent, "The local storage must have proper data");
callback();
});
// Clear storage and refresh panel content.
FBTest.click(win.document.getElementById("initStorage"));
var panel = FBTest.selectPanel("dom");
panel.rebuild(true);
}