Permalink
Browse files

Update dom/storage test

  • Loading branch information...
1 parent 7039bc4 commit 81a904c57b0916a8ab1f751921ca40957d4e6b01 @janodvarko janodvarko committed Apr 12, 2012
Showing with 25 additions and 95 deletions.
  1. +0 −15 tests/content/dom/storage/storage.html
  2. +25 −80 tests/content/dom/storage/storage.js
View
15 tests/content/dom/storage/storage.html
@@ -14,13 +14,11 @@
<li>Refresh the page (or pick <i>Refresh</i> from DOM panel option menu).</li>
<br/>
<li>Verify following properties:<br/>
-<code>globalStorage</code> should display <code>0 items in Storage</code><br/>
<code>localStorage</code> should display <code>0 items in Storage</code><br/>
<code>sessionStorage</code> should display <code>0 items in Storage</code><br/>
<br/>
</li>
<li>Switch to the Console panel and verify the log<br/>
-<code>globalStorage</code> <span style="color: green">0 items in Storage</span><br/>
<code>localStorage</code> <span style="color: green">0 items in Storage</span><br/>
<code>sessionStorage</code> <span style="color: green">0 items in Storage</span><br/>
<br/>
@@ -29,13 +27,11 @@
<li>Click on the <code style="color:green">Init Storage</code> button below and refresh the page.</li>
<br/>
<li>Verify following properties:<br/>
-<code>globalStorage</code> should display <code>1 item in Storage test1="Hello1"</code><br/>
<code>localStorage</code> should display <code>10 items in Storage item6="6", item3="3", more...</code><br/>
<code>sessionStorage</code> should display <code>2 items in Storage issue="value1", name="item1"</code><br/>
</li>
<br/>
<li>Switch to the Console panel and verify the log<br/>
-<code>globalStorage:</code> <span style="color: green">1 item in Storage test1="Hello1"</span><br/>
<code>localStorage:</code> <span style="color: green">10 items in Storage item6="6", item3="3", item8="8", item0="0", item5="5", item2="2", item7="7", item4="4", item9="9", item1="1"</span><br/>
<code>sessionStorage:</code> <span style="color: green">2 items in Storage issue="value1", name="item1"</span><br/>
<br/>
@@ -65,12 +61,6 @@
if (window.console)
console.log("sessionStorage: ", sessionStorage);
-
- // Initialize global storage
- globalStorage[location.hostname].test1 = "Hello1";
-
- if (window.console)
- console.log("globalStorage: ", globalStorage);
}
function clearStorage()
@@ -84,11 +74,6 @@
if (window.console)
console.log("sessionStorage: ", sessionStorage);
-
- delete globalStorage[location.hostname].test1;
-
- if (window.console)
- console.log("globalStorage: ", sessionStorage);
}
</script>
View
105 tests/content/dom/storage/storage.js
@@ -1,3 +1,5 @@
+var Fx13 = FBTest.compareFirefoxVersion("13.0a1") >= 0;
+
/**
* Test for DOM session and local storage.
*
@@ -14,37 +16,32 @@ function runTest()
{
var tasks = new FBTest.TaskList();
tasks.push(testEmptySessionStorage, win);
- tasks.push(executeAndVerify, "sessionStorage",
+ 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(executeAndVerify, "localStorage",
+ tasks.push(FBTest.executeCommandAndVerify, "localStorage",
new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [0]) + "\\s*"),
"a", "objectLink-Storage");
- tasks.push(testEmptyGlobalStorage, win);
- tasks.push(executeAndVerify, "globalStorage",
- new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [0]) + "\\s*"),
- "a", "objectLink-StorageList");
+ var expected = Fx13 ?
+ "\\s*name=\\\"item1\\\",\\s*issue=\\\"value1\\\"\\s*" :
+ "\\s*issue=\\\"value1\\\",\\s*name=\\\"item1\\\"\\s*";
tasks.push(testSessionStorageData, win);
- tasks.push(executeAndVerify, "sessionStorage",
- new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [2]) +
- "\\s*issue=\\\"value1\\\",\\s*name=\\\"item1\\\"\\s*"),
+ tasks.push(FBTest.executeCommandAndVerify, "sessionStorage",
+ new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [2]) + expected),
"a", "objectLink-Storage");
- tasks.push(testLocalStorageData, win);
- tasks.push(executeAndVerify, "localStorage",
- new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [10]) +
- "\\s*item6=\\\"6\\\", item3=\\\"3\\\", item8=\\\"8\\\", item0=\\\"0\\\", item5=\\\"5\\\", item2=\\\"2\\\", item7=\\\"7\\\", item4=\\\"4\\\", item9=\\\"9\\\", item1=\\\"1\\\""),
- "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(testGlobalStorageData, win);
- tasks.push(executeAndVerify, "globalStorage",
- new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [1]) +
- "\\s*test1=\\\"Hello1\\\"\\s*"),
- "a", "objectLink-StorageList");
+ 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()
{
@@ -84,28 +81,16 @@ function testEmptyLocalStorage(callback, win)
panel.rebuild(true);
}
-function testEmptyGlobalStorage(callback, win)
-{
- FBTest.waitForDOMProperty("localStorage", function(row)
- {
- FBTest.compare(new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [0]) + "\\s*"),
- row.textContent, "The global 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]) +
- "\\s*issue=\\\"value1\\\",\\s*name=\\\"item1\\\"\\s*"),
+ new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [2]) + expected),
row.textContent, "The session storage must have proper data");
callback();
});
@@ -120,26 +105,12 @@ function testLocalStorageData(callback, win)
{
FBTest.waitForDOMProperty("localStorage", function(row)
{
- FBTest.compare(
- new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [10]) +
- "\\s*item6=\\\"6\\\",\\s*item3=\\\"3\\\",\\s*" + FW.FBL.$STR("firebug.reps.more") + "...\\s*"),
- 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);
-}
+ var expected = Fx13 ?
+ "\\s*item6=\\\"6\\\",\\s*item7=\\\"7\\\",\\s*" + FW.FBL.$STR("firebug.reps.more") + "...\\s*" :
+ "\\s*item6=\\\"6\\\",\\s*item3=\\\"3\\\",\\s*" + FW.FBL.$STR("firebug.reps.more") + "...\\s*";
-function testGlobalStorageData(callback, win)
-{
- FBTest.waitForDOMProperty("globalStorage", function(row)
- {
FBTest.compare(
- new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [1]) +
- "\\s*test1=\\\"Hello1\\\"\\s*"),
+ new RegExp("\\s*" + FW.FBL.$STRP("firebug.storage.totalItems", [10]) + expected),
row.textContent, "The local storage must have proper data");
callback();
});
@@ -150,29 +121,3 @@ function testGlobalStorageData(callback, win)
panel.rebuild(true);
}
-// ********************************************************************************************* //
-// xxxHonza: could be part of FBTest namespace.
-
-/**
- * Helper function for executing expression on the command line.
- * @param {Function} callback Appended by the test harness.
- * @param {String} expression Expression to be executed.
- * @param {String} expected Expected value displayed.
- * @param {String} tagName Name of the displayed element.
- * @param {String} class Class of the displayed element.
- */
-function executeAndVerify(callback, expression, expected, tagName, classes)
-{
- var config = {tagName: tagName, classes: classes};
- FBTest.waitForDisplayedElement("console", config, function(row)
- {
- FBTest.compare(expected, row.textContent, "Verify: " +
- expression + " SHOULD BE " + expected);
-
- FBTest.clickToolbarButton(null, "fbConsoleClear");
- callback();
- });
-
- FBTest.selectPanel("console");
- FBTest.executeCommand(expression);
-}

0 comments on commit 81a904c

Please sign in to comment.