Changeset 51480 in webkit
- Timestamp:
- Nov 29, 2009 8:15:40 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r51478 r51480 1 2009-11-28 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 postMessage should serialize File objects 6 https://bugs.webkit.org/show_bug.cgi?id=31955 7 8 Add test for postMessage serialization of File objects. 9 10 * fast/dom/Window/window-postmessage-clone-expected.txt: 11 * fast/dom/Window/window-postmessage-clone.html: 12 1 13 2009-11-29 Simon Fraser <simon.fraser@apple.com> 2 14 -
trunk/LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt
r49229 r51480 17 17 PASS: eventData is 2009-02-13T23:31:30.000Z of type object 18 18 PASS: eventData is [object Array](default toString threw RangeError: Maximum call stack size exceeded.) of type object 19 PASS: eventData is [object File] of type object 19 20 PASS: eventData is done of type string 20 21 -
trunk/LayoutTests/fast/dom/Window/window-postmessage-clone.html
r49229 r51480 4 4 <div id="description"></div> 5 5 <div id="console"></div> 6 <input type="file" id="fileInput"></input> 6 7 <script> 7 8 if (window.layoutTestController) { … … 124 125 tryPostMessage('window', true); 125 126 127 var fileInput = document.getElementById("fileInput"); 128 var fileRect = fileInput.getClientRects()[0]; 129 var targetX = fileRect.left + fileRect.width / 2; 130 var targetY = fileRect.top + fileRect.height / 2; 131 eventSender.beginDragWithFiles(['get-file-upload.html']); 132 eventSender.mouseMoveTo(targetX, targetY); 133 eventSender.mouseUp(); 134 135 tryPostMessage('fileInput.files[0]', false, fileInput.files[0]); 136 126 137 tryPostMessage('"done"'); 127 138 </script> -
trunk/WebCore/ChangeLog
r51476 r51480 1 2009-11-28 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 postMessage should serialize File objects 6 https://bugs.webkit.org/show_bug.cgi?id=31955 7 8 Update SerializedScriptValue to include support for 9 File objects in the serialized object graph. 10 11 * bindings/js/SerializedScriptValue.cpp: 12 (WebCore::SerializedScriptValueData::SerializedScriptValueData): 13 (WebCore::SerializingTreeWalker::convertIfTerminal): 14 (WebCore::DeserializingTreeWalker::convertIfTerminal): 15 * bindings/js/SerializedScriptValue.h: 16 (WebCore::SerializedScriptValueData::): 17 (WebCore::SerializedScriptValueData::asString): 18 1 19 2009-11-29 Simon Fraser <simon.fraser@apple.com> 2 20 -
trunk/WebCore/bindings/js/SerializedScriptValue.cpp
r51256 r51480 28 28 #include "SerializedScriptValue.h" 29 29 30 #include "File.h" 31 #include "JSDOMGlobalObject.h" 32 #include "JSFile.h" 33 #include "JSFileList.h" 30 34 #include <JavaScriptCore/APICast.h> 31 35 #include <runtime/DateInstance.h> … … 147 151 : m_type(ArrayType) 148 152 , m_sharedData(data) 153 { 154 } 155 156 SerializedScriptValueData::SerializedScriptValueData(const File* file) 157 : m_type(FileType) 158 , m_string(file->path().crossThreadString()) 149 159 { 150 160 } … … 483 493 return SerializedScriptValueData(); 484 494 485 CallData unusedData; 486 if (value.isObject() && value.getCallData(unusedData) == CallTypeNone) 487 return SerializedScriptValueData(); 488 495 if (value.isObject()) { 496 JSObject* obj = asObject(value); 497 if (obj->inherits(&JSFile::s_info)) 498 return SerializedScriptValueData(toFile(obj)); 499 500 CallData unusedData; 501 if (value.getCallData(unusedData) == CallTypeNone) 502 return SerializedScriptValueData(); 503 } 489 504 // Any other types are expected to serialize as null. 490 505 return SerializedScriptValueData(jsNull()); … … 642 657 case SerializedScriptValueData::DateType: 643 658 return new (m_exec) DateInstance(m_exec, value.asDouble()); 659 case SerializedScriptValueData::FileType: 660 return toJS(m_exec, static_cast<JSDOMGlobalObject*>(m_exec->lexicalGlobalObject()), File::create(value.asString().crossThreadString())); 644 661 default: 645 662 ASSERT_NOT_REACHED(); -
trunk/WebCore/bindings/js/SerializedScriptValue.h
r51256 r51480 34 34 35 35 namespace WebCore { 36 class File; 36 37 class SerializedObject; 37 38 class SerializedArray; … … 55 56 ObjectType, 56 57 ArrayType, 57 StringType 58 StringType, 59 FileType 58 60 }; 59 61 … … 78 80 { 79 81 } 82 83 explicit SerializedScriptValueData(const File*); 80 84 81 85 explicit SerializedScriptValueData(JSC::JSValue value) … … 109 113 String asString() const 110 114 { 111 ASSERT(m_type == StringType );115 ASSERT(m_type == StringType || m_type == FileType); 112 116 return m_string; 113 117 }
Note: See TracChangeset
for help on using the changeset viewer.