2009-07-28 Jeremy Orlow <jorlow@chromium.org>
authorjorlow@chromium.org <jorlow@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jul 2009 20:28:40 +0000 (20:28 +0000)
committerjorlow@chromium.org <jorlow@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jul 2009 20:28:40 +0000 (20:28 +0000)
        Reviewed by Adam Barth.

        Add some checks to existing DOM Storage LayoutTests.
        https://bugs.webkit.org/show_bug.cgi?id=27695

        This is really a mixed bag of tweaks to existing tests.

        * storage/domstorage/localstorage/delete-removal-expected.txt:
        * storage/domstorage/localstorage/delete-removal.html:
              Made output more readable, added redundant deletes, added deletes to
              keys with the same name in different case.
        * storage/domstorage/localstorage/enumerate-storage.html:
              Removed dead code.
        * storage/domstorage/localstorage/enumerate-with-length-and-key-expected.txt: Added.
        * storage/domstorage/localstorage/enumerate-with-length-and-key.html: Copied from LayoutTests/storage/domstorage/localstorage/enumerate-storage.html.
              Test enumerating by hand (with length+key).
        * storage/domstorage/localstorage/iframe-events-expected.txt:
        * storage/domstorage/localstorage/iframe-events.html:
              Test removeItem and clear in addition to setItem.
        * storage/domstorage/localstorage/onstorage-attribute-setwindow-expected.txt: Copied from LayoutTests/storage/domstorage/localstorage/onstorage-attribute-setattribute-expected.txt.
        * storage/domstorage/localstorage/onstorage-attribute-setwindow.html: Copied from LayoutTests/storage/domstorage/localstorage/onstorage-attribute-setattribute.html.
              Test using window.onstorage.
        * storage/domstorage/window-attributes-exist-expected.txt:
        * storage/domstorage/window-attributes-exist.html:
              Verify that two consecutive calls to window.____Storage will equal each other.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@46498 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/domstorage/localstorage/delete-removal-expected.txt
LayoutTests/storage/domstorage/localstorage/delete-removal.html
LayoutTests/storage/domstorage/localstorage/enumerate-storage.html
LayoutTests/storage/domstorage/localstorage/enumerate-with-length-and-key-expected.txt [new file with mode: 0644]
LayoutTests/storage/domstorage/localstorage/enumerate-with-length-and-key.html [new file with mode: 0644]
LayoutTests/storage/domstorage/localstorage/iframe-events-expected.txt
LayoutTests/storage/domstorage/localstorage/iframe-events.html
LayoutTests/storage/domstorage/localstorage/onstorage-attribute-setwindow-expected.txt [new file with mode: 0644]
LayoutTests/storage/domstorage/localstorage/onstorage-attribute-setwindow.html [new file with mode: 0644]
LayoutTests/storage/domstorage/window-attributes-exist-expected.txt
LayoutTests/storage/domstorage/window-attributes-exist.html

index 6d6ad40..5ee93e2 100644 (file)
@@ -1,3 +1,31 @@
+2009-07-28  Jeremy Orlow  <jorlow@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Add some checks to existing DOM Storage LayoutTests.
+        https://bugs.webkit.org/show_bug.cgi?id=27695
+
+        This is really a mixed bag of tweaks to existing tests.
+
+        * storage/domstorage/localstorage/delete-removal-expected.txt:
+        * storage/domstorage/localstorage/delete-removal.html:
+              Made output more readable, added redundant deletes, added deletes to
+              keys with the same name in different case.
+        * storage/domstorage/localstorage/enumerate-storage.html:
+              Removed dead code.
+        * storage/domstorage/localstorage/enumerate-with-length-and-key-expected.txt: Added.
+        * storage/domstorage/localstorage/enumerate-with-length-and-key.html: Copied from LayoutTests/storage/domstorage/localstorage/enumerate-storage.html.
+              Test enumerating by hand (with length+key).
+        * storage/domstorage/localstorage/iframe-events-expected.txt:
+        * storage/domstorage/localstorage/iframe-events.html:
+              Test removeItem and clear in addition to setItem.
+        * storage/domstorage/localstorage/onstorage-attribute-setwindow-expected.txt: Copied from LayoutTests/storage/domstorage/localstorage/onstorage-attribute-setattribute-expected.txt.
+        * storage/domstorage/localstorage/onstorage-attribute-setwindow.html: Copied from LayoutTests/storage/domstorage/localstorage/onstorage-attribute-setattribute.html.
+              Test using window.onstorage.
+        * storage/domstorage/window-attributes-exist-expected.txt:
+        * storage/domstorage/window-attributes-exist.html:
+              Verify that two consecutive calls to window.____Storage will equal each other.
+
 2009-07-28  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
 
         Reviewed by George Staikos.
