Title: [120776] trunk
Revision
120776
Author
[email protected]
Date
2012-06-19 17:09:05 -0700 (Tue, 19 Jun 2012)

Log Message

Source/WebCore: Make DOMFileSystem selectively structure clonable so it can be the body of a web intent.
https://bugs.webkit.org/show_bug.cgi?id=88267

Patch by Steve VanDeBogart <[email protected]> on 2012-06-19
Reviewed by David Levin.

This functionality will allow FileSystem API objects to be dispatched to
web content in order to enable, for instance, an intent notifying web
content that a particular filesystem has been mounted by the local
system. The goal at this point is not to enable across-the-board
clonability, but just for handling the particular use case.

* bindings/v8/SerializedScriptValue.cpp:
(WebCore::V8ObjectMap::Writer::writeDOMFileSystem):
(WebCore::V8ObjectMap::Serializer::writeDOMFileSystem):
(WebCore::V8ObjectMap::Serializer::doSerialize):
(WebCore::V8ObjectMap::Reader::read):
(WebCore::V8ObjectMap::Reader::readDOMFileSystem):

LayoutTests: Add filesystem regression test to check that the filesystem object is
not serializable as created by _javascript_.
https://bugs.webkit.org/show_bug.cgi?id=88267

Patch by Greg Billock <[email protected]> on 2012-06-19
Reviewed by David Levin.

* fast/filesystem/filesystem-unserializable-expected.html: Added.
* fast/filesystem/filesystem-unserializable.html: Added.
* fast/filesystem/script-tests/filesystem-unserializable.js: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (120775 => 120776)


--- trunk/LayoutTests/ChangeLog	2012-06-20 00:07:03 UTC (rev 120775)
+++ trunk/LayoutTests/ChangeLog	2012-06-20 00:09:05 UTC (rev 120776)
@@ -1,3 +1,15 @@
+2012-06-19  Greg Billock  <[email protected]>
+
+        Add filesystem regression test to check that the filesystem object is
+        not serializable as created by _javascript_.
+        https://bugs.webkit.org/show_bug.cgi?id=88267
+
+        Reviewed by David Levin.
+
+        * fast/filesystem/filesystem-unserializable-expected.html: Added.
+        * fast/filesystem/filesystem-unserializable.html: Added.
+        * fast/filesystem/script-tests/filesystem-unserializable.js: Added.
+
 2012-06-19  Beth Dakin  <[email protected]>
 
         Skipping failing tests to keep the bots green. Filed 

Added: trunk/LayoutTests/fast/filesystem/filesystem-unserializable-expected.txt (0 => 120776)


--- trunk/LayoutTests/fast/filesystem/filesystem-unserializable-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/filesystem/filesystem-unserializable-expected.txt	2012-06-20 00:09:05 UTC (rev 120776)
@@ -0,0 +1,10 @@
+This tests if the filesystem object is unserializable by default
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+DATA_CLONE_ERR: DOM Exception 25
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/filesystem/filesystem-unserializable.html (0 => 120776)


--- trunk/LayoutTests/fast/filesystem/filesystem-unserializable.html	                        (rev 0)
+++ trunk/LayoutTests/fast/filesystem/filesystem-unserializable.html	2012-06-20 00:09:05 UTC (rev 120776)
@@ -0,0 +1,10 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/filesystem/script-tests/filesystem-unserializable.js (0 => 120776)


--- trunk/LayoutTests/fast/filesystem/script-tests/filesystem-unserializable.js	                        (rev 0)
+++ trunk/LayoutTests/fast/filesystem/script-tests/filesystem-unserializable.js	2012-06-20 00:09:05 UTC (rev 120776)
@@ -0,0 +1,29 @@
+description("This tests if the filesystem object is unserializable by default");
+
+function errorCallback(error)
+{
+    testFailed("Error occurred: " + error.code);
+    finishJSTest();
+}
+
+function fileSystemCallback(fs)
+{
+    try {
+        postMessage(fs, '*');
+    } catch (e) {
+        debug(e.message);
+    }
+
+    finishJSTest();
+}
+
+function onmessage()
+{
+}
+
+if (window.webkitRequestFileSystem) {
+    window.addEventListener('message', onmessage, false);
+    window.jsTestIsAsync = true;
+    webkitRequestFileSystem(window.TEMPORARY, 100, fileSystemCallback, errorCallback);
+} else
+    debug("This test requires FileSystem API support.");

Modified: trunk/Source/WebCore/ChangeLog (120775 => 120776)


