Skip to content

Commit

Permalink
Merge r235844 - XMLHttpRequest: overrideMimeType should not update th…
Browse files Browse the repository at this point in the history
…e response's "Content-Type" header

https://bugs.webkit.org/show_bug.cgi?id=189465

Patch by Rob Buis <[email protected]> on 2018-09-10
Reviewed by Frédéric Wang.

LayoutTests/imported/w3c:

* web-platform-tests/xhr/overridemimetype-invalid-mime-type-expected.txt:

Source/WebCore:

The xhr spec changed [1, 2] so that overrideMimeType should not update the
response's "Content-Type" header anymore.

Behavior matches Firefox and Chrome.

[1] https://xhr.spec.whatwg.org/#dom-xmlhttprequest-overridemimetype
[2] whatwg/xhr#157

Tests: http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header.html
       web-platform-tests/xhr/overridemimetype-invalid-mime-type.htm

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::didReceiveResponse):

LayoutTests:

Change existing test to reflect new behavior.

* http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header-expected.txt:
* http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header.html:

git-svn-id: http://svn.webkit.org/repository/webkit/releases/WebKitGTK/webkit-2.22@236185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
[email protected] committed Sep 19, 2018
1 parent baf1423 commit d3dfdf0
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 9 deletions.
12 changes: 12 additions & 0 deletions LayoutTests/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2018-09-10 Rob Buis <[email protected]>

XMLHttpRequest: overrideMimeType should not update the response's "Content-Type" header
https://bugs.webkit.org/show_bug.cgi?id=189465

Reviewed by Frédéric Wang.

Change existing test to reflect new behavior.

* http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header-expected.txt:
* http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header.html:

2018-09-10 Antoine Quint <[email protected]>

[Web Animations] Interrupting an accelerated CSS transition on a composited element in flight fails
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
This tests that XMLHttpRequest overrideMimeType() properly updates the Content-Type header for the response.
This tests that XMLHttpRequest overrideMimeType() does not update the Content-Type header for the response.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS xhr.getResponseHeader("Content-Type") is "text/xml;charset=GBK"
PASS xhr.getResponseHeader("Content-Type") is "application/xml"
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
</head>
<body>
<script>
description('This tests that XMLHttpRequest overrideMimeType() properly updates the Content-Type header for the response.');
description('This tests that XMLHttpRequest overrideMimeType() does not update the Content-Type header for the response.');
window.jsTestIsAsync = true;

var xhr = new XMLHttpRequest();
var url = 'resources/reply.xml';

xhr.onreadystatechange = function () {
if (xhr.readyState == xhr.LOADING) {
shouldBe('xhr.getResponseHeader("Content-Type")', '"text/xml;charset=GBK"');
shouldBe('xhr.getResponseHeader("Content-Type")', '"application/xml"');
finishJSTest();
}
}
Expand Down
9 changes: 9 additions & 0 deletions LayoutTests/imported/w3c/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2018-09-10 Rob Buis <[email protected]>

XMLHttpRequest: overrideMimeType should not update the response's "Content-Type" header
https://bugs.webkit.org/show_bug.cgi?id=189465

Reviewed by Frédéric Wang.

* web-platform-tests/xhr/overridemimetype-invalid-mime-type-expected.txt:

2018-09-12 Chris Dumez <[email protected]>

Unreviewed, rebaseline imported/w3c/web-platform-tests/url/failure.html after r235808.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

FAIL Bogus MIME type does not override encoding assert_equals: expected "text/html;charset=windows-1252" but got "bogus"
PASS Bogus MIME type does not override encoding
FAIL Bogus MIME type does not override encoding, 2 assert_equals: expected "ÿ" but got "\x1a"
FAIL Bogus MIME type does override MIME type assert_equals: expected "text/xml" but got "bogus"
PASS Bogus MIME type does override MIME type

21 changes: 21 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
2018-09-10 Rob Buis <[email protected]>

XMLHttpRequest: overrideMimeType should not update the response's "Content-Type" header
https://bugs.webkit.org/show_bug.cgi?id=189465

Reviewed by Frédéric Wang.

The xhr spec changed [1, 2] so that overrideMimeType should not update the
response's "Content-Type" header anymore.

Behavior matches Firefox and Chrome.

[1] https://xhr.spec.whatwg.org/#dom-xmlhttprequest-overridemimetype
[2] https://github.com/whatwg/xhr/issues/157

Tests: http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header.html
web-platform-tests/xhr/overridemimetype-invalid-mime-type.htm

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::didReceiveResponse):

2018-09-10 Antoine Quint <[email protected]>

[Web Animations] Interrupting an accelerated CSS transition on a composited element in flight fails
Expand Down
3 changes: 0 additions & 3 deletions Source/WebCore/xml/XMLHttpRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,6 @@ void XMLHttpRequest::didSendData(unsigned long long bytesSent, unsigned long lon
void XMLHttpRequest::didReceiveResponse(unsigned long, const ResourceResponse& response)
{
m_response = response;
if (!m_mimeTypeOverride.isEmpty())
m_response.setHTTPHeaderField(HTTPHeaderName::ContentType, m_mimeTypeOverride);
}

static inline bool shouldDecodeResponse(XMLHttpRequest::ResponseType type)
Expand Down Expand Up @@ -1027,7 +1025,6 @@ void XMLHttpRequest::didReceiveData(const char* data, int len)
if (readyState() < HEADERS_RECEIVED)
changeState(HEADERS_RECEIVED);

// FIXME: Should we update "Content-Type" header field with m_mimeTypeOverride value in case it has changed since didReceiveResponse?
if (!m_mimeTypeOverride.isEmpty())
m_responseEncoding = extractCharsetFromMediaType(m_mimeTypeOverride);
if (m_responseEncoding.isEmpty())
Expand Down

0 comments on commit d3dfdf0

Please sign in to comment.