index f66244f..b50b617 100644 (file)
@@ -1,9 +1,13 @@
 This test makes sure that using the syntax `delete localStorage.keyName` works as an alias to `localStorage.removeItem(keyName).`
-foo is: undefined
-foo is: bar
-foo is: undefined
-foo is: bar
-foo is: undefined
-foo is: bar
-foo is: undefined
+foo (before anything) is: undefined
+foo (after a named property settter set) is: bar
+foo (after a delete) is: undefined
+foo (after an indexed setter set) is: bar
+foo (after deleting FOO (not foo)) is: bar
+foo (after a delete) is: undefined
+foo (after calling setItem) is: bar
+foo (after a delete) is: undefined
+foo (after a redundant delete) is: undefined
+foo (after an implicit settter set) is: bar
+foo (after an indexed delete) is: undefined
 
index 8745e0d..85d1278 100644 (file)
@@ -19,19 +19,27 @@ function runTest()
         return;
     }
     
-    log("foo is: " + localStorage.foo);
+    log("foo (before anything) is: " + localStorage.foo);
     localStorage.foo = "bar";
-    log("foo is: " + localStorage.foo);
+    log("foo (after a named property settter set) is: " + localStorage.foo);
     delete localStorage.foo;
-    log("foo is: " + localStorage.foo);
+    log("foo (after a delete) is: " + localStorage.foo);
     localStorage["foo"] = "bar";
-    log("foo is: " + localStorage.foo);
+    log("foo (after an indexed setter set) is: " + localStorage.foo);
+    delete localStorage.FOO;
+    log("foo (after deleting FOO (not foo)) is: " + localStorage.foo);
     delete localStorage.foo;
-    log("foo is: " + localStorage.foo);
+    log("foo (after a delete) is: " + localStorage.foo);
     localStorage.setItem("foo", "bar");
-    log("foo is: " + localStorage.foo);
+    log("foo (after calling setItem) is: " + localStorage.foo);
     delete localStorage.foo;
-    log("foo is: " + localStorage.foo);
+    log("foo (after a delete) is: " + localStorage.foo);
+    delete localStorage.foo;
+    log("foo (after a redundant delete) is: " + localStorage.foo);
+    localStorage.foo = "bar";
+    log("foo (after an implicit settter set) is: " + localStorage.foo);
+    delete localStorage["foo"];
+    log("foo (after an indexed delete) is: " + localStorage.foo);
 }
 
 </script>
index 2d5a2b7..b45a419 100644 (file)
@@ -11,12 +11,6 @@ function log(a)
     document.getElementById("logger").innerHTML += a + "<br>";
 }
 
