Diff
Modified: trunk/LayoutTests/ChangeLog (210545 => 210546)
--- trunk/LayoutTests/ChangeLog 2017-01-10 14:51:02 UTC (rev 210545)
+++ trunk/LayoutTests/ChangeLog 2017-01-10 15:07:46 UTC (rev 210546)
@@ -1,3 +1,14 @@
+2017-01-10 Youenn Fablet <you...@apple.com>
+
+ CachedScript cloning does not clone encodedSize
+ https://bugs.webkit.org/show_bug.cgi?id=166865
+
+ Reviewed by Darin Adler.
+
+ * http/tests/security/cross-origin-cached-scripts-expected.txt:
+ * http/tests/security/cross-origin-cached-scripts.html:
+ * http/tests/security/resources/notify-loaded.js:
+
2017-01-09 Ryosuke Niwa <rn...@webkit.org>
Add an iOS test for tapping on a text node assigned to a slot
Modified: trunk/LayoutTests/http/tests/security/cross-origin-cached-scripts-expected.txt (210545 => 210546)
--- trunk/LayoutTests/http/tests/security/cross-origin-cached-scripts-expected.txt 2017-01-10 14:51:02 UTC (rev 210545)
+++ trunk/LayoutTests/http/tests/security/cross-origin-cached-scripts-expected.txt 2017-01-10 15:07:46 UTC (rev 210546)
@@ -9,5 +9,8 @@
Test 2 PASS: Did not load script http://127.0.0.1:8000/security/resources/allow-if-origin.php?allowCache&origin=http%3A%2F%2Flocalhost%3A8000&name=notify-loaded.js from localhost:8080 (crossOrigin=anonymous)
Test 3 PASS: Loaded script http://127.0.0.1:8080/security/resources/allow-if-origin.php?allowCache&origin=http%3A%2F%2Flocalhost%3A8000&name=notify-loaded.js from localhost:8080
Test 4 PASS: Did not load script http://127.0.0.1:8080/security/resources/allow-if-origin.php?allowCache&origin=http%3A%2F%2Flocalhost%3A8000&name=notify-loaded.js from localhost:8080 (crossOrigin=anonymous)
+Test 5 PASS: Loaded script http://127.0.0.1:8080/security/resources/allow-if-origin.php?allowCache&origin=*&name=notify-loaded.js from localhost:8000 (crossOrigin=anonymous)
+Test 6 PASS: Loaded script http://127.0.0.1:8080/security/resources/allow-if-origin.php?allowCache&origin=*&name=notify-loaded.js from localhost:8080 (crossOrigin=anonymous)
+
Modified: trunk/LayoutTests/http/tests/security/cross-origin-cached-scripts.html (210545 => 210546)
--- trunk/LayoutTests/http/tests/security/cross-origin-cached-scripts.html 2017-01-10 14:51:02 UTC (rev 210545)
+++ trunk/LayoutTests/http/tests/security/cross-origin-cached-scripts.html 2017-01-10 15:07:46 UTC (rev 210546)
@@ -11,6 +11,10 @@
<iframe id="iframe3"></iframe>
<iframe id="iframe4"></iframe>
</div>
+<div>
+ <iframe id="iframe5"></iframe>
+ <iframe id="iframe6"></iframe>
+</div>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
@@ -27,21 +31,22 @@
var allow8000Script1 = "http://127.0.0.1:8000/security/resources/allow-if-origin.php?allowCache&origin=http%3A%2F%2Flocalhost%3A8000&name=notify-loaded.js";
var allow8000Script2 = "http://127.0.0.1:8080/security/resources/allow-if-origin.php?allowCache&origin=http%3A%2F%2Flocalhost%3A8000&name=notify-loaded.js";
+var allow8000Script3 = "http://127.0.0.1:8080/security/resources/allow-if-origin.php?allowCache&origin=*&name=notify-loaded.js";
var counter = 0;
function loadNextFrame()
{
counter++;
- // Four first tests try to load an image with a given origin and then the same image (in cache) with a different origin.
+ // Two first tests try to load a script with a given origin and then the same script (in cache) with a different origin.
if (counter == 1)
document.getElementById('iframe1').src = "" + "#" +
encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script1, shouldPass: true, crossOrigin: "anonymous", id: 1}));
- // Fourth image load should fail since requesting image from localhost:8080 while only allowed from localhost:8000.
+ // Load should fail since requesting script from localhost:8080 while only allowed from localhost:8000.
else if (counter == 2)
document.getElementById('iframe2').src = "" + "#" +
encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script1, shouldPass: false, crossOrigin: "anonymous", id: 2}));
- // Four next tests try to load a cross-origin image without cors and then with cors.
+ // Next two tests try to load a cross-origin script without cors and then with cors.
else if (counter == 3)
document.getElementById('iframe3').src = "" + "#" +
encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script2, shouldPass:true, id: 3}));
@@ -48,6 +53,16 @@
else if (counter == 4)
document.getElementById('iframe4').src = "" + "#" +
encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script2, shouldPass:false, crossOrigin: "anonymous", id: 4}));
+
+ // Next two tests try to load a script with a given origin and then the same script (in cache) with a different origin.
+ else if (counter == 5)
+ document.getElementById('iframe5').src = "" + "#" +
+ encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script3, shouldPass: true, crossOrigin: "anonymous", id: 5}));
+ // Load should succeed since cached script is allowed for all origins.
+ else if (counter == 6)
+ document.getElementById('iframe6').src = "" + "#" +
+ encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script3, shouldPass: true, crossOrigin: "anonymous", id: 6}));
+
else if (window.testRunner)
testRunner.notifyDone();
}
Modified: trunk/LayoutTests/http/tests/security/resources/notify-loaded.js (210545 => 210546)
--- trunk/LayoutTests/http/tests/security/resources/notify-loaded.js 2017-01-10 14:51:02 UTC (rev 210545)
+++ trunk/LayoutTests/http/tests/security/resources/notify-loaded.js 2017-01-10 15:07:46 UTC (rev 210546)
@@ -1 +1 @@
-document.body.innerHTML += "LOADED";
+document.body.innerHTML += "LOADED with UTF-8 content ยข";
Modified: trunk/Source/WebCore/ChangeLog (210545 => 210546)
--- trunk/Source/WebCore/ChangeLog 2017-01-10 14:51:02 UTC (rev 210545)
+++ trunk/Source/WebCore/ChangeLog 2017-01-10 15:07:46 UTC (rev 210546)
@@ -1,3 +1,18 @@
+2017-01-10 Youenn Fablet <you...@apple.com>
+
+ CachedScript cloning does not clone encodedSize
+ https://bugs.webkit.org/show_bug.cgi?id=166865
+
+ Reviewed by Darin Adler.
+
+ Covered by updated test.
+
+ * loader/cache/CachedResource.cpp:
+ (WebCore::CachedResource::setBodyDataFrom): set encoded size based on being cloned resource.
+ * loader/cache/CachedScript.cpp:
+ (WebCore::CachedScript::script):
+ (WebCore::CachedScript::setBodyDataFrom): Making use of CachedResource::setBodyDataFrom for complete cloning.
+
2017-01-10 Zan Dobersek <zdober...@igalia.com>
Unreviewed. Remove the unused gReadyStateTimerInterval global from
Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (210545 => 210546)
--- trunk/Source/WebCore/loader/cache/CachedResource.cpp 2017-01-10 14:51:02 UTC (rev 210545)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp 2017-01-10 15:07:46 UTC (rev 210546)
@@ -299,6 +299,7 @@
m_data = resource.m_data;
m_response = resource.m_response;
setDecodedSize(resource.decodedSize());
+ setEncodedSize(resource.encodedSize());
}
void CachedResource::checkNotify()
Modified: trunk/Source/WebCore/loader/cache/CachedScript.cpp (210545 => 210546)
--- trunk/Source/WebCore/loader/cache/CachedScript.cpp 2017-01-10 14:51:02 UTC (rev 210545)
+++ trunk/Source/WebCore/loader/cache/CachedScript.cpp 2017-01-10 15:07:46 UTC (rev 210546)
@@ -125,7 +125,8 @@
ASSERT(resource.type() == type());
auto& script = static_cast<const CachedScript&>(resource);
- m_data = script.m_data;
+ CachedResource::setBodyDataFrom(resource);
+
m_script = script.m_script;
m_scriptHash = script.m_scriptHash;
m_decodingState = script.m_decodingState;