Web Inspector: inspector/storage-panel-dom-storage-update.html is flakey on the bots
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Aug 2013 20:01:38 +0000 (20:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Aug 2013 20:01:38 +0000 (20:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=120544

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2013-08-30
Reviewed by Dean Jackson.

Explicitly listen for events instead of running callbacks after a delay.

* inspector/storage-panel-dom-storage-update.html:

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

LayoutTests/ChangeLog
LayoutTests/inspector/storage-panel-dom-storage-update.html

index 45e9555..36f10d7 100644 (file)
@@ -1,3 +1,14 @@
+2013-08-30  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: inspector/storage-panel-dom-storage-update.html is flakey on the bots
+        https://bugs.webkit.org/show_bug.cgi?id=120544
+
+        Reviewed by Dean Jackson.
+
+        Explicitly listen for events instead of running callbacks after a delay.
+
+        * inspector/storage-panel-dom-storage-update.html:
+
 2013-08-30  Dirk Schulze  <krit@webkit.org>
 
         Animate CSS Image filter() function
index 19aa722..7566477 100644 (file)
@@ -2,7 +2,6 @@
 <head>\r
 <script src="../http/tests/inspector/inspector-test.js"></script>\r
 <script>\r
-\r
 function addItem(key,value)\r
 {\r
     localStorage.setItem(key,value);\r
@@ -40,15 +39,46 @@ function test()
         InspectorTest.addResult("KeyValue pairs: [" + rows.join() + "]");\r
     }\r
 \r
+    var nextDOMStorageClearHandler = null;\r
+    InspectorTest.addSniffer(WebInspector.DOMStorageDispatcher.prototype, "domStorageItemsCleared", function() {\r
+        if (nextDOMStorageClearHandler) {\r
+            nextDOMStorageClearHandler();\r
+            nextDOMStorageClearHandler = null;\r
+        } else\r
+            InspectorTest.addResult("ERROR: domStorageItemsCleared event without handler");\r
+    }, true);\r
+\r
+    var nextDOMStorageAddHandler = null;\r
+    InspectorTest.addSniffer(WebInspector.DOMStorageDispatcher.prototype, "domStorageItemAdded", function() {\r
+        if (nextDOMStorageAddHandler) {\r
+            nextDOMStorageAddHandler();\r
+            nextDOMStorageAddHandler = null;\r
+        } else\r
+            InspectorTest.addResult("ERROR: domStorageItemAdded event without handler");\r
+    }, true);\r
+\r
+    var nextDOMStorageRemoveHandler = null;\r
+    InspectorTest.addSniffer(WebInspector.DOMStorageDispatcher.prototype, "domStorageItemRemoved", function() {\r
+        if (nextDOMStorageRemoveHandler) {\r
+            nextDOMStorageRemoveHandler();\r
+            nextDOMStorageRemoveHandler = null;\r
+        } else\r
+            InspectorTest.addResult("ERROR: domStorageItemRemoved event without handler");\r
+    }, true);\r
+\r
+\r
     InspectorTest.runTestSuite([\r
         function initialize(next)\r
         {\r
-            function initialized(result)\r
+            function didClear(result)\r
             {\r
                 InspectorTest.addResult("Initialized localStorage by clearing entries");\r
                 next();\r
             }\r
-            InspectorTest.evaluateInPage("clear()", initialized );\r
+\r
+            nextDOMStorageClearHandler = didClear;\r
+\r
+            InspectorTest.evaluateInPage("clear()");\r
         },\r
 \r
         function updateLocalStorageView(next)\r
@@ -59,6 +89,7 @@ function test()
                 InspectorTest.addResult("Resource Panel with localStorage view updated");\r
                 next();\r
             }\r
+\r
             var storages = WebInspector.domStorageModel.storages();\r
             for (var i = 0; i < storages.length; ++i) {\r
                 storage = storages[i];\r
@@ -74,8 +105,7 @@ function test()
         {\r
             function viewUpdatedAfterAddition()\r
             {\r
-                InspectorTest.runAfterPendingDispatches(function()\r
-                {\r
+                InspectorTest.runAfterPendingDispatches(function() {\r
                     rootNode = WebInspector.panels.resources._domStorageViews.get(storage)._dataGrid.rootNode();\r
                     dumpDataGrid();\r
                     if (count < 6)\r
@@ -85,13 +115,10 @@ function test()
                 });\r
             }\r
 \r
-            function itemAdded(result)\r
-            {\r
-                viewUpdatedAfterAddition();\r
-            }\r
+            nextDOMStorageAddHandler = viewUpdatedAfterAddition;\r
 \r
             InspectorTest.addResult("addItem('a"+count+"','=value"+count+"')");\r
-            InspectorTest.evaluateInPage("addItem('a"+count+"','=value"+count+"')", itemAdded );\r
+            InspectorTest.evaluateInPage("addItem('a"+count+"','=value"+count+"')");\r
             count++;\r
         },\r
 \r
@@ -109,14 +136,11 @@ function test()
                 });\r
             }\r
 \r
-            function itemRemoved(result)\r
-            {\r
-                setTimeout(viewUpdatedAfterRemoval, 0 );\r
-            }\r
+            nextDOMStorageRemoveHandler = viewUpdatedAfterRemoval;\r
 \r
             --count;\r
             InspectorTest.addResult("removeItem('a"+count+"')");\r
-            InspectorTest.evaluateInPage("removeItem('a"+count+"')", itemRemoved );\r
+            InspectorTest.evaluateInPage("removeItem('a"+count+"')");\r
         },\r
 \r
         function clearTest(next)\r
@@ -130,21 +154,16 @@ function test()
                 });\r
             }\r
 \r
-            function cleared(result)\r
-            {\r
-                setTimeout(viewUpdatedAfterClear, 0 );\r
-            }\r
+            nextDOMStorageClearHandler = viewUpdatedAfterClear;\r
 \r
             InspectorTest.addResult("clear()");\r
-            InspectorTest.evaluateInPage("clear()", cleared );\r
+            InspectorTest.evaluateInPage("clear()");\r
         }\r
     ]);\r
 }\r
 </script>\r
 </head>\r
-\r
 <body onload="runTest()">\r
 <p>Test that storage panel is present and that it contains correct data whenever localStorage is updated.</p>\r
 </body>\r
 </html>\r
-\r