Changeset 245825 in webkit


Ignore:
Timestamp:
May 28, 2019 2:10:47 PM (5 years ago)
Author:
Shawn Roberts
Message:

Unreviewed, rolling out r245475.

Newly imported test is flaky. Features need flags.

Reverted changeset:

"Implement imagesrcset and imagesizes attributes on link
rel=preload"
https://bugs.webkit.org/show_bug.cgi?id=192950
https://trac.webkit.org/changeset/245475

Location:
trunk
Files:
29 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245821 r245825  
     12019-05-28  Shawn Roberts  <sroberts@apple.com>
     2
     3        Unreviewed, rolling out r245475.
     4
     5        Newly imported test is flaky. Features need flags.
     6
     7        Reverted changeset:
     8
     9        "Implement imagesrcset and imagesizes attributes on link
     10        rel=preload"
     11        https://bugs.webkit.org/show_bug.cgi?id=192950
     12        https://trac.webkit.org/changeset/245475
     13
    1142019-05-28  Devin Rousso  <drousso@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r245820 r245825  
     12019-05-28  Shawn Roberts  <sroberts@apple.com>
     2
     3        Unreviewed, rolling out r245475.
     4
     5        Newly imported test is flaky. Features need flags.
     6
     7        Reverted changeset:
     8
     9        "Implement imagesrcset and imagesizes attributes on link
     10        rel=preload"
     11        https://bugs.webkit.org/show_bug.cgi?id=192950
     12        https://trac.webkit.org/changeset/245475
     13
    1142019-05-28  Antoine Quint  <graouts@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/preload/preload-csp.sub-expected.txt

    r245475 r245825  
    1313CONSOLE MESSAGE: Refused to load http://localhost:8800/preload/resources/sound_5.oga because it does not appear in the media-src directive of the Content Security Policy.
    1414CONSOLE MESSAGE: Refused to load http://localhost:8800/preload/resources/foo.vtt because it does not appear in the media-src directive of the Content Security Policy.
    15 CONSOLE MESSAGE: line 14: <link rel=preload> must have a valid `as` value
    16 CONSOLE MESSAGE: line 15: <link rel=preload> must have a valid `as` value
     15CONSOLE MESSAGE: line 16: <link rel=preload> must have a valid `as` value
     16CONSOLE MESSAGE: line 17: <link rel=preload> must have a valid `as` value
    1717
    1818PASS Makes sure that preload requests respect CSP
  • trunk/LayoutTests/imported/w3c/web-platform-tests/preload/preload-csp.sub.html

    r245475 r245825  
    11<!DOCTYPE html>
    22<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'; font-src 'none'; style-src 'none'; img-src 'none'; media-src 'none'; connect-src 'none'">
    3 <title>Makes sure that preload requests respect CSP</title>
    43<script src="/resources/testharness.js"></script>
    54<script src="/resources/testharnessreport.js"></script>
    65<script src="/preload/resources/preload_helper.js"></script>
     6<script>
     7    var t = async_test('Makes sure that preload requests respect CSP');
     8</script>
    79<link rel=preload href="{{host}}:{{ports[http][1]}}/preload/resources/dummy.js" as=style>
    810<link rel=preload href="resources/dummy.css" as=style>
     
    1618<body>
    1719<script>
    18     setup({explicit_done: true});
    19 
    20     var iterations = 0;
    21 
    22     function check_finished() {
    23         if (numberOfResourceTimingEntries("{{host}}:{{ports[http][1]}}/preload/resources/dummy.js") == 0 &&
    24             numberOfResourceTimingEntries("resources/dummy.css") == 0 &&
    25             numberOfResourceTimingEntries("resources/square.png") == 0 &&
    26             numberOfResourceTimingEntries("/fonts/CanvasTest.ttf") == 0 &&
    27             numberOfResourceTimingEntries("resources/white.mp4") == 0 &&
    28             numberOfResourceTimingEntries("resources/sound_5.oga") == 0 &&
    29             numberOfResourceTimingEntries("resources/foo.vtt") == 0 &&
    30             numberOfResourceTimingEntries("resources/dummy.xml") == 0) {
    31             done();
    32         }
    33         iterations++;
    34         if (iterations == 10) {
    35             // At least one is expected to fail, but this should give details to the exact failure(s).
     20    window.onload = t.step_func(function() {
     21        t.step_timeout(function() {
     22            verifyPreloadAndRTSupport();
    3623            verifyNumberOfResourceTimingEntries("{{host}}:{{ports[http][1]}}/preload/resources/dummy.js", 0);
    3724            verifyNumberOfResourceTimingEntries("resources/dummy.css", 0);
     
    4229            verifyNumberOfResourceTimingEntries("resources/foo.vtt", 0);
    4330            verifyNumberOfResourceTimingEntries("resources/dummy.xml", 0);
    44             done();
    45         } else {
    46             step_timeout(check_finished, 500);
    47         }
    48     }
    49 
    50     window.addEventListener("load", function() {
    51         verifyPreloadAndRTSupport();
    52         step_timeout(check_finished, 500);
     31            t.done();
     32        }, 5000);
    5333    });
    5434</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/preload/preload-default-csp.sub-expected.txt

    r245475 r245825  
    1313CONSOLE MESSAGE: Refused to load http://localhost:8800/preload/resources/sound_5.oga because it appears in neither the media-src directive nor the default-src directive of the Content Security Policy.
    1414CONSOLE MESSAGE: Refused to load http://localhost:8800/preload/resources/foo.vtt because it appears in neither the media-src directive nor the default-src directive of the Content Security Policy.
    15 CONSOLE MESSAGE: line 14: <link rel=preload> must have a valid `as` value
    16 CONSOLE MESSAGE: line 15: <link rel=preload> must have a valid `as` value
     15CONSOLE MESSAGE: line 16: <link rel=preload> must have a valid `as` value
     16CONSOLE MESSAGE: line 17: <link rel=preload> must have a valid `as` value
    1717
    1818PASS Makes sure that preload requests respect CSP
  • trunk/LayoutTests/imported/w3c/web-platform-tests/preload/preload-default-csp.sub.html

    r245475 r245825  
    11<!DOCTYPE html>
    22<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'; default-src 'none'">
    3 <title>Makes sure that preload requests respect CSP</title>
    43<script src="/resources/testharness.js"></script>
    54<script src="/resources/testharnessreport.js"></script>
    65<script src="/preload/resources/preload_helper.js"></script>
     6<script>
     7    var t = async_test('Makes sure that preload requests respect CSP');
     8</script>
    79<link rel=preload href="{{host}}:{{ports[http][1]}}/preload/resources/dummy.js" as=style>
    810<link rel=preload href="resources/dummy.css" as=style>
     
    1618<body>
    1719<script>
    18     setup({explicit_done: true});
    19 
    20     var iterations = 0;
    21 
    22     function check_finished() {
    23         if (numberOfResourceTimingEntries("{{host}}:{{ports[http][1]}}/preload/resources/dummy.js") == 0 &&
    24             numberOfResourceTimingEntries("resources/dummy.css") == 0 &&
    25             numberOfResourceTimingEntries("resources/square.png") == 0 &&
    26             numberOfResourceTimingEntries("/fonts/CanvasTest.ttf") == 0 &&
    27             numberOfResourceTimingEntries("resources/white.mp4") == 0 &&
    28             numberOfResourceTimingEntries("resources/sound_5.oga") == 0 &&
    29             numberOfResourceTimingEntries("resources/foo.vtt") == 0 &&
    30             numberOfResourceTimingEntries("resources/dummy.xml") == 0) {
    31             done();
    32         }
    33         iterations++;
    34         if (iterations == 10) {
    35             // At least one is expected to fail, but this should give details to the exact failure(s).
     20    window.onload = t.step_func(function() {
     21        t.step_timeout(function() {
     22            verifyPreloadAndRTSupport();
    3623            verifyNumberOfResourceTimingEntries("{{host}}:{{ports[http][1]}}/preload/resources/dummy.js", 0);
    3724            verifyNumberOfResourceTimingEntries("resources/dummy.css", 0);
     
    4229            verifyNumberOfResourceTimingEntries("resources/foo.vtt", 0);
    4330            verifyNumberOfResourceTimingEntries("resources/dummy.xml", 0);
    44             done();
    45         } else {
    46             step_timeout(check_finished, 500);
    47         }
    48     }
    49 
    50     window.addEventListener("load", function() {
    51         verifyPreloadAndRTSupport();
    52         step_timeout(check_finished, 500);
     31            t.done();
     32        }, 5000);
    5333    });
    5434</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/preload/resources/preload_helper.js

    r245475 r245825  
    1313function verifyNumberOfResourceTimingEntries(url, number)
    1414{
    15     assert_equals(numberOfResourceTimingEntries(url), number, url);
    16 }
    17 
    18 function numberOfResourceTimingEntries(url)
    19 {
    20     return performance.getEntriesByName(getAbsoluteURL(url)).length;
     15    var numEntries = performance.getEntriesByName(getAbsoluteURL(url)).length;
     16    assert_equals(numEntries, number, url);
    2117}
    2218
  • trunk/Source/WebCore/ChangeLog

    r245823 r245825  
     12019-05-28  Shawn Roberts  <sroberts@apple.com>
     2
     3        Unreviewed, rolling out r245475.
     4
     5        Newly imported test is flaky. Features need flags.
     6
     7        Reverted changeset:
     8
     9        "Implement imagesrcset and imagesizes attributes on link
     10        rel=preload"
     11        https://bugs.webkit.org/show_bug.cgi?id=192950
     12        https://trac.webkit.org/changeset/245475
     13
    1142019-05-28  Brent Fulgham  <bfulgham@apple.com>
    215
  • trunk/Source/WebCore/html/HTMLAttributeNames.in

    r245475 r245825  
    145145http_equiv
    146146id
    147 imagesizes
    148 imagesrcset
    149147incremental
    150148indeterminate
  • trunk/Source/WebCore/html/HTMLLinkElement.cpp

    r245475 r245825  
    263263    URL url = getNonEmptyURLAttribute(hrefAttr);
    264264
    265     if (!m_linkLoader.loadLink(m_relAttribute, url, attributeWithoutSynchronization(asAttr), attributeWithoutSynchronization(mediaAttr), attributeWithoutSynchronization(typeAttr), attributeWithoutSynchronization(crossoriginAttr), attributeWithoutSynchronization(imagesrcsetAttr),  attributeWithoutSynchronization(imagesizesAttr), document()))
     265    if (!m_linkLoader.loadLink(m_relAttribute, url, attributeWithoutSynchronization(asAttr), attributeWithoutSynchronization(mediaAttr), attributeWithoutSynchronization(typeAttr), attributeWithoutSynchronization(crossoriginAttr), document()))
    266266        return;
    267267
  • trunk/Source/WebCore/html/HTMLLinkElement.idl

    r245475 r245825  
    3636    [CEReactions=NotNeeded] attribute DOMString as;
    3737    [CEReactions=NotNeeded] attribute DOMString? crossOrigin;
    38     [CEReactions=NotNeeded, Reflect] attribute DOMString imageSrcset;
    39     [CEReactions=NotNeeded, Reflect] attribute DOMString imageSizes;
    4038
    4139    // DOM Level 2 Style
  • trunk/Source/WebCore/loader/LinkHeader.cpp

    r245475 r245825  
    166166    if (equalLettersIgnoringASCIICase(name, "as"))
    167167        return LinkHeader::LinkParameterAs;
    168     if (equalLettersIgnoringASCIICase(name, "imagesrcset"))
    169         return LinkHeader::LinkParameterImageSrcSet;
    170     if (equalLettersIgnoringASCIICase(name, "imagesizes"))
    171         return LinkHeader::LinkParameterImageSizes;
    172168    return LinkHeader::LinkParameterUnknown;
    173169}
     
    269265}
    270266
    271 void LinkHeader::setValue(LinkParameterName name, String&& value)
     267void LinkHeader::setValue(LinkParameterName name, String value)
    272268{
    273269    switch (name) {
    274270    case LinkParameterRel:
    275271        if (!m_rel)
    276             m_rel = WTFMove(value);
     272            m_rel = value;
    277273        break;
    278274    case LinkParameterAnchor:
     
    280276        break;
    281277    case LinkParameterCrossOrigin:
    282         m_crossOrigin = WTFMove(value);
     278        m_crossOrigin = value;
    283279        break;
    284280    case LinkParameterAs:
    285         m_as = WTFMove(value);
     281        m_as = value;
    286282        break;
    287283    case LinkParameterType:
    288         m_mimeType = WTFMove(value);
     284        m_mimeType = value;
    289285        break;
    290286    case LinkParameterMedia:
    291         m_media = WTFMove(value);
    292         break;
    293     case LinkParameterImageSrcSet:
    294         m_imageSrcSet = WTFMove(value);
    295         break;
    296     case LinkParameterImageSizes:
    297         m_imageSizes = WTFMove(value);
     287        m_media = value;
    298288        break;
    299289    case LinkParameterTitle:
     
    347337        }
    348338
    349         setValue(parameterName, WTFMove(parameterValue));
     339        setValue(parameterName, parameterValue);
    350340    }
    351341    findNextHeader(position, end);
  • trunk/Source/WebCore/loader/LinkHeader.h

    r245475 r245825  
    4242    const String& media() const { return m_media; }
    4343    const String& crossOrigin() const { return m_crossOrigin; }
    44     const String& imageSrcSet() const { return m_imageSrcSet; }
    45     const String& imageSizes() const { return m_imageSizes; }
    4644    bool valid() const { return m_isValid; }
    47     bool isViewportDependent() const { return !media().isEmpty() || !imageSrcSet().isEmpty() || !imageSizes().isEmpty(); }
    4845
    4946    enum LinkParameterName {
     
    5956        LinkParameterCrossOrigin,
    6057        LinkParameterAs,
    61         LinkParameterImageSrcSet,
    62         LinkParameterImageSizes,
    6358    };
    6459
    6560private:
    66     void setValue(LinkParameterName, String&& value);
     61    void setValue(LinkParameterName, String value);
    6762
    6863    String m_url;
     
    7267    String m_media;
    7368    String m_crossOrigin;
    74     String m_imageSrcSet;
    75     String m_imageSizes;
    7669    bool m_isValid { true };
    7770};
  • trunk/Source/WebCore/loader/LinkLoader.cpp

    r245475 r245825  
    4545#include "FrameLoaderClient.h"
    4646#include "FrameView.h"
    47 #include "HTMLSrcsetParser.h"
    4847#include "LinkHeader.h"
    4948#include "LinkPreloadResourceClients.h"
     
    5150#include "LoaderStrategy.h"
    5251#include "MIMETypeRegistry.h"
    53 #include "MediaList.h"
    5452#include "MediaQueryEvaluator.h"
    5553#include "PlatformStrategies.h"
     
    5755#include "RuntimeEnabledFeatures.h"
    5856#include "Settings.h"
    59 #include "SizesAttributeParser.h"
    6057#include "StyleResolver.h"
    6158
     
    10198        if (!header.valid() || header.url().isEmpty() || header.rel().isEmpty())
    10299            continue;
    103         if ((mediaAttributeCheck == MediaAttributeCheck::MediaAttributeNotEmpty && !header.isViewportDependent())
    104             || (mediaAttributeCheck == MediaAttributeCheck::MediaAttributeEmpty && header.isViewportDependent())) {
     100        if ((mediaAttributeCheck == MediaAttributeCheck::MediaAttributeNotEmpty && header.media().isEmpty())
     101            || (mediaAttributeCheck == MediaAttributeCheck::MediaAttributeEmpty && !header.media().isEmpty())) {
    105102                continue;
    106103        }
     
    112109            continue;
    113110        preconnectIfNeeded(relAttribute, url, document, header.crossOrigin());
    114         preloadIfNeeded(relAttribute, url, document, header.as(), header.media(), header.mimeType(), header.crossOrigin(), header.imageSrcSet(), header.imageSizes(), nullptr);
     111        preloadIfNeeded(relAttribute, url, document, header.as(), header.media(), header.mimeType(), header.crossOrigin(), nullptr);
    115112    }
    116113}
     
    231228}
    232229
    233 std::unique_ptr<LinkPreloadResourceClient> LinkLoader::preloadIfNeeded(const LinkRelAttribute& relAttribute, const URL& href, Document& document, const String& as, const String& media, const String& mimeType, const String& crossOriginMode, const String& imageSrcSet, const String& imageSizes, LinkLoader* loader)
     230std::unique_ptr<LinkPreloadResourceClient> LinkLoader::preloadIfNeeded(const LinkRelAttribute& relAttribute, const URL& href, Document& document, const String& as, const String& media, const String& mimeType, const String& crossOriginMode, LinkLoader* loader)
    234231{
    235232    if (!document.loader() || !relAttribute.isLinkPreload)
     
    237234
    238235    ASSERT(RuntimeEnabledFeatures::sharedFeatures().linkPreloadEnabled());
     236    if (!href.isValid()) {
     237        document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, "<link rel=preload> has an invalid `href` value"_s);
     238        return nullptr;
     239    }
    239240    auto type = LinkLoader::resourceTypeFromAsAttribute(as);
    240241    if (!type) {
     
    242243        return nullptr;
    243244    }
    244     URL url;
    245     if (type == CachedResource::Type::ImageResource && !imageSrcSet.isEmpty()) {
    246         auto sourceSize = SizesAttributeParser(imageSizes, document).length();
    247         auto candidate = bestFitSourceForImageAttributes(document.deviceScaleFactor(), href.string(), imageSrcSet, sourceSize);
    248         url = document.completeURL(URL({ }, candidate.string.toString()));
    249     } else
    250         url = document.completeURL(href);
    251 
    252     if (!url.isValid()) {
    253         if (imageSrcSet.isEmpty())
    254             document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, "<link rel=preload> has an invalid `href` value"_s);
    255         else
    256             document.addConsoleMessage(MessageSource::Other, MessageLevel::Error, "<link rel=preload> has an invalid `imagesrcset` value"_s);
    257         return nullptr;
    258     }
    259245    if (!MediaQueryEvaluator::mediaAttributeMatches(document, media))
    260246        return nullptr;
     
    263249
    264250    auto options = CachedResourceLoader::defaultCachedResourceOptions();
    265     auto linkRequest = createPotentialAccessControlRequest(url, document, crossOriginMode, WTFMove(options));
     251    auto linkRequest = createPotentialAccessControlRequest(document.completeURL(href), document, crossOriginMode, WTFMove(options));
    266252    linkRequest.setPriority(CachedResource::defaultPriorityForResourceType(type.value()));
    267253    linkRequest.setInitiator("link");
     
    314300}
    315301
    316 bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const URL& href, const String& as, const String& media, const String& mimeType, const String& crossOrigin, const String& imageSrcSet, const String& imageSizes, Document& document)
     302bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const URL& href, const String& as, const String& media, const String& mimeType, const String& crossOrigin, Document& document)
    317303{
    318304    if (relAttribute.isDNSPrefetch) {
     
    326312
    327313    if (m_client.shouldLoadLink()) {
    328         auto resourceClient = preloadIfNeeded(relAttribute, href, document, as, media, mimeType, crossOrigin, imageSrcSet, imageSizes, this);
     314        auto resourceClient = preloadIfNeeded(relAttribute, href, document, as, media, mimeType, crossOrigin, this);
    329315        if (m_preloadResourceClient)
    330316            m_preloadResourceClient->clear();
  • trunk/Source/WebCore/loader/LinkLoader.h

    r245475 r245825  
    5151    virtual ~LinkLoader();
    5252
    53     bool loadLink(const LinkRelAttribute&, const URL&, const String& as, const String& media, const String& type, const String& crossOrigin, const String& imageSrcSet, const String& imageSizes, Document&);
     53    bool loadLink(const LinkRelAttribute&, const URL&, const String& as, const String& media, const String& type, const String& crossOrigin, Document&);
    5454    static Optional<CachedResource::Type> resourceTypeFromAsAttribute(const String& as);
    5555
     
    6464    void notifyFinished(CachedResource&) override;
    6565    static void preconnectIfNeeded(const LinkRelAttribute&, const URL& href, Document&, const String& crossOrigin);
    66     static std::unique_ptr<LinkPreloadResourceClient> preloadIfNeeded(const LinkRelAttribute&, const URL& href, Document&, const String& as, const String& media, const String& type, const String& crossOriginMode, const String&, const String&, LinkLoader*);
     66    static std::unique_ptr<LinkPreloadResourceClient> preloadIfNeeded(const LinkRelAttribute&, const URL& href, Document&, const String& as, const String& media, const String& type, const String& crossOriginMode, LinkLoader*);
    6767    void prefetchIfNeeded(const LinkRelAttribute&, const URL& href, Document&);
    6868
Note: See TracChangeset for help on using the changeset viewer.