Changeset 249361 in webkit


Ignore:
Timestamp:
Aug 31, 2019 3:16:40 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

XMLHttpRequest: responseXML returns null if the Content-Type is valid (end in +xml) in some cases
https://bugs.webkit.org/show_bug.cgi?id=46146

Patch by Rob Buis <rbuis@igalia.com> on 2019-08-31
Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Updated expected result.

  • web-platform-tests/xhr/responsexml-media-type-expected.txt:

Source/WebCore:

Make response MIME type fallback to text/xml in case mimeType could
not be extracted [1] and use the stricter ParsedContentType for that.

Behavior matches Firefox.

Test: web-platform-tests/xhr/responsexml-media-type.htm

[1] https://xhr.spec.whatwg.org/#response-mime-type

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::responseMIMEType const):

LayoutTests:

Adjust test to match the specification: make response MIME type fallback to
text/xml in case mimeType could not be extracted.

Behavior matches Firefox.

  • http/tests/xmlhttprequest/supported-xml-content-types-expected.txt:
  • http/tests/xmlhttprequest/supported-xml-content-types.html:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r249360 r249361  
     12019-08-31  Rob Buis  <rbuis@igalia.com>
     2
     3        XMLHttpRequest: responseXML returns null if the Content-Type is valid (end in +xml) in some cases
     4        https://bugs.webkit.org/show_bug.cgi?id=46146
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Adjust test to match the specification: make response MIME type fallback to
     9        text/xml in case mimeType could not be extracted.
     10
     11        Behavior matches Firefox.
     12
     13        * http/tests/xmlhttprequest/supported-xml-content-types-expected.txt:
     14        * http/tests/xmlhttprequest/supported-xml-content-types.html:
     15
    1162019-08-31  Frederic Wang  <fwang@igalia.com>
    217
  • trunk/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types-expected.txt

    r239040 r249361  
    4141PASS -- testing: foo*bar/baz+xml -- responseXML: [object XMLDocument]
    4242
     43PASS -- testing: foo bar/baz+xml -- responseXML: [object XMLDocument]
     44
     45PASS -- testing: foo[bar/baz+xml -- responseXML: [object XMLDocument]
     46
     47PASS -- testing: foo]bar/baz+xml -- responseXML: [object XMLDocument]
     48
     49PASS -- testing: foo(bar/baz+xml -- responseXML: [object XMLDocument]
     50
     51PASS -- testing: foo)bar/baz+xml -- responseXML: [object XMLDocument]
     52
     53PASS -- testing: foo
     54
     55PASS -- testing: foo>bar/baz+xml -- responseXML: [object XMLDocument]
     56
     57PASS -- testing: foo@bar/baz+xml -- responseXML: [object XMLDocument]
     58
     59PASS -- testing: foo,bar/baz+xml -- responseXML: [object XMLDocument]
     60
     61PASS -- testing: foo;bar/baz+xml -- responseXML: [object XMLDocument]
     62
     63PASS -- testing: foo:bar/baz+xml -- responseXML: [object XMLDocument]
     64
     65PASS -- testing: foo\bar/baz+xml -- responseXML: [object XMLDocument]
     66
     67PASS -- testing: foo"bar/baz+xml -- responseXML: [object XMLDocument]
     68
     69PASS -- testing: foo/bar/baz+xml -- responseXML: [object XMLDocument]
     70
     71PASS -- testing: foo?bar/baz+xml -- responseXML: [object XMLDocument]
     72
     73PASS -- testing: foo=bar/baz+xml -- responseXML: [object XMLDocument]
     74
     75PASS -- testing: invalid -- responseXML: [object XMLDocument]
     76
    4377PASS -- testing: text/html -- responseXML: null
    4478
    4579PASS -- testing: image/png -- responseXML: null
    46 
    47 PASS -- testing: invalid -- responseXML: null
    48 
    49 PASS -- testing: foo bar/baz+xml -- responseXML: null
    50 
    51 PASS -- testing: foo[bar/baz+xml -- responseXML: null
    52 
    53 PASS -- testing: foo]bar/baz+xml -- responseXML: null
    54 
    55 PASS -- testing: foo(bar/baz+xml -- responseXML: null
    56 
    57 PASS -- testing: foo)bar/baz+xml -- responseXML: null
    58 
    59 PASS -- testing: foo
    60 
    61 PASS -- testing: foo>bar/baz+xml -- responseXML: null
    62 
    63 PASS -- testing: foo@bar/baz+xml -- responseXML: null
    64 
    65 PASS -- testing: foo,bar/baz+xml -- responseXML: null
    66 
    67 PASS -- testing: foo;bar/baz+xml -- responseXML: null
    68 
    69 PASS -- testing: foo:bar/baz+xml -- responseXML: null
    70 
    71 PASS -- testing: foo\bar/baz+xml -- responseXML: null
    72 
    73 PASS -- testing: foo"bar/baz+xml -- responseXML: null
    74 
    75 PASS -- testing: foo/bar/baz+xml -- responseXML: null
    76 
    77 PASS -- testing: foo?bar/baz+xml -- responseXML: null
    78 
    79 PASS -- testing: foo=bar/baz+xml -- responseXML: null
  • trunk/LayoutTests/http/tests/xmlhttprequest/supported-xml-content-types.html

    r239040 r249361  
    5757testXMLType("foo&bar/baz+xml", true);
    5858testXMLType("foo*bar/baz+xml", true);
     59testXMLType("foo bar/baz+xml", true);
     60testXMLType("foo[bar/baz+xml", true);
     61testXMLType("foo]bar/baz+xml", true);
     62testXMLType("foo(bar/baz+xml", true);
     63testXMLType("foo)bar/baz+xml", true);
     64testXMLType("foo<bar/baz+xml", true);
     65testXMLType("foo>bar/baz+xml", true);
     66testXMLType("foo@bar/baz+xml", true);
     67testXMLType("foo,bar/baz+xml", true);
     68testXMLType("foo;bar/baz+xml", true);
     69testXMLType("foo:bar/baz+xml", true);
     70testXMLType("foo\\bar/baz+xml", true);
     71testXMLType('foo"bar/baz+xml', true);
     72testXMLType("foo/bar/baz+xml", true);
     73testXMLType("foo?bar/baz+xml", true);
     74testXMLType("foo=bar/baz+xml", true);
     75
     76testXMLType("invalid", true);
    5977
    6078// non-xml types
     
    6280testXMLType("image/png", false);
    6381
    64 
    65 // invalid types
    66 testXMLType("invalid", false);
    67 
    68 testXMLType("foo bar/baz+xml", false);
    69 
    70 testXMLType("foo[bar/baz+xml", false);
    71 testXMLType("foo]bar/baz+xml", false);
    72 testXMLType("foo(bar/baz+xml", false);
    73 testXMLType("foo)bar/baz+xml", false);
    74 testXMLType("foo<bar/baz+xml", false);
    75 testXMLType("foo>bar/baz+xml", false);
    76 testXMLType("foo@bar/baz+xml", false);
    77 testXMLType("foo,bar/baz+xml", false);
    78 testXMLType("foo;bar/baz+xml", false);
    79 testXMLType("foo:bar/baz+xml", false);
    80 testXMLType("foo\\bar/baz+xml", false);
    81 testXMLType('foo"bar/baz+xml', false);
    82 testXMLType("foo/bar/baz+xml", false);
    83 testXMLType("foo?bar/baz+xml", false);
    84 testXMLType("foo=bar/baz+xml", false);
    85 
    8682</script>
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r249360 r249361  
     12019-08-31  Rob Buis  <rbuis@igalia.com>
     2
     3        XMLHttpRequest: responseXML returns null if the Content-Type is valid (end in +xml) in some cases
     4        https://bugs.webkit.org/show_bug.cgi?id=46146
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Updated expected result.
     9
     10        * web-platform-tests/xhr/responsexml-media-type-expected.txt:
     11
    1122019-08-31  Frederic Wang  <fwang@igalia.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/responsexml-media-type-expected.txt

    r235354 r249361  
    22PASS XMLHttpRequest: responseXML MIME type tests ('', should  parse)
    33PASS XMLHttpRequest: responseXML MIME type tests ('text/html', should not parse)
    4 FAIL XMLHttpRequest: responseXML MIME type tests ('bogus', should  parse) null is not an object (evaluating 'client.responseXML.documentElement')
    5 FAIL XMLHttpRequest: responseXML MIME type tests ('bogus+xml', should  parse) null is not an object (evaluating 'client.responseXML.documentElement')
     4PASS XMLHttpRequest: responseXML MIME type tests ('bogus', should  parse)
     5PASS XMLHttpRequest: responseXML MIME type tests ('bogus+xml', should  parse)
    66PASS XMLHttpRequest: responseXML MIME type tests ('text/plain;+xml', should not parse)
    77PASS XMLHttpRequest: responseXML MIME type tests ('text/plainxml', should not parse)
     
    99PASS XMLHttpRequest: responseXML MIME type tests ('video/x-awesome', should not parse)
    1010PASS XMLHttpRequest: responseXML MIME type tests ('text/xml', should  parse)
    11 FAIL XMLHttpRequest: responseXML MIME type tests ('application', should  parse) null is not an object (evaluating 'client.responseXML.documentElement')
     11PASS XMLHttpRequest: responseXML MIME type tests ('application', should  parse)
    1212FAIL XMLHttpRequest: responseXML MIME type tests ('text/xsl', should not parse) assert_equals: expected null but got Document node with 1 child
    1313PASS XMLHttpRequest: responseXML MIME type tests ('text/plain', should not parse)
  • trunk/Source/WebCore/ChangeLog

    r249360 r249361  
     12019-08-31  Rob Buis  <rbuis@igalia.com>
     2
     3        XMLHttpRequest: responseXML returns null if the Content-Type is valid (end in +xml) in some cases
     4        https://bugs.webkit.org/show_bug.cgi?id=46146
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Make response MIME type fallback to text/xml in case mimeType could
     9        not be extracted [1] and use the stricter ParsedContentType for that.
     10
     11        Behavior matches Firefox.
     12
     13        Test: web-platform-tests/xhr/responsexml-media-type.htm
     14
     15        [1] https://xhr.spec.whatwg.org/#response-mime-type
     16
     17        * xml/XMLHttpRequest.cpp:
     18        (WebCore::XMLHttpRequest::responseMIMEType const):
     19
    1202019-08-31  Frederic Wang  <fwang@igalia.com>
    221
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r248846 r249361  
    842842    String mimeType = extractMIMETypeFromMediaType(m_mimeTypeOverride);
    843843    if (mimeType.isEmpty()) {
     844        String contentType;
    844845        if (m_response.isHTTP())
    845             mimeType = extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPHeaderName::ContentType));
     846            contentType = m_response.httpHeaderField(HTTPHeaderName::ContentType);
    846847        else
    847             mimeType = m_response.mimeType();
    848         if (mimeType.isEmpty())
    849             mimeType = "text/xml"_s;
     848            contentType = m_response.mimeType();
     849        if (auto parsedContentType = ParsedContentType::create(contentType))
     850            return parsedContentType->mimeType();
     851        return "text/xml"_s;
    850852    }
    851853    return mimeType;
Note: See TracChangeset for help on using the changeset viewer.