-function finish()
-{
-    if (window.layoutTestController)
-        layoutTestController.notifyDone()
-}
-
 function startTest()
 {
     if (!window.localStorage) {
diff --git a/LayoutTests/storage/domstorage/localstorage/enumerate-with-length-and-key-expected.txt b/LayoutTests/storage/domstorage/localstorage/enumerate-with-length-and-key-expected.txt
new file mode 100644 (file)
index 0000000..7b61676
--- /dev/null
@@ -0,0 +1,8 @@
+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.
+alpha
+bar
+batman
+foo
+fu
+zeta
+
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 (file)
index 0000000..aa77dcd
--- /dev/null
@@ -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>
index 804bc05..6c5dc86 100644 (file)
@@ -1,6 +1,6 @@
 This is the main frame of a 2-frame document. Each frame is in the same security origin and therefore shares the same localStorage object. As a result, each frame should receive a StorageEvent when either frame changes the localStorage object.
 
-Main frame about to change localStorage...
+Main frame about to run setItem on localStorage...
 Main Frame received StorageEvent:
 Key - Main Frame
 New Value - SET
@@ -34,4 +34,56 @@ URI - LayoutTests/storage/domstorage/localstorage/resources/iframe-events-second
 Source - LayoutTests/storage/domstorage/localstorage/resources/iframe-events-second.html
 Storage Area - This window's window.localStorage
 
+Main frame about to run removeItem on localStorage...
+Main Frame received StorageEvent:
+Key - Main Frame
+New Value - null
+Old Value - SET
+URI - LayoutTests/storage/domstorage/localstorage/iframe-events.html
+Source - LayoutTests/storage/domstorage/localstorage/iframe-events.html
+Storage Area - This window's window.localStorage
+
+Subframe received storage event:
+Key - Main Frame
+New Value - null
+Old Value - SET
+URI - LayoutTests/storage/domstorage/localstorage/iframe-events.html
+Source - LayoutTests/storage/domstorage/localstorage/iframe-events.html
+Storage Area - This window's window.localStorage
+
+Subframe about to change localStorage...
+Main frame about to clear localStorage...
+Main Frame received StorageEvent:
+Key - 
+New Value - null
+Old Value - null
+URI - LayoutTests/storage/domstorage/localstorage/iframe-events.html
+Source - LayoutTests/storage/domstorage/localstorage/iframe-events.html
+Storage Area - This window's window.localStorage
+
+Subframe received storage event:
+Key - 
+New Value - null
+Old Value - null
+URI - LayoutTests/storage/domstorage/localstorage/iframe-events.html
+Source - LayoutTests/storage/domstorage/localstorage/iframe-events.html
+Storage Area - This window's window.localStorage
+
+Subframe about to change localStorage...
+Main Frame received StorageEvent:
+Key - Subframe
+New Value - SET
+Old Value - null
+URI - LayoutTests/storage/domstorage/localstorage/resources/iframe-events-second.html
+Source - LayoutTests/storage/domstorage/localstorage/resources/iframe-events-second.html
+Storage Area - This window's window.localStorage
+
+Subframe received storage event:
+Key - Subframe
+New Value - SET
+Old Value - null
+URI - LayoutTests/storage/domstorage/localstorage/resources/iframe-events-second.html
+Source - LayoutTests/storage/domstorage/localstorage/resources/iframe-events-second.html
+Storage Area - This window's window.localStorage
+
 
index 93376ed..e928ca6 100644 (file)
@@ -48,8 +48,12 @@ function startTest()
     }
 
     window.addEventListener("storage", handleStorageEvent, false);
-    log("Main frame about to change localStorage...");
+    log("Main frame about to run setItem on localStorage...");
     localStorage.setItem("Main Frame", "SET");
+    log("Main frame about to run removeItem on localStorage...");
+    localStorage.removeItem("Main Frame");
+    log("Main frame about to clear localStorage...");
+    localStorage.clear();
 }
 
 </script>