--- trunk/Source/WebCore/ChangeLog	2012-06-20 00:07:03 UTC (rev 120775)
+++ trunk/Source/WebCore/ChangeLog	2012-06-20 00:09:05 UTC (rev 120776)
@@ -1,3 +1,23 @@
+2012-06-19  Steve VanDeBogart  <[email protected]>
+
+        Make DOMFileSystem selectively structure clonable so it can be the body of a web intent.
+        https://bugs.webkit.org/show_bug.cgi?id=88267
+
+        Reviewed by David Levin.
+
+        This functionality will allow FileSystem API objects to be dispatched to
+        web content in order to enable, for instance, an intent notifying web
+        content that a particular filesystem has been mounted by the local
+        system. The goal at this point is not to enable across-the-board
+        clonability, but just for handling the particular use case.
+
+        * bindings/v8/SerializedScriptValue.cpp:
+        (WebCore::V8ObjectMap::Writer::writeDOMFileSystem):
+        (WebCore::V8ObjectMap::Serializer::writeDOMFileSystem):
+        (WebCore::V8ObjectMap::Serializer::doSerialize):
+        (WebCore::V8ObjectMap::Reader::read):
+        (WebCore::V8ObjectMap::Reader::readDOMFileSystem):
+
 2012-06-19  Kenneth Russell  <[email protected]>
 
         Unreviewed, rolling out r120772.

Modified: trunk/Source/WebCore/Modules/filesystem/DOMFileSystemBase.cpp (120775 => 120776)


--- trunk/Source/WebCore/Modules/filesystem/DOMFileSystemBase.cpp	2012-06-20 00:07:03 UTC (rev 120775)
+++ trunk/Source/WebCore/Modules/filesystem/DOMFileSystemBase.cpp	2012-06-20 00:09:05 UTC (rev 120776)
@@ -62,6 +62,7 @@
     , m_name(name)
     , m_type(type)
     , m_filesystemRootURL(rootURL)
+    , m_clonable(false)
     , m_asyncFileSystem(asyncFileSystem)
 {
 }

Modified: trunk/Source/WebCore/Modules/filesystem/DOMFileSystemBase.h (120775 => 120776)


--- trunk/Source/WebCore/Modules/filesystem/DOMFileSystemBase.h	2012-06-20 00:07:03 UTC (rev 120775)
+++ trunk/Source/WebCore/Modules/filesystem/DOMFileSystemBase.h	2012-06-20 00:09:05 UTC (rev 120776)
@@ -78,6 +78,12 @@
     AsyncFileSystem* asyncFileSystem() const { return m_asyncFileSystem.get(); }
     SecurityOrigin* securityOrigin() const;
 
+    // The clonable flag is used in the structured clone algorithm to test
+    // whether the FileSystem API object is permitted to be cloned. It defaults
+    // to false, and must be explicitly set by internal code permit cloning.
+    void makeClonable() { m_clonable = true; }
+    bool clonable() const { return m_clonable; }
+
     static bool isValidType(FileSystemType);
     static bool crackFileSystemURL(const KURL&, FileSystemType&, String& filePath);
     bool supportsToURL() const;
@@ -104,6 +110,7 @@
     String m_name;
     FileSystemType m_type;
     KURL m_filesystemRootURL;
+    bool m_clonable;
 
     mutable OwnPtr<AsyncFileSystem> m_asyncFileSystem;
 };

Modified: trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp (120775 => 120776)


--- trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp	2012-06-20 00:07:03 UTC (rev 120775)
+++ trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp	2012-06-20 00:09:05 UTC (rev 120776)
@@ -31,25 +31,15 @@
 #include "config.h"
 #include "SerializedScriptValue.h"
 
-#include <wtf/ArrayBuffer.h>
-#include <wtf/ArrayBufferView.h>
+#include "AsyncFileSystem.h"
 #include "Blob.h"
 #include "DataView.h"
 #include "ExceptionCode.h"
 #include "File.h"
 #include "FileList.h"
-#include <wtf/Float32Array.h>
-#include <wtf/Float64Array.h>
 #include "ImageData.h"
-#include <wtf/Int16Array.h>
-#include <wtf/Int32Array.h>
-#include <wtf/Int8Array.h>
 #include "MessagePort.h"
 #include "SharedBuffer.h"
-#include <wtf/Uint16Array.h>
-#include <wtf/Uint32Array.h>
-#include <wtf/Uint8Array.h>
-#include <wtf/Uint8ClampedArray.h>
 #include "V8ArrayBuffer.h"
 #include "V8ArrayBufferView.h"
 #include "V8Binding.h"
@@ -71,10 +61,25 @@
 #include "V8Uint8ClampedArray.h"
 #include "V8Utilities.h"
 
