Commit 4008d31
ScriptElement should use FetchOptions::mode according its crossOrigin attribute
https://bugs.webkit.org/show_bug.cgi?id=161686
Patch by Youenn Fablet <youenn@apple.com> on 2016-09-12
Reviewed by Darin Adler.
Source/WebCore:
Setting ScriptElement fetch mode according its crossOrigin attribute.
Removing LoadableClassicScriptchecking of CORS since this is now done at ResourceLoader/CachedResource level.
Updating CachedResourceLoader to ensure that a resource that matches an on-going resource load but with different fetch mode/origin,
always gets its loading started if the resource state is not Cached.
Tests: fast/dom/script-crossorigin-loads-fail-origin.html
http/tests/security/cross-origin-cached-images-parallel.html
http/tests/security/cross-origin-cached-images.html
http/tests/security/cross-origin-cached-scripts-parallel.html
http/tests/security/cross-origin-cached-scripts.html
http/tests/security/script-crossorigin-loads-correctly-credentials.html
http/tests/security/script-with-dataurl.html
* dom/LoadableClassicScript.cpp:
(WebCore::LoadableClassicScript::create):
(WebCore::LoadableClassicScript::notifyFinished): Checking CORS failures using the resource state.
(WebCore::LoadableClassicScript::~LoadableClassicScript): Deleted.
(WebCore::LoadableClassicScript::isLoaded): Deleted.
* dom/LoadableClassicScript.h:
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::requestClassicScript):
(WebCore::ScriptElement::requestScriptWithCache): Using CachedResourceRequest::setAsPotentiallyCrossOrigin to set fetch mode according crossOrigin attribute.
* dom/ScriptElement.h:
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::setBodyDataFrom):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::updateCachedResourceWithCurrentRequest): Adding support for script resources.
(WebCore::CachedResourceLoader::requestResource): Ensuring that 'updated' resources gets actually loaded.
* loader/cache/CachedScript.cpp:
(WebCore::CachedScript::setBodyDataFrom): Implementing specific data copy from another CachedScript.
* loader/cache/CachedScript.h:
LayoutTests:
Added new tests.
Updated cookie test for robustness as the order of the cookie items when more than one may not be preserved.
Moved one of the blink test to http/tests as it requires HTTP to run properly.
Updated blink test expectation as it is run from file, while it should be run from http.
Copied a similar test to http/tests/local to ensure that script load fails when served from the filesystem , CORS check failing.
The test was previously passing in WebKit as the test file was served from filesystem and was granted universal access.
The CORS checks were done through SecurityOrigin::canRequest which was testing that first.
With the patch, CORS checks are done at a lower level and do not take in to account universal access.
This aligns with Chrome and Firefox behavior.
* http/tests/local/script-crossorigin-loads-fail-origin-expected.txt: Added.
* http/tests/local/script-crossorigin-loads-fail-origin.html: Copied from LayoutTests/imported/blink/http/tests/security/script-crossorigin-loads-correctly-credentials.html.
* http/tests/cookies/resources/third-party-cookie-relaxing-iframe.html: Sorting the cookie to make the test more resistant.
* http/tests/security/cross-origin-cached-images-expected.txt: Added.
* http/tests/security/cross-origin-cached-images-parallel-expected.txt: Added.
* http/tests/security/cross-origin-cached-images-parallel.html: Renamed from LayoutTests/http/tests/security/cross-origin-cached-resource-parallel.html.
* http/tests/security/cross-origin-cached-images.html: Renamed from LayoutTests/http/tests/security/cross-origin-cached-resource.html.
* http/tests/security/cross-origin-cached-resource-parallel-expected.txt: Removed.
* http/tests/security/cross-origin-cached-scripts-expected.txt: Added.
* http/tests/security/cross-origin-cached-scripts-parallel-expected.txt: Added.
* http/tests/security/cross-origin-cached-scripts-parallel.html: Added.
* http/tests/security/cross-origin-cached-scripts.html: Added.
* http/tests/security/resources/cors-script.php: Updated according chromium script to activate CORS credentials header if requested.
* http/tests/security/resources/cross-origin-cached-resource-iframe.html:
* http/tests/security/resources/notify-loaded.js: Added.
* http/tests/security/script-crossorigin-loads-correctly-credentials-expected.txt: Renamed from LayoutTests/imported/blink/http/tests/security/script-crossorigin-loads-correctly-credentials-expected.txt.
* http/tests/security/script-crossorigin-loads-correctly-credentials.html: Renamed from LayoutTests/imported/blink/http/tests/security/script-crossorigin-loads-correctly-credentials.html.
* http/tests/security/script-with-dataurl-expected.txt: Added.
* http/tests/security/script-with-dataurl.html: Added.
* http/tests/security/script-with-failed-cors-check-fails-to-load-expected.txt:
Canonical link: https://commits.webkit.org/180053@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205854 268f45cc-cd09-0410-ab3c-d52691b4dbfc1 parent 316bd65 commit 4008d31Copy full SHA for 4008d31
30 files changed
+416-85Lines changed: 416 additions & 85 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- LayoutTests
- http/tests
- cookies/resources
- local
- security
- resources
- Source/WebCore
- dom
- loader/cache
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+40Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
1 | 41 | |
2 | 42 | |
3 | 43 | |
|
Collapse file
LayoutTests/http/tests/cookies/resources/third-party-cookie-relaxing-iframe.html
Copy file name to clipboardExpand all lines: LayoutTests/http/tests/cookies/resources/third-party-cookie-relaxing-iframe.html+9-2Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
21 | 21 | |
22 | 22 | |
23 | 23 | |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
24 | 31 | |
25 | 32 | |
26 | 33 | |
27 | | - |
28 | | - |
| 34 | + |
| 35 | + |
29 | 36 | |
30 | 37 | |
31 | 38 | |
|
Collapse file
LayoutTests/http/tests/local/script-crossorigin-loads-fail-origin-expected.txt
Copy file name to clipboard+5Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
Collapse file
LayoutTests/http/tests/local/script-crossorigin-loads-fail-origin.html
Copy file name to clipboard+23Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
Collapse file
LayoutTests/http/tests/security/cross-origin-cached-images-expected.txt
Copy file name to clipboard+17Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
Collapse file
LayoutTests/http/tests/security/cross-origin-cached-images-parallel-expected.txt
Copy file name to clipboard+17Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
Collapse file
…oss-origin-cached-resource-parallel.html …cross-origin-cached-images-parallel.htmlLayoutTests/http/tests/security/cross-origin-cached-resource-parallel.html renamed to LayoutTests/http/tests/security/cross-origin-cached-images-parallel.html LayoutTests/http/tests/security/cross-origin-cached-resource-parallel.html renamed to LayoutTests/http/tests/security/cross-origin-cached-images-parallel.html
Copy file name to clipboardExpand all lines: LayoutTests/http/tests/security/cross-origin-cached-images-parallel.html+11-12Lines changed: 11 additions & 12 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | 1 | |
2 | 2 | |
3 | 3 | |
4 | | - |
5 | | - |
| 4 | + |
6 | 5 | |
7 | 6 | |
8 | 7 | |
| ||
40 | 39 | |
41 | 40 | |
42 | 41 | |
43 | | - |
| 42 | + |
44 | 43 | |
45 | 44 | |
46 | | - |
| 45 | + |
47 | 46 | |
48 | 47 | |
49 | | - |
| 48 | + |
50 | 49 | |
51 | | - |
| 50 | + |
52 | 51 | |
53 | | - |
| 52 | + |
54 | 53 | |
55 | | - |
| 54 | + |
56 | 55 | |
57 | 56 | |
58 | | - |
| 57 | + |
59 | 58 | |
60 | | - |
| 59 | + |
61 | 60 | |
62 | | - |
| 61 | + |
63 | 62 | |
64 | | - |
| 63 | + |
65 | 64 | |
66 | 65 | |
67 | 66 | |
Collapse file
…curity/cross-origin-cached-resource.html …security/cross-origin-cached-images.htmlLayoutTests/http/tests/security/cross-origin-cached-resource.html renamed to LayoutTests/http/tests/security/cross-origin-cached-images.html LayoutTests/http/tests/security/cross-origin-cached-resource.html renamed to LayoutTests/http/tests/security/cross-origin-cached-images.html
Copy file name to clipboardExpand all lines: LayoutTests/http/tests/security/cross-origin-cached-images.html+9-10Lines changed: 9 additions & 10 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | 1 | |
2 | 2 | |
3 | 3 | |
4 | | - |
5 | | - |
| 4 | + |
6 | 5 | |
7 | 6 | |
8 | 7 | |
| ||
43 | 42 | |
44 | 43 | |
45 | 44 | |
46 | | - |
| 45 | + |
47 | 46 | |
48 | 47 | |
49 | | - |
| 48 | + |
50 | 49 | |
51 | 50 | |
52 | | - |
| 51 | + |
53 | 52 | |
54 | 53 | |
55 | 54 | |
56 | | - |
| 55 | + |
57 | 56 | |
58 | 57 | |
59 | 58 | |
60 | 59 | |
61 | | - |
| 60 | + |
62 | 61 | |
63 | 62 | |
64 | | - |
| 63 | + |
65 | 64 | |
66 | 65 | |
67 | | - |
| 66 | + |
68 | 67 | |
69 | 68 | |
70 | | - |
| 69 | + |
71 | 70 | |
72 | 71 | |
73 | 72 | |
|
Collapse file
LayoutTests/http/tests/security/cross-origin-cached-resource-parallel-expected.txt
Copy file name to clipboardExpand all lines: LayoutTests/http/tests/security/cross-origin-cached-resource-parallel-expected.txt-19Lines changed: 0 additions & 19 deletions
This file was deleted.
Collapse file
LayoutTests/http/tests/security/cross-origin-cached-scripts-expected.txt
Copy file name to clipboard+13Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
0 commit comments