diff --git a/LayoutTests/storage/domstorage/localstorage/onstorage-attribute-setwindow-expected.txt b/LayoutTests/storage/domstorage/localstorage/onstorage-attribute-setwindow-expected.txt
new file mode 100644 (file)
index 0000000..e42bea7
--- /dev/null
@@ -0,0 +1,22 @@
+This is a test to make sure LocalStorage mutations fire StorageEvents that are caught by the event listener corresponding to window.onstorage.
+Storage event fired:
+Key - FOO
+New Value - BAR
+Old Value - null
+
+Storage event fired:
+Key - FU
+New Value - BAR
+Old Value - null
+
+Storage event fired:
+Key - FOO
+New Value - null
+Old Value - BAR
+
+Storage event fired:
+Key - FU
+New Value - null
+Old Value - BAR
+
+
diff --git a/LayoutTests/storage/domstorage/localstorage/onstorage-attribute-setwindow.html b/LayoutTests/storage/domstorage/localstorage/onstorage-attribute-setwindow.html
new file mode 100644 (file)
index 0000000..65436ff
--- /dev/null
@@ -0,0 +1,49 @@
+<html>
+<head>
+<script src="resources/clearLocalStorage.js"></script>
+<script>
+
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function log(a)
+{
+    document.getElementById("logger").innerHTML += a + "<br>";
+}
+
+function handleStorageEvent()
+{
+    if (!window.event) {
+        log("Global event not available.");
+        return;
+    }
+    
+    log("Storage event fired:");
+    log("Key           - " + event.key);
+    log("New Value     - " + event.newValue);
+    log("Old Value     - " + event.oldValue);
+    log("");
+}
+
+function runTest()
+{
+    if (!window.localStorage) {
+        log("window.localStorage DOES NOT exist");
+        return;
+    }
+
+    window.onstorage = handleStorageEvent;
+    
+    window.localStorage.setItem("FOO", "BAR");
+    window.localStorage.setItem("FU", "BAR");
+    window.localStorage.removeItem("FOO");
+    window.localStorage.removeItem("FU");
+}
+
+</script>
+</head>
+<body onload="runTest();">
+This is a test to make sure LocalStorage mutations fire StorageEvents that are caught by the event listener corresponding to window.onstorage.<br>
+<div id="logger"></div>
+</body>
+</html>
index a8b3b7f..09b47c5 100644 (file)
@@ -5,12 +5,18 @@ Storage object sessionStorage has key
 Storage object sessionStorage has getItem
 Storage object sessionStorage has setItem
 Storage object sessionStorage has removeItem
+Storage object sessionStorage has clear
+window.sessionStorage == window.sessionStorage: true
+window.sessionStorage === window.sessionStorage: true
 window.localStorage exists
 Storage object localStorage has length
 Storage object localStorage has key
 Storage object localStorage has getItem
 Storage object localStorage has setItem
 Storage object localStorage has removeItem
+Storage object localStorage has clear
+window.localStorage == window.localStorage: true
+window.localStorage === window.localStorage: true
 window.onstorage exists
 The onstorage property works when a storage event is fired.
 
index 935bf13..3e3be04 100644 (file)
@@ -22,6 +22,8 @@ function testStorage(name, storage)
         log("Storage object " + name + " has setItem");
     if ("removeItem" in storage)
         log("Storage object " + name + " has removeItem");
+    if ("clear" in storage)
+        log("Storage object " + name + " has clear");
 }
 
 function testOnstorage()
@@ -39,12 +41,16 @@ function runTest()
     if ("sessionStorage" in window) {
         log("window.sessionStorage exists");
         testStorage("sessionStorage", window.sessionStorage);
+        log("window.sessionStorage == window.sessionStorage: " + (window.sessionStorage == window.sessionStorage));
+        log("window.sessionStorage === window.sessionStorage: " + (window.sessionStorage === window.sessionStorage));
     } else
         log("window.sessionStorage DOES NOT exist");
 
     if ("localStorage" in window) {
         log("window.localStorage exists");
         testStorage("localStorage", window.localStorage);
+        log("window.localStorage == window.localStorage: " + (window.localStorage == window.localStorage));
+        log("window.localStorage === window.localStorage: " + (window.localStorage === window.localStorage));
     } else
         log("window.localStorage DOES NOT exist");