⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 266187 in webkit


Ignore:
Timestamp:
Aug 26, 2020, 1:18:23 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Implement DataTransfer constructor and multipart form filename encoding as other browsers do
https://bugs.webkit.org/show_bug.cgi?id=215837

Patch by Alex Christensen <achristensen@webkit.org> on 2020-08-26
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

  • web-platform-tests/FileAPI/file/send-file-form-expected.txt:
  • web-platform-tests/FileAPI/file/send-file-form-iso-2022-jp.tentative-expected.txt:
  • web-platform-tests/FileAPI/file/send-file-form-utf-8-expected.txt:
  • web-platform-tests/FileAPI/file/send-file-form-windows-1252.tentative-expected.txt:
  • web-platform-tests/FileAPI/file/send-file-form-x-user-defined.tentative-expected.txt:
  • web-platform-tests/html/editing/dnd/datastore/datatransfer-constructor-001-expected.txt:
  • web-platform-tests/html/editing/dnd/datastore/datatransfer-types-expected.txt:

This test still fails because of bindings issues. DataTransfer.types should apparently return
a cached JSValue that is updated whenever the contents change, which I don't think our bindings
generator can handle right now, so these tests are now failing in a different way.
I think that's fine because I think most uses of DataTransfer.types will just be checking the contents,
not whether its === to a stored reference like these tests do. We should fix this later.

  • web-platform-tests/html/semantics/forms/form-submission-0/submit-file.sub-expected.txt:
  • web-platform-tests/html/semantics/forms/form-submission-0/submit-file.sub.html:

Updated to successfully submit the form to a listening server in our test infrastructure,
so that we see PASS like we do now on wpt.live

  • web-platform-tests/service-workers/service-worker/data-transfer-files.https-expected.txt:

Source/WebCore:

Covered by newly passing WPT tests that Chrome and Firefox both pass.

  • dom/DataTransfer.cpp:

(WebCore::DataTransfer::create):

  • dom/DataTransfer.h:
  • dom/DataTransfer.idl:
  • platform/network/FormDataBuilder.cpp:

(WebCore::FormDataBuilder::addFilenameToMultiPartHeader):

LayoutTests:

  • fast/dom/dom-constructors-expected.txt:
  • fast/dom/dom-constructors.html:
Location:
trunk
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r266168 r266187  
     12020-08-26  Alex Christensen  <achristensen@webkit.org>
     2
     3        Implement DataTransfer constructor and multipart form filename encoding as other browsers do
     4        https://bugs.webkit.org/show_bug.cgi?id=215837
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * fast/dom/dom-constructors-expected.txt:
     9        * fast/dom/dom-constructors.html:
     10
    1112020-08-26  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/LayoutTests/fast/dom/dom-constructors-expected.txt

    r256716 r266187  
    8181PASS TryAllocate('CSSValue') is 'exception'
    8282PASS TryAllocate('CSSValueList') is 'exception'
    83 PASS TryAllocate('DataTransfer') is 'exception'
    8483PASS TryAllocate('DOMImplementation') is 'exception'
    8584PASS TryAllocate('HTMLCollection') is 'exception'
     
    125124PASS TryAllocate('DOMParser') is '[object DOMParser]'
    126125PASS TryAllocate('DOMParser') is '[object DOMParser]'
     126PASS TryAllocate('DataTransfer') is '[object DataTransfer]'
     127PASS TryAllocate('DataTransfer') is '[object DataTransfer]'
     128PASS TryAllocate('DataTransfer') is '[object DataTransfer]'
    127129PASS TryAllocate('Document') is '[object Document]'
    128130PASS TryAllocate('Document') is '[object Document]'
  • trunk/LayoutTests/fast/dom/dom-constructors.html

    r256716 r266187  
    9191    'CSSValue',
    9292    'CSSValueList',
    93     'DataTransfer',
    9493    'DOMImplementation',
    9594    'HTMLCollection',
     
    130129    'Comment',
    131130    'DOMParser',
     131    'DataTransfer',
    132132    'Document',
    133133    'DocumentFragment',
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r266186 r266187  
     12020-08-26  Alex Christensen  <achristensen@webkit.org>
     2
     3        Implement DataTransfer constructor and multipart form filename encoding as other browsers do
     4        https://bugs.webkit.org/show_bug.cgi?id=215837
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * web-platform-tests/FileAPI/file/send-file-form-expected.txt:
     9        * web-platform-tests/FileAPI/file/send-file-form-iso-2022-jp.tentative-expected.txt:
     10        * web-platform-tests/FileAPI/file/send-file-form-utf-8-expected.txt:
     11        * web-platform-tests/FileAPI/file/send-file-form-windows-1252.tentative-expected.txt:
     12        * web-platform-tests/FileAPI/file/send-file-form-x-user-defined.tentative-expected.txt:
     13        * web-platform-tests/html/editing/dnd/datastore/datatransfer-constructor-001-expected.txt:
     14        * web-platform-tests/html/editing/dnd/datastore/datatransfer-types-expected.txt:
     15        This test still fails because of bindings issues.  DataTransfer.types should apparently return
     16        a cached JSValue that is updated whenever the contents change, which I don't think our bindings
     17        generator can handle right now, so these tests are now failing in a different way.
     18        I think that's fine because I think most uses of DataTransfer.types will just be checking the contents,
     19        not whether its === to a stored reference like these tests do.  We should fix this later.
     20        * web-platform-tests/html/semantics/forms/form-submission-0/submit-file.sub-expected.txt:
     21        * web-platform-tests/html/semantics/forms/form-submission-0/submit-file.sub.html:
     22        Updated to successfully submit the form to a listening server in our test infrastructure,
     23        so that we see PASS like we do now on wpt.live
     24        * web-platform-tests/service-workers/service-worker/data-transfer-files.https-expected.txt:
     25
    1262020-08-26  Chris Dumez  <cdumez@apple.com>
    227
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-expected.txt

    r265749 r266187  
    11
    2 FAIL Upload file-for-upload-in-form.txt (ASCII) in UTF-8 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
     2PASS Upload file-for-upload-in-form.txt (ASCII) in UTF-8 form
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-iso-2022-jp.tentative-expected.txt

    r265749 r266187  
    11
    2 FAIL Upload file-for-upload-in-form.txt (ASCII) in ISO-2022-JP form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    3 FAIL Upload file-for-upload-in-form-.txt (x-user-defined) in ISO-2022-JP form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    4 FAIL Upload file-for-upload-in-form-☺😂.txt (windows-1252) in ISO-2022-JP form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    5 FAIL Upload file-for-upload-in-form-★星★.txt (JIS X 0201 and JIS X 0208) in ISO-2022-JP form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    6 FAIL Upload file-for-upload-in-form-☺😂.txt (Unicode) in ISO-2022-JP form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    7 FAIL Upload file-for-upload-in-form-ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ.txt (Unicode) in ISO-2022-JP form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
     2PASS Upload file-for-upload-in-form.txt (ASCII) in ISO-2022-JP form
     3PASS Upload file-for-upload-in-form-.txt (x-user-defined) in ISO-2022-JP form
     4PASS Upload file-for-upload-in-form-☺😂.txt (windows-1252) in ISO-2022-JP form
     5PASS Upload file-for-upload-in-form-★星★.txt (JIS X 0201 and JIS X 0208) in ISO-2022-JP form
     6PASS Upload file-for-upload-in-form-☺😂.txt (Unicode) in ISO-2022-JP form
     7PASS Upload file-for-upload-in-form-ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ.txt (Unicode) in ISO-2022-JP form
    88
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-utf-8-expected.txt

    r265749 r266187  
    11
    2 FAIL Upload file-for-upload-in-form.txt (ASCII) in UTF-8 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    3 FAIL Upload file-for-upload-in-form-.txt (x-user-defined) in UTF-8 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    4 FAIL Upload file-for-upload-in-form-☺😂.txt (windows-1252) in UTF-8 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    5 FAIL Upload file-for-upload-in-form-★星★.txt (JIS X 0201 and JIS X 0208) in UTF-8 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    6 FAIL Upload file-for-upload-in-form-☺😂.txt (Unicode) in UTF-8 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    7 FAIL Upload file-for-upload-in-form-ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ.txt (Unicode) in UTF-8 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
     2PASS Upload file-for-upload-in-form.txt (ASCII) in UTF-8 form
     3PASS Upload file-for-upload-in-form-.txt (x-user-defined) in UTF-8 form
     4PASS Upload file-for-upload-in-form-☺😂.txt (windows-1252) in UTF-8 form
     5PASS Upload file-for-upload-in-form-★星★.txt (JIS X 0201 and JIS X 0208) in UTF-8 form
     6PASS Upload file-for-upload-in-form-☺😂.txt (Unicode) in UTF-8 form
     7PASS Upload file-for-upload-in-form-ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ.txt (Unicode) in UTF-8 form
    88
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-windows-1252.tentative-expected.txt

    r265749 r266187  
    11
    2 FAIL Upload file-for-upload-in-form.txt (ASCII) in windows-1252 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    3 FAIL Upload file-for-upload-in-form-.txt (x-user-defined) in windows-1252 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    4 FAIL Upload file-for-upload-in-form-☺😂.txt (windows-1252) in windows-1252 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    5 FAIL Upload file-for-upload-in-form-★星★.txt (JIS X 0201 and JIS X 0208) in windows-1252 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    6 FAIL Upload file-for-upload-in-form-☺😂.txt (Unicode) in windows-1252 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    7 FAIL Upload file-for-upload-in-form-ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ.txt (Unicode) in windows-1252 form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
     2PASS Upload file-for-upload-in-form.txt (ASCII) in windows-1252 form
     3PASS Upload file-for-upload-in-form-.txt (x-user-defined) in windows-1252 form
     4PASS Upload file-for-upload-in-form-☺😂.txt (windows-1252) in windows-1252 form
     5PASS Upload file-for-upload-in-form-★星★.txt (JIS X 0201 and JIS X 0208) in windows-1252 form
     6PASS Upload file-for-upload-in-form-☺😂.txt (Unicode) in windows-1252 form
     7PASS Upload file-for-upload-in-form-ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ.txt (Unicode) in windows-1252 form
    88
  • trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/file/send-file-form-x-user-defined.tentative-expected.txt

    r265749 r266187  
    11
    2 FAIL Upload file-for-upload-in-form.txt (ASCII) in x-user-defined form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    3 FAIL Upload file-for-upload-in-form-.txt (x-user-defined) in x-user-defined form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    4 FAIL Upload file-for-upload-in-form-☺😂.txt (windows-1252) in x-user-defined form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    5 FAIL Upload file-for-upload-in-form-★星★.txt (JIS X 0201 and JIS X 0208) in x-user-defined form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    6 FAIL Upload file-for-upload-in-form-☺😂.txt (Unicode) in x-user-defined form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
    7 FAIL Upload file-for-upload-in-form-ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ.txt (Unicode) in x-user-defined form promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
     2PASS Upload file-for-upload-in-form.txt (ASCII) in x-user-defined form
     3PASS Upload file-for-upload-in-form-.txt (x-user-defined) in x-user-defined form
     4PASS Upload file-for-upload-in-form-☺😂.txt (windows-1252) in x-user-defined form
     5PASS Upload file-for-upload-in-form-★星★.txt (JIS X 0201 and JIS X 0208) in x-user-defined form
     6PASS Upload file-for-upload-in-form-☺😂.txt (Unicode) in x-user-defined form
     7PASS Upload file-for-upload-in-form-ABC~‾¥≈¤・・•∙·☼★星🌟星★☼·∙•・・¤≈¥‾~XYZ.txt (Unicode) in x-user-defined form
    88
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransfer-constructor-001-expected.txt

    r265749 r266187  
    11
    2 FAIL Verify DataTransfer constructor Illegal constructor
     2PASS Verify DataTransfer constructor
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/editing/dnd/datastore/datatransfer-types-expected.txt

    r265749 r266187  
    11
    2 FAIL type's state on DataTransfer creation Illegal constructor
    3 FAIL Relationship between types and items Illegal constructor
    4 FAIL type's identity Illegal constructor
    5 FAIL Verify type is a read-only attribute Illegal constructor
     2FAIL type's state on DataTransfer creation assert_equals: types must return the same object when the data store item list has not changed expected [] but got []
     3FAIL Relationship between types and items assert_equals: expected ["text/plain"] but got ["text/plain"]
     4FAIL type's identity assert_equals: expected ["text/plain"] but got ["text/plain"]
     5FAIL Verify type is a read-only attribute assert_equals: expected [] but got []
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/submit-file.sub-expected.txt

    r265749 r266187  
    22
    33
    4 FAIL Posting a File Illegal constructor
     4PASS Posting a File
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/submit-file.sub.html

    r249886 r266187  
    55<body>
    66<iframe id=testframe name=testframe></iframe>
    7 <form id=testform method=post action="//{{domains[www1]}}:{{location[port]}}/html/semantics/forms/form-submission-0/resources/file-submission.py" target=testframe enctype="multipart/form-data">
     7<form id=testform method=post action="http://{{hosts[alt][]}}:{{ports[http][0]}}/html/semantics/forms/form-submission-0/resources/file-submission.py" target=testframe enctype="multipart/form-data">
    88<input name=testinput id=testinput type=file>
    99</form>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/data-transfer-files.https-expected.txt

    r265749 r266187  
    22
    33
    4 FAIL Posting a File in a navigation handled by a service worker promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
     4PASS Posting a File in a navigation handled by a service worker
    55
  • trunk/Source/WebCore/ChangeLog

    r266186 r266187  
     12020-08-26  Alex Christensen  <achristensen@webkit.org>
     2
     3        Implement DataTransfer constructor and multipart form filename encoding as other browsers do
     4        https://bugs.webkit.org/show_bug.cgi?id=215837
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Covered by newly passing WPT tests that Chrome and Firefox both pass.
     9
     10        * dom/DataTransfer.cpp:
     11        (WebCore::DataTransfer::create):
     12        * dom/DataTransfer.h:
     13        * dom/DataTransfer.idl:
     14        * platform/network/FormDataBuilder.cpp:
     15        (WebCore::FormDataBuilder::addFilenameToMultiPartHeader):
     16
    1172020-08-26  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/Source/WebCore/dom/DataTransfer.cpp

    r266168 r266187  
    6969#endif
    7070
    71 DataTransfer::DataTransfer(StoreMode mode, std::unique_ptr<Pasteboard> pasteboard, Type type)
     71DataTransfer::DataTransfer(StoreMode mode, std::unique_ptr<Pasteboard> pasteboard, Type type, String&& effectAllowed)
    7272    : m_storeMode(mode)
    7373    , m_pasteboard(WTFMove(pasteboard))
     
    7575    , m_type(type)
    7676    , m_dropEffect("uninitialized"_s)
    77     , m_effectAllowed("uninitialized"_s)
     77    , m_effectAllowed(WTFMove(effectAllowed))
    7878    , m_shouldUpdateDragImage(false)
    7979#endif
    8080{
    8181#if !ENABLE(DRAG_SUPPORT)
     82    UNUSED_PARAM(effectAllowed);
    8283    ASSERT_UNUSED(type, type != Type::DragAndDropData && type != Type::DragAndDropFiles);
    8384#endif
     
    8990    dataTransfer->m_originIdentifier = document.originIdentifierForPasteboard();
    9091    return dataTransfer;
     92}
     93
     94Ref<DataTransfer> DataTransfer::create()
     95{
     96    return adoptRef(*new DataTransfer(StoreMode::ReadWrite, makeUnique<StaticPasteboard>(), Type::CopyAndPaste, "none"_s));
    9197}
    9298
  • trunk/Source/WebCore/dom/DataTransfer.h

    r266168 r266187  
    4848    enum class StoreMode { Invalid, ReadWrite, Readonly, Protected };
    4949
     50    static Ref<DataTransfer> create();
    5051    static Ref<DataTransfer> createForCopyAndPaste(const Document&, StoreMode, std::unique_ptr<Pasteboard>&&);
    5152    static Ref<DataTransfer> createForInputEvent(const String& plainText, const String& htmlText);
     
    115116private:
    116117    enum class Type { CopyAndPaste, DragAndDropData, DragAndDropFiles, InputEvent };
    117     DataTransfer(StoreMode, std::unique_ptr<Pasteboard>, Type = Type::CopyAndPaste);
     118    DataTransfer(StoreMode, std::unique_ptr<Pasteboard>, Type = Type::CopyAndPaste, String&& effectAllowed = "uninitialized"_s);
    118119
    119120#if ENABLE(DRAG_SUPPORT)
  • trunk/Source/WebCore/dom/DataTransfer.idl

    r266168 r266187  
    3030    SkipVTableValidation,
    3131] interface DataTransfer {
     32    constructor();
     33
    3234    attribute DOMString dropEffect;
    3335    attribute DOMString effectAllowed;
  • trunk/Source/WebCore/platform/network/FormDataBuilder.cpp

    r254046 r266187  
    176176void addFilenameToMultiPartHeader(Vector<char>& buffer, const TextEncoding& encoding, const String& filename)
    177177{
    178     // FIXME: This loses data irreversibly if the filename includes characters you can't encode
    179     // in the website's character set.
    180178    append(buffer, "; filename=\"");
    181     appendQuoted(buffer, encoding.encode(filename, UnencodableHandling::QuestionMarks));
     179    appendQuoted(buffer, encoding.encode(filename, UnencodableHandling::Entities));
    182180    append(buffer, '"');
    183181}
Note: See TracChangeset for help on using the changeset viewer.