+#include <wtf/ArrayBuffer.h>
+#include <wtf/ArrayBufferView.h>
 #include <wtf/Assertions.h>
+#include <wtf/Float32Array.h>
+#include <wtf/Float64Array.h>
+#include <wtf/Int16Array.h>
+#include <wtf/Int32Array.h>
+#include <wtf/Int8Array.h>
 #include <wtf/RefCounted.h>
+#include <wtf/Uint16Array.h>
+#include <wtf/Uint32Array.h>
+#include <wtf/Uint8Array.h>
+#include <wtf/Uint8ClampedArray.h>
 #include <wtf/Vector.h>
 
+#if ENABLE(FILE_SYSTEM)
+#include "V8DOMFileSystem.h"
+#endif
+
 // FIXME: consider crashing in debug mode on deserialization errors
 // NOTE: be sure to change wireFormatVersion as necessary!
 
@@ -187,6 +192,9 @@
     NumberTag = 'N', // value:double -> Number
     BlobTag = 'b', // url:WebCoreString, type:WebCoreString, size:uint64_t -> Blob (ref)
     FileTag = 'f', // file:RawFile -> File (ref)
+#if ENABLE(FILE_SYSTEM)
+    DOMFileSystemTag = 'd', // type:int32_t, name:WebCoreString, url:WebCoreString -> FileSystem (ref)
+#endif
     FileListTag = 'l', // length:uint32_t, files:RawFile[length] -> FileList (ref)
     ImageDataTag = '#', // width:uint32_t, height:uint32_t, pixelDataLength:uint32_t, data:byte[pixelDataLength] -> ImageData (ref)
     ObjectTag = '{', // numProperties:uint32_t -> pops the last object from the open stack;
@@ -360,6 +368,16 @@
         doWriteUint64(size);
     }
 
+#if ENABLE(FILE_SYSTEM)
+    void writeDOMFileSystem(int type, const String& name, const String& url)
+    {
+        append(DOMFileSystemTag);
+        doWriteUint32(type);
+        doWriteWebCoreString(name);
+        doWriteWebCoreString(url);
+    }
+#endif
+
     void writeFile(const String& path, const String& url, const String& type)
     {
         append(FileTag);
@@ -982,6 +1000,19 @@
         m_blobURLs.append(blob->url().string());
     }
 
+#if ENABLE(FILE_SYSTEM)
+    StateBase* writeDOMFileSystem(v8::Handle<v8::Value> value, StateBase* next)
+    {
+        DOMFileSystem* fs = V8DOMFileSystem::toNative(value.As<v8::Object>());
+        if (!fs)
+            return 0;
+        if (!fs->clonable())
+            return handleError(DataCloneError, next);
+        m_writer.writeDOMFileSystem(fs->type(), fs->name(), fs->rootURL().string());
+        return 0;
+    }
+#endif
+
     void writeFile(v8::Handle<v8::Value> value)
     {
         File* file = V8File::toNative(value.As<v8::Object>());
@@ -1183,6 +1214,10 @@
             writeFile(value);
         else if (V8Blob::HasInstance(value))
             writeBlob(value);
+#if ENABLE(FILE_SYSTEM)
+        else if (V8DOMFileSystem::HasInstance(value))
+            return writeDOMFileSystem(value, next);
+#endif
         else if (V8FileList::HasInstance(value))
             writeFileList(value);
         else if (V8ImageData::HasInstance(value))
@@ -1320,6 +1355,13 @@
                 return false;
             creator.pushObjectReference(*value);
             break;
+#if ENABLE(FILE_SYSTEM)
+        case DOMFileSystemTag:
+            if (!readDOMFileSystem(value))
+                return false;
+            creator.pushObjectReference(*value);
+            break;
+#endif
         case FileListTag:
             if (!readFileList(value))
                 return false;
@@ -1729,6 +1771,24 @@
         return true;
     }
 
+#if ENABLE(FILE_SYSTEM)
+    bool readDOMFileSystem(v8::Handle<v8::Value>* value)
+    {
+        uint32_t type;
+        String name;
+        String url;
+        if (!doReadUint32(&type))
+            return false;
+        if (!readWebCoreString(&name))
+            return false;
+        if (!readWebCoreString(&url))
+            return false;
+        RefPtr<DOMFileSystem> fs = DOMFileSystem::create(getScriptExecutionContext(), name, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, url), AsyncFileSystem::create());
+        *value = toV8(fs.release(), m_isolate);
+        return true;
+    }
+#endif
+
     bool readFile(v8::Handle<v8::Value>* value)
     {
         String path;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to