[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

oliver at apple.com oliver at apple.com
Wed Apr 7 23:59:54 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 88ed9c19d98aa0fa9b20b42218b60bee18748b92
Author: oliver at apple.com <oliver at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 30 04:15:40 2009 +0000

    postMessage should serialize File objects
    https://bugs.webkit.org/show_bug.cgi?id=31955
    
    Reviewed by Sam Weinig.
    
    Update SerializedScriptValue to include support for
    File objects in the serialized object graph.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51480 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index e808a8c..afa5767 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2009-11-28  Oliver Hunt  <oliver at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        postMessage should serialize File objects
+        https://bugs.webkit.org/show_bug.cgi?id=31955
+
+        Add test for postMessage serialization of File objects.
+
+        * fast/dom/Window/window-postmessage-clone-expected.txt:
+        * fast/dom/Window/window-postmessage-clone.html:
+
 2009-11-29  Simon Fraser  <simon.fraser at apple.com>
 
         Rubber-stamped by Eric Seidel.
diff --git a/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt b/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
index 495ea7c..2353f19 100644
--- a/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
+++ b/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
@@ -16,5 +16,6 @@ PASS: eventData is ,,1 of type object
 PASS: eventData is null of type object
 PASS: eventData is 2009-02-13T23:31:30.000Z of type object
 PASS: eventData is [object Array](default toString threw RangeError: Maximum call stack size exceeded.) of type object
+PASS: eventData is [object File] of type object
 PASS: eventData is done of type string
 
diff --git a/LayoutTests/fast/dom/Window/window-postmessage-clone.html b/LayoutTests/fast/dom/Window/window-postmessage-clone.html
index 68e66c6..31f9c9a 100644
--- a/LayoutTests/fast/dom/Window/window-postmessage-clone.html
+++ b/LayoutTests/fast/dom/Window/window-postmessage-clone.html
@@ -3,6 +3,7 @@
 <body>
 <div id="description"></div>
 <div id="console"></div>
+<input type="file" id="fileInput"></input>
 <script>
 if (window.layoutTestController) {
     layoutTestController.dumpAsText();
@@ -123,6 +124,16 @@ for (var i = 0; i < 100000; i++)
 tryPostMessage('reallyDeepArray', true);
 tryPostMessage('window', true);
 
+var fileInput = document.getElementById("fileInput");
+var fileRect = fileInput.getClientRects()[0];
+var targetX = fileRect.left + fileRect.width / 2;
+var targetY = fileRect.top + fileRect.height / 2;
+eventSender.beginDragWithFiles(['get-file-upload.html']);
+eventSender.mouseMoveTo(targetX, targetY);
+eventSender.mouseUp();
+
+tryPostMessage('fileInput.files[0]', false, fileInput.files[0]);
+
 tryPostMessage('"done"');
 </script>
 </body>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1bc57fa..1c44253 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2009-11-28  Oliver Hunt  <oliver at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        postMessage should serialize File objects
+        https://bugs.webkit.org/show_bug.cgi?id=31955
+
+        Update SerializedScriptValue to include support for
+        File objects in the serialized object graph.
+
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::SerializedScriptValueData::SerializedScriptValueData):
+        (WebCore::SerializingTreeWalker::convertIfTerminal):
+        (WebCore::DeserializingTreeWalker::convertIfTerminal):
+        * bindings/js/SerializedScriptValue.h:
+        (WebCore::SerializedScriptValueData::):
+        (WebCore::SerializedScriptValueData::asString):
+
 2009-11-29  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/WebCore/bindings/js/SerializedScriptValue.cpp b/WebCore/bindings/js/SerializedScriptValue.cpp
index 2e17c19..7a2d645 100644
--- a/WebCore/bindings/js/SerializedScriptValue.cpp
+++ b/WebCore/bindings/js/SerializedScriptValue.cpp
@@ -27,6 +27,10 @@
 #include "config.h"
 #include "SerializedScriptValue.h"
 
+#include "File.h"
+#include "JSDOMGlobalObject.h"
+#include "JSFile.h"
+#include "JSFileList.h"
 #include <JavaScriptCore/APICast.h>
 #include <runtime/DateInstance.h>
 #include <runtime/ExceptionHelpers.h>
@@ -149,6 +153,12 @@ SerializedScriptValueData::SerializedScriptValueData(RefPtr<SerializedArray> dat
 {
 }
 
+SerializedScriptValueData::SerializedScriptValueData(const File* file)
+    : m_type(FileType)
+    , m_string(file->path().crossThreadString())
+{
+}
+
 SerializedArray* SharedSerializedData::asArray()
 {
     return static_cast<SerializedArray*>(this);
@@ -482,10 +492,15 @@ struct SerializingTreeWalker : public BaseWalker {
         if (isArray(value))
             return SerializedScriptValueData();
 
-        CallData unusedData;
-        if (value.isObject() && value.getCallData(unusedData) == CallTypeNone)
-            return SerializedScriptValueData();
-
+        if (value.isObject()) {
+            JSObject* obj = asObject(value);
+            if (obj->inherits(&JSFile::s_info))
+                return SerializedScriptValueData(toFile(obj));
+                
+            CallData unusedData;
+            if (value.getCallData(unusedData) == CallTypeNone)
+                return SerializedScriptValueData();
+        }
         // Any other types are expected to serialize as null.
         return SerializedScriptValueData(jsNull());
     }
@@ -641,6 +656,8 @@ struct DeserializingTreeWalker : public BaseWalker {
                 return jsNumber(m_exec, value.asDouble());
             case SerializedScriptValueData::DateType:
                 return new (m_exec) DateInstance(m_exec, value.asDouble());
+            case SerializedScriptValueData::FileType:
+                return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject()), File::create(value.asString().crossThreadString()));
             default:
                 ASSERT_NOT_REACHED();
                 return JSValue();
diff --git a/WebCore/bindings/js/SerializedScriptValue.h b/WebCore/bindings/js/SerializedScriptValue.h
index 3eb37ed..57a4a66 100644
--- a/WebCore/bindings/js/SerializedScriptValue.h
+++ b/WebCore/bindings/js/SerializedScriptValue.h
@@ -33,6 +33,7 @@ typedef const struct OpaqueJSContext* JSContextRef;
 typedef const struct OpaqueJSValue* JSValueRef;
 
 namespace WebCore {
+    class File;
     class SerializedObject;
     class SerializedArray;
 
@@ -54,7 +55,8 @@ namespace WebCore {
             ImmediateType,
             ObjectType,
             ArrayType,
-            StringType
+            StringType,
+            FileType
         };
 
         SerializedType type() const { return m_type; }
@@ -77,6 +79,8 @@ namespace WebCore {
             , m_string(string.crossThreadString()) // FIXME: Should be able to just share the Rep
         {
         }
+        
+        explicit SerializedScriptValueData(const File*);
 
         explicit SerializedScriptValueData(JSC::JSValue value)
             : m_type(ImmediateType)
@@ -108,7 +112,7 @@ namespace WebCore {
 
         String asString() const
         {
-            ASSERT(m_type == StringType);
+            ASSERT(m_type == StringType || m_type == FileType);
             return m_string;
         }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list