Changeset 210546 in webkit


Ignore:
Timestamp:
Jan 10, 2017 7:07:46 AM (7 years ago)
Author:
commit-queue@webkit.org
Message:

CachedScript cloning does not clone encodedSize
https://bugs.webkit.org/show_bug.cgi?id=166865

Patch by Youenn Fablet <youenn@apple.com> on 2017-01-10
Reviewed by Darin Adler.

Source/WebCore:

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.

LayoutTests:

  • http/tests/security/cross-origin-cached-scripts-expected.txt:
  • http/tests/security/cross-origin-cached-scripts.html:
  • http/tests/security/resources/notify-loaded.js:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r210538 r210546  
     12017-01-10  Youenn Fablet  <youenn@apple.com>
     2
     3        CachedScript cloning does not clone encodedSize
     4        https://bugs.webkit.org/show_bug.cgi?id=166865
     5
     6        Reviewed by Darin Adler.
     7
     8        * http/tests/security/cross-origin-cached-scripts-expected.txt:
     9        * http/tests/security/cross-origin-cached-scripts.html:
     10        * http/tests/security/resources/notify-loaded.js:
     11
    1122017-01-09  Ryosuke Niwa  <rniwa@webkit.org>
    213
  • trunk/LayoutTests/http/tests/security/cross-origin-cached-scripts-expected.txt

    r205854 r210546  
    1010Test 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
    1111Test 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)
     12Test 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)
     13Test 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)
    1214 
    1315 
     16 
  • trunk/LayoutTests/http/tests/security/cross-origin-cached-scripts.html

    r205854 r210546  
    1111    <iframe id="iframe3"></iframe>
    1212    <iframe id="iframe4"></iframe>
     13</div>
     14<div>
     15    <iframe id="iframe5"></iframe>
     16    <iframe id="iframe6"></iframe>
    1317</div>
    1418<script>
     
    2832var allow8000Script1 = "http://127.0.0.1:8000/security/resources/allow-if-origin.php?allowCache&origin=http%3A%2F%2Flocalhost%3A8000&name=notify-loaded.js";
    2933var allow8000Script2 = "http://127.0.0.1:8080/security/resources/allow-if-origin.php?allowCache&origin=http%3A%2F%2Flocalhost%3A8000&name=notify-loaded.js";
     34var allow8000Script3 = "http://127.0.0.1:8080/security/resources/allow-if-origin.php?allowCache&origin=*&name=notify-loaded.js";
    3035
    3136var counter = 0;
     
    3338{
    3439    counter++;
    35     // Four first tests try to load an image with a given origin and then the same image (in cache) with a different origin.
     40    // Two first tests try to load a script with a given origin and then the same script (in cache) with a different origin.
    3641    if (counter == 1)
    3742        document.getElementById('iframe1').src = iframeURL8000 + "#" +
    3843            encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script1, shouldPass: true, crossOrigin: "anonymous", id: 1}));
    39     // Fourth image load should fail since requesting image from localhost:8080 while only allowed from localhost:8000.
     44    // Load should fail since requesting script from localhost:8080 while only allowed from localhost:8000.
    4045    else if (counter == 2)
    4146        document.getElementById('iframe2').src = iframeURL8080 + "#" +
    4247            encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script1, shouldPass: false, crossOrigin: "anonymous", id: 2}));
    4348
    44     // Four next tests try to load a cross-origin image without cors and then with cors.
     49    // Next two tests try to load a cross-origin script without cors and then with cors.
    4550    else if (counter == 3)
    4651        document.getElementById('iframe3').src = iframeURL8080 + "#" +
     
    4954        document.getElementById('iframe4').src = iframeURL8080 + "#" +
    5055            encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script2, shouldPass:false, crossOrigin: "anonymous", id: 4}));
     56
     57    // Next two tests try to load a script with a given origin and then the same script (in cache) with a different origin.
     58    else if (counter == 5)
     59        document.getElementById('iframe5').src = iframeURL8000 + "#" +
     60            encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script3, shouldPass: true, crossOrigin: "anonymous", id: 5}));
     61    // Load should succeed since cached script is allowed for all origins.
     62    else if (counter == 6)
     63        document.getElementById('iframe6').src = iframeURL8080 + "#" +
     64            encodeURIComponent(JSON.stringify({node: "script", url: allow8000Script3, shouldPass: true, crossOrigin: "anonymous", id: 6}));
     65
    5166    else if (window.testRunner)
    5267        testRunner.notifyDone();
  • trunk/LayoutTests/http/tests/security/resources/notify-loaded.js

    r205854 r210546  
    1 document.body.innerHTML += "LOADED";
     1document.body.innerHTML += "LOADED with UTF-8 content ¢";
  • trunk/Source/WebCore/ChangeLog

    r210544 r210546  
     12017-01-10  Youenn Fablet  <youenn@apple.com>
     2
     3        CachedScript cloning does not clone encodedSize
     4        https://bugs.webkit.org/show_bug.cgi?id=166865
     5
     6        Reviewed by Darin Adler.
     7
     8        Covered by updated test.
     9
     10        * loader/cache/CachedResource.cpp:
     11        (WebCore::CachedResource::setBodyDataFrom): set encoded size based on being cloned resource.
     12        * loader/cache/CachedScript.cpp:
     13        (WebCore::CachedScript::script):
     14        (WebCore::CachedScript::setBodyDataFrom): Making use of CachedResource::setBodyDataFrom for complete cloning.
     15
    1162017-01-10  Zan Dobersek  <zdobersek@igalia.com>
    217
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r209961 r210546  
    300300    m_response = resource.m_response;
    301301    setDecodedSize(resource.decodedSize());
     302    setEncodedSize(resource.encodedSize());
    302303}
    303304
  • trunk/Source/WebCore/loader/cache/CachedScript.cpp

    r206206 r210546  
    126126    auto& script = static_cast<const CachedScript&>(resource);
    127127
    128     m_data = script.m_data;
     128    CachedResource::setBodyDataFrom(resource);
     129
    129130    m_script = script.m_script;
    130131    m_scriptHash = script.m_scriptHash;
Note: See TracChangeset for help on using the changeset viewer.