Title: [120430] trunk/LayoutTests
Revision
120430
Author
commit-qu...@webkit.org
Date
2012-06-15 02:33:12 -0700 (Fri, 15 Jun 2012)

Log Message

Web Inspector: LayoutTest http/tests/inspector/filesystem/* should clean up FileSystem after test.
https://bugs.webkit.org/show_bug.cgi?id=89066

Patch by Taiju Tsuiki <t...@chromium.org> on 2012-06-15
Reviewed by Vsevolod Vlasov.

* http/tests/inspector/filesystem/filesystem-test.js:
(initialize_FileSystemTest.InspectorTest.clearFileSystem):
(dispatchCallback):
(createDirectory.gotFileSystem):
(createDirectory):
(createFile.gotFileSystem):
(clearFileSystem.gotRoot):
(clearFileSystem.gotRoot.removeAll):
(clearFileSystem.onError):
* http/tests/inspector/filesystem/read-directory.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (120429 => 120430)


--- trunk/LayoutTests/ChangeLog	2012-06-15 09:30:18 UTC (rev 120429)
+++ trunk/LayoutTests/ChangeLog	2012-06-15 09:33:12 UTC (rev 120430)
@@ -1,3 +1,21 @@
+2012-06-15  Taiju Tsuiki  <t...@chromium.org>
+
+        Web Inspector: LayoutTest http/tests/inspector/filesystem/* should clean up FileSystem after test.
+        https://bugs.webkit.org/show_bug.cgi?id=89066
+
+        Reviewed by Vsevolod Vlasov.
+
+        * http/tests/inspector/filesystem/filesystem-test.js:
+        (initialize_FileSystemTest.InspectorTest.clearFileSystem):
+        (dispatchCallback):
+        (createDirectory.gotFileSystem):
+        (createDirectory):
+        (createFile.gotFileSystem):
+        (clearFileSystem.gotRoot):
+        (clearFileSystem.gotRoot.removeAll):
+        (clearFileSystem.onError):
+        * http/tests/inspector/filesystem/read-directory.html:
+
 2012-06-15  Kent Tamura  <tk...@chromium.org>
 
         [Chromium] Update TestExpectations

Modified: trunk/LayoutTests/http/tests/inspector/filesystem/filesystem-test.js (120429 => 120430)


--- trunk/LayoutTests/http/tests/inspector/filesystem/filesystem-test.js	2012-06-15 09:30:18 UTC (rev 120429)
+++ trunk/LayoutTests/http/tests/inspector/filesystem/filesystem-test.js	2012-06-15 09:33:12 UTC (rev 120430)
@@ -29,6 +29,11 @@
         InspectorTest.evaluateInPage("createFile(unescape(\"" + escape(path) + "\"), " + InspectorTest.registerCallback(callback) + ")");
     };
 
+    InspectorTest.clearFileSystem = function(callback)
+    {
+        InspectorTest.evaluateInPage("clearFileSystem(" + InspectorTest.registerCallback(callback) + ")");
+    };
+
     InspectorTest.dumpReadDirectoryResult = function(requestId, errorCode, entries)
     {
         InspectorTest.addResult("requestId: " + requestId);
@@ -51,23 +56,71 @@
 function dispatchCallback()
 {
     var args = JSON.stringify(Array.prototype.slice.call(arguments));
-    layoutTestController.evaluateInWebInspector(0, "InspectorTest.dispatchCallback(unescape(\"" + escape(args) + "\"))");
+    testRunner.evaluateInWebInspector(999, "InspectorTest.dispatchCallback(unescape(\"" + escape(args) + "\"))");
 }
 
 function createDirectory(path, callback)
 {
-    webkitRequestFileSystem(TEMPORARY, 1, function(fs) {
-        fs.root.getDirectory(path, {create:true}, function(entry) {
+    webkitRequestFileSystem(TEMPORARY, 1, gotFileSystem);
+
+    function gotFileSystem(fileSystem)
+    {
+        fileSystem.root.getDirectory(path, {create:true}, function(entry) {
             callback();
         });
-    });
+    }
 }
 
 function createFile(path, callback)
 {
-    webkitRequestFileSystem(TEMPORARY, 1, function(fs) {
-        fs.root.getFile(path, {create:true}, function(entry) {
+    webkitRequestFileSystem(TEMPORARY, 1, gotFileSystem);
+
+    function gotFileSystem(fileSystem)
+    {
+        fileSystem.root.getFile(path, {create:true}, function(entry) {
             callback();
         });
-    });
+    }
 }
+
+function clearFileSystem(callback)
+{
+    webkitResolveLocalFileSystemURL("filesystem:" + location.origin + "/temporary/", gotRoot, onError);
+
+    function gotRoot(root)
+    {
+        var reader = root.createReader();
+        reader.readEntries(didReadEntries);
+
+        var entries = [];
+        function didReadEntries(newEntries)
+        {
+            if (newEntries.length === 0) {
+                removeAll();
+                return;
+            }
+            for (var i = 0; i < newEntries.length; ++i)
+                entries.push(newEntries[i]);
+            reader.readEntries(didReadEntries);
+        }
+
+        function removeAll()
+        {
+            if (entries.length === 0) {
+                callback();
+                return;
+            }
+            var entry = entries.shift();
+            if (entry.isDirectory)
+                entry.removeRecursively(removeAll);
+            else
+                entry.remove(removeAll);
+        }
+    }
+
+    function onError()
+    {
+        // Assume the FileSystem is uninitialized and therefore empty.
+        callback();
+    }
+}

Modified: trunk/LayoutTests/http/tests/inspector/filesystem/read-directory.html (120429 => 120430)


--- trunk/LayoutTests/http/tests/inspector/filesystem/read-directory.html	2012-06-15 09:30:18 UTC (rev 120429)
+++ trunk/LayoutTests/http/tests/inspector/filesystem/read-directory.html	2012-06-15 09:33:12 UTC (rev 120430)
@@ -16,7 +16,7 @@
     InspectorBackend.registerFileSystemDispatcher(new FileSystemDispatcher());
     FileSystemAgent.enable();
 
-    step1();
+    InspectorTest.clearFileSystem(step1);
 
     function step1()
     {
@@ -52,6 +52,11 @@
     function step6(requestId, errorCode, entries) {
         InspectorTest.dumpReadDirectoryResult(requestId, errorCode, entries);
 
+        InspectorTest.clearFileSystem(step7);
+    }
+
+    function step7()
+    {
         InspectorTest.completeTest();
     }
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to