Title: [126195] trunk
Revision
126195
Author
[email protected]
Date
2012-08-21 15:29:29 -0700 (Tue, 21 Aug 2012)

Log Message

Web Inspector: Completion events of InspectorFileSystemAgent should be fired asynchronously.
https://bugs.webkit.org/show_bug.cgi?id=93933

Patch by Taiju Tsuiki <[email protected]> on 2012-08-21
Reviewed by Yury Semikhatsky.

InspectorFileSystemAgent fires completion event too early in error case. It should wait
until JS code is ready.

Source/WebCore:

Test: http/tests/inspector/filesystem/request-directory-content.html
      http/tests/inspector/filesystem/request-file-content.html
      http/tests/inspector/filesystem/request-metadata.html

* inspector/InspectorFileSystemAgent.cpp:
(WebCore): Add ReportErrorTask class

LayoutTests:

* http/tests/inspector/filesystem/request-directory-content-expected.txt:
* http/tests/inspector/filesystem/request-directory-content.html: Add more error case test.
* http/tests/inspector/filesystem/request-file-content-expected.txt:
* http/tests/inspector/filesystem/request-file-content.html: Add more error case test.
* http/tests/inspector/filesystem/request-filesystem-root-expected.txt:
* http/tests/inspector/filesystem/request-metadata-expected.txt:
* http/tests/inspector/filesystem/request-metadata.html: Add more error case test.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (126194 => 126195)


--- trunk/LayoutTests/ChangeLog	2012-08-21 22:23:00 UTC (rev 126194)
+++ trunk/LayoutTests/ChangeLog	2012-08-21 22:29:29 UTC (rev 126195)
@@ -1,3 +1,21 @@
+2012-08-21  Taiju Tsuiki  <[email protected]>
+
+        Web Inspector: Completion events of InspectorFileSystemAgent should be fired asynchronously.
+        https://bugs.webkit.org/show_bug.cgi?id=93933
+
+        Reviewed by Yury Semikhatsky.
+
+        InspectorFileSystemAgent fires completion event too early in error case. It should wait
+        until JS code is ready.
+
+        * http/tests/inspector/filesystem/request-directory-content-expected.txt:
+        * http/tests/inspector/filesystem/request-directory-content.html: Add more error case test.
+        * http/tests/inspector/filesystem/request-file-content-expected.txt:
+        * http/tests/inspector/filesystem/request-file-content.html: Add more error case test.
+        * http/tests/inspector/filesystem/request-filesystem-root-expected.txt:
+        * http/tests/inspector/filesystem/request-metadata-expected.txt:
+        * http/tests/inspector/filesystem/request-metadata.html: Add more error case test.
+
 2012-08-21  Mike West  <[email protected]>
 
         Blocking a resource via Content Security Policy should trigger an Error event.

Modified: trunk/LayoutTests/http/tests/inspector/filesystem/request-directory-content-expected.txt (126194 => 126195)


--- trunk/LayoutTests/http/tests/inspector/filesystem/request-directory-content-expected.txt	2012-08-21 22:23:00 UTC (rev 126194)
+++ trunk/LayoutTests/http/tests/inspector/filesystem/request-directory-content-expected.txt	2012-08-21 22:29:29 UTC (rev 126195)
@@ -1,5 +1,11 @@
 Tests requestDirectoryContent command.
 
+errorCode: 2
+entries: (null)
+
+errorCode: 8
+entries: (null)
+
 errorCode: 0
 entries:
   0:

Modified: trunk/LayoutTests/http/tests/inspector/filesystem/request-directory-content.html (126194 => 126195)


--- trunk/LayoutTests/http/tests/inspector/filesystem/request-directory-content.html	2012-08-21 22:23:00 UTC (rev 126194)
+++ trunk/LayoutTests/http/tests/inspector/filesystem/request-directory-content.html	2012-08-21 22:29:29 UTC (rev 126195)
@@ -28,6 +28,18 @@
 
         function()
         {
+            fileSystemRequestManager.requestDirectoryContent("InvalidURL", testStep.shift());
+        },
+
+        function(errorCode, entries)
+        {
+            InspectorTest.dumpDirectoryContentRequestResult(errorCode, entries);
+            fileSystemRequestManager.requestDirectoryContent("filesystem:http://127.0.0.1:8000/InvalidType/", testStep.shift());
+        },
+
+        function(errorCode, entries)
+        {
+            InspectorTest.dumpDirectoryContentRequestResult(errorCode, entries);
             fileSystemRequestManager.requestDirectoryContent("filesystem:http://127.0.0.1:8000/temporary/hoge", testStep.shift());
         },
 

