data:// URL behavior of XHR does not match spec
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Aug 2016 08:06:28 +0000 (08:06 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Aug 2016 08:06:28 +0000 (08:06 +0000)
commitb37b4700e39abb5835c21c7ab4cb3a19ebb5babb
tree330434593551cd4653ad61c31ca7c6ed6001f6eb
parent7ee64787fc6f2e1d92f805dd4b0a710fc075c0ec
data:// URL behavior of XHR does not match spec
https://bugs.webkit.org/show_bug.cgi?id=109199

Patch by Youenn Fablet <youenn@apple.com> on 2016-08-29
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/XMLHttpRequest/data-uri-expected.txt:
* web-platform-tests/XMLHttpRequest/send-network-error-sync-events.sub-expected.txt:
* web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-block-defer-scripts-expected.txt:
* web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-block-scripts-expected.txt:
* web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-not-hang-scriptloader-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-data.js: Adding setStatusText check.
* web-platform-tests/fetch/api/basic/scheme-data-expected.txt:
* web-platform-tests/fetch/api/basic/scheme-data-worker-expected.txt:

Source/WebCore:

Covered by rebased tests.

Making data URLs same origin for XHR and fetch API.
This is the behavior when https://fetch.spec.whatwg.org/#same-origin-data-url-flag is set.
As per the specs, this flag is set for fetch API and XMLHttpRequest.
Introducing this flag in ThreadableLoader options, default value being false.
Setting flag for XHR and fetch API.

Fixing accuracy of data URL loading by setting status code and content-type HTTP header as per fetch specification.

As can be seen from the rebased tests, no constraint is put on the method used as the fetch specification is about to allow all methods for data URLs.

* Modules/fetch/FetchLoader.cpp:
(WebCore::FetchLoader::start): Setting same-origin-data-url-flag to true.
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader): Making data URLs same origin if flag is set.
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::loadDataURL): Setting status code and content-type header according specification.
* loader/ThreadableLoader.cpp:
(WebCore::ThreadableLoaderOptions::ThreadableLoaderOptions): Adding same-origin-data-url-flag option.
* loader/ThreadableLoader.h:
* loader/WorkerThreadableLoader.cpp:
(WebCore::LoaderTaskOptions::LoaderTaskOptions): Ensuring flag is preserved when going to the main thread.
* platform/network/DataURLDecoder.cpp:
(WebCore::DataURLDecoder::parseMediaType): Setting mediaType value, used by ResourceLoader to set the content-type header.
* platform/network/DataURLDecoder.h:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createRequest): Setting same-origin-data-url-flag to true.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205113 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/data-uri-expected.txt
LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/send-network-error-sync-events.sub-expected.txt
LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-block-defer-scripts-expected.txt
LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-block-scripts-expected.txt
LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-not-hang-scriptloader-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data-worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/scheme-data.js
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchLoader.cpp
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/ThreadableLoader.cpp
Source/WebCore/loader/ThreadableLoader.h
Source/WebCore/loader/WorkerThreadableLoader.cpp
Source/WebCore/platform/network/DataURLDecoder.cpp
Source/WebCore/platform/network/DataURLDecoder.h
Source/WebCore/xml/XMLHttpRequest.cpp