Modified: trunk/LayoutTests/http/tests/inspector/filesystem/request-file-content-expected.txt (126194 => 126195)


--- trunk/LayoutTests/http/tests/inspector/filesystem/request-file-content-expected.txt	2012-08-21 22:23:00 UTC (rev 126194)
+++ trunk/LayoutTests/http/tests/inspector/filesystem/request-file-content-expected.txt	2012-08-21 22:29:29 UTC (rev 126195)
@@ -1,5 +1,13 @@
 Tests requestFileContent command.
 
+errorCode: 2
+content: (null)
+charset: undefined
+
+errorCode: 8
+content: (null)
+charset: undefined
+
 errorCode: 0
 content: "PASS"
 charset: UTF-8

Modified: trunk/LayoutTests/http/tests/inspector/filesystem/request-file-content.html (126194 => 126195)


--- trunk/LayoutTests/http/tests/inspector/filesystem/request-file-content.html	2012-08-21 22:23:00 UTC (rev 126194)
+++ trunk/LayoutTests/http/tests/inspector/filesystem/request-file-content.html	2012-08-21 22:29:29 UTC (rev 126195)
@@ -10,7 +10,6 @@
 {
     var fileSystemRequestManager = new WebInspector.FileSystemRequestManager();
 
-setTimeout(function() {InspectorTest.completeTest();}, 1000);
     var testStep = [
         function()
         {
@@ -24,6 +23,18 @@
 
         function()
         {
+            fileSystemRequestManager.requestFileContent("InvalidURL", true, 2, 6, "UTF-8", testStep.shift());
+        },
+
+        function(errorCode, content, charset)
+        {
+            InspectorTest.dumpFileContentRequestResult(errorCode, content, charset);
+            fileSystemRequestManager.requestFileContent("filesystem:http://127.0.0.1:8000/InvalidType/hoge/fuga.txt", true, 2, 6, "UTF-8", testStep.shift());
+        },
+
+        function(errorCode, content, charset)
+        {
+            InspectorTest.dumpFileContentRequestResult(errorCode, content, charset);
             fileSystemRequestManager.requestFileContent("filesystem:http://127.0.0.1:8000/temporary/hoge/fuga.txt", true, 2, 6, "UTF-8", testStep.shift());
         },
 

Modified: trunk/LayoutTests/http/tests/inspector/filesystem/request-filesystem-root-expected.txt (126194 => 126195)


--- trunk/LayoutTests/http/tests/inspector/filesystem/request-filesystem-root-expected.txt	2012-08-21 22:23:00 UTC (rev 126194)
+++ trunk/LayoutTests/http/tests/inspector/filesystem/request-filesystem-root-expected.txt	2012-08-21 22:29:29 UTC (rev 126195)
@@ -3,7 +3,7 @@
 errorCode: 0
 backendRootEntry.url: filesystem:http://127.0.0.1:8000/temporary/
 
-errorCode: 2
+errorCode: 8
 backendRootEntry: (null)
 
 errorCode: 2

Modified: trunk/LayoutTests/http/tests/inspector/filesystem/request-metadata-expected.txt (126194 => 126195)


--- trunk/LayoutTests/http/tests/inspector/filesystem/request-metadata-expected.txt	2012-08-21 22:23:00 UTC (rev 126194)
+++ trunk/LayoutTests/http/tests/inspector/filesystem/request-metadata-expected.txt	2012-08-21 22:29:29 UTC (rev 126195)
@@ -1,5 +1,11 @@
 Tests requestMetadata command.
 
+errorCode: 2
+metadata: (null)
+
+errorCode: 8
+metadata: (null)
+
 errorCode: 0
 metadata:
   modificationTime: (exists)

Modified: trunk/LayoutTests/http/tests/inspector/filesystem/request-metadata.html (126194 => 126195)


--- trunk/LayoutTests/http/tests/inspector/filesystem/request-metadata.html	2012-08-21 22:23:00 UTC (rev 126194)
+++ trunk/LayoutTests/http/tests/inspector/filesystem/request-metadata.html	2012-08-21 22:29:29 UTC (rev 126195)
@@ -18,6 +18,18 @@
 
         function()
         {
+            fileSystemRequestManager.requestMetadata("InvalidURL", testStep.shift());
+        },
+
+        function(errorCode, metadata)
+        {
+            InspectorTest.dumpMetadataRequestResult(errorCode, metadata);
+            fileSystemRequestManager.requestMetadata("filesystem:http://127.0.0.1:8000/InvalidType", testStep.shift());
+        },
+
+        function(errorCode, metadata)
+        {
+            InspectorTest.dumpMetadataRequestResult(errorCode, metadata);
             fileSystemRequestManager.requestMetadata("filesystem:http://127.0.0.1:8000/temporary/hoge", testStep.shift());
         },
 

Modified: trunk/Source/WebCore/ChangeLog (126194 => 126195)


--- trunk/Source/WebCore/ChangeLog	2012-08-21 22:23:00 UTC (rev 126194)
+++ trunk/Source/WebCore/ChangeLog	2012-08-21 22:29:29 UTC (rev 126195)
@@ -1,3 +1,20 @@
+2012-08-21  Taiju Tsuiki  <[email protected]>
+
+        Web Inspector: Completion events of InspectorFileSystemAgent should be fired asynchronously.
+        https://bugs.webkit.org/show_bug.cgi?id=93933
+
+        Reviewed by Yury Semikhatsky.
+
+        InspectorFileSystemAgent fires completion event too early in error case. It should wait
+        until JS code is ready.
+
+        Test: http/tests/inspector/filesystem/request-directory-content.html
+              http/tests/inspector/filesystem/request-file-content.html
+              http/tests/inspector/filesystem/request-metadata.html
+
+        * inspector/InspectorFileSystemAgent.cpp:
+        (WebCore): Add ReportErrorTask class
+
 2012-08-21  Mike West  <[email protected]>
 
         Blocking a resource via Content Security Policy should trigger an Error event.

Modified: trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp (126194 => 126195)


--- trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp	2012-08-21 22:23:00 UTC (rev 126194)
+++ trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp	2012-08-21 22:29:29 UTC (rev 126195)
@@ -141,10 +141,31 @@
     }
 };
 
+class ReportErrorTask : public ScriptExecutionContext::Task {
+public:
+    static PassOwnPtr<ReportErrorTask> create(PassRefPtr<ErrorCallback> errorCallback, FileError::ErrorCode errorCode)
+    {
+        return adoptPtr(new ReportErrorTask(errorCallback, errorCode));
+    }
+
+    virtual void performTask(ScriptExecutionContext*) OVERRIDE
+    {
+        m_errorCallback->handleEvent(FileError::create(m_errorCode).get());
+    }
+
+private:
+    ReportErrorTask(PassRefPtr<ErrorCallback> errorCallback, FileError::ErrorCode errorCode)
+        : m_errorCallback(errorCallback)
+        , m_errorCode(errorCode) { }
+
+    RefPtr<ErrorCallback> m_errorCallback;
+    FileError::ErrorCode m_errorCode;
+};
+
 class FileSystemRootRequest : public RefCounted<FileSystemRootRequest> {
     WTF_MAKE_NONCOPYABLE(FileSystemRootRequest);
 public:
-    static PassRefPtr<FileSystemRootRequest> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, FileSystemType type)
+    static PassRefPtr<FileSystemRootRequest> create(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& type)
     {
         return adoptRef(new FileSystemRootRequest(frontendProvider, requestId, type));
     }
@@ -163,14 +184,14 @@
         m_frontendProvider = 0;
     }
 
-    FileSystemRootRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, FileSystemType type)
+    FileSystemRootRequest(PassRefPtr<FrontendProvider> frontendProvider, int requestId, const String& type)
         : m_frontendProvider(frontendProvider)
         , m_requestId(requestId)
         , m_type(type) { }
 
     RefPtr<FrontendProvider> m_frontendProvider;
     int m_requestId;
-    FileSystemType m_type;
+    String m_type;
 };
 
 bool FileSystemRootRequest::didHitError(FileError* error)
@@ -181,11 +202,23 @@
 
 void FileSystemRootRequest::start(ScriptExecutionContext* scriptExecutionContext)
 {
-    RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &FileSystemRootRequest::didGetEntry);
+    ASSERT(scriptExecutionContext);
+
     RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &FileSystemRootRequest::didHitError);
-    OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, m_type, "/");
+    FileSystemType type;
+    if (m_type == DOMFileSystemBase::persistentPathPrefix)
+        type = FileSystemTypePersistent;
+    else if (m_type == DOMFileSystemBase::temporaryPathPrefix)
+        type = FileSystemTypeTemporary;
+    else {
+        scriptExecutionContext->postTask(ReportErrorTask::create(errorCallback, FileError::SYNTAX_ERR));
+        return;
+    }
 
-    LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, m_type, fileSystemCallbacks.release());
+    RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &FileSystemRootRequest::didGetEntry);
+    OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, "/");
+
+    LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
 }
 
 bool FileSystemRootRequest::didGetEntry(Entry* entry)
@@ -249,15 +282,15 @@
 {
     ASSERT(scriptExecutionContext);
 
+    RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &DirectoryContentRequest::didHitError);
     FileSystemType type;
     String path;
     if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) {
-        reportResult(FileError::SYNTAX_ERR);
+        scriptExecutionContext->postTask(ReportErrorTask::create(errorCallback, FileError::SYNTAX_ERR));
         return;
     }
 
     RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &DirectoryContentRequest::didGetEntry);
-    RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &DirectoryContentRequest::didHitError);
     OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
 
     LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
@@ -377,12 +410,17 @@
 
 void MetadataRequest::start(ScriptExecutionContext* scriptExecutionContext)
 {
+    ASSERT(scriptExecutionContext);
+
+    RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &MetadataRequest::didHitError);
+
     FileSystemType type;
-    DOMFileSystemBase::crackFileSystemURL(m_url, type, m_path);
+    if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, m_path)) {
+        scriptExecutionContext->postTask(ReportErrorTask::create(errorCallback, FileError::SYNTAX_ERR));
+        return;
+    }
 
     RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &MetadataRequest::didGetEntry);
-    RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &MetadataRequest::didHitError);
-
     OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, m_path);
     LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
 }
@@ -484,15 +522,16 @@
 {
     ASSERT(scriptExecutionContext);
 
+    RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &FileContentRequest::didHitError);
+
     FileSystemType type;
     String path;
     if (!DOMFileSystemBase::crackFileSystemURL(m_url, type, path)) {
-        reportResult(FileError::SYNTAX_ERR);
+        scriptExecutionContext->postTask(ReportErrorTask::create(errorCallback, FileError::SYNTAX_ERR));
         return;
     }
 
     RefPtr<EntryCallback> successCallback = CallbackDispatcherFactory<EntryCallback>::create(this, &FileContentRequest::didGetEntry);
-    RefPtr<ErrorCallback> errorCallback = CallbackDispatcherFactory<ErrorCallback>::create(this, &FileContentRequest::didHitError);
     OwnPtr<ResolveURICallbacks> fileSystemCallbacks = ResolveURICallbacks::create(successCallback, errorCallback, scriptExecutionContext, type, path);
 
     LocalFileSystem::localFileSystem().readFileSystem(scriptExecutionContext, type, fileSystemCallbacks.release());
@@ -579,7 +618,7 @@
     m_state->setBoolean(FileSystemAgentState::fileSystemAgentEnabled, m_enabled);
 }
 
-void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const String& origin, const String& typeString, int* requestId)
+void InspectorFileSystemAgent::requestFileSystemRoot(ErrorString* error, const String& origin, const String& type, int* requestId)
 {
     if (!m_enabled || !m_frontendProvider) {
         *error = "FileSystem agent is not enabled";
@@ -591,16 +630,6 @@
     if (!scriptExecutionContext)
         return;
 
-    FileSystemType type;
-    if (typeString == DOMFileSystemBase::persistentPathPrefix)
-        type = FileSystemTypePersistent;
-    else if (typeString == DOMFileSystemBase::temporaryPathPrefix)
-        type = FileSystemTypeTemporary;
-    else {
-        *error = "Invalid FileSystem type";
-        return;
-    }
-
     *requestId = m_nextRequestId++;
     FileSystemRootRequest::create(m_frontendProvider, *requestId, type)->start(scriptExecutionContext);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to