Changeset 270300 in webkit


Ignore:
Timestamp:
Dec 1, 2020 9:14:28 AM (20 months ago)
Author:
commit-queue@webkit.org
Message:

Lazy loaded iframe should not lazy load when scripting is disabled
https://bugs.webkit.org/show_bug.cgi?id=217315

Patch by Rob Buis <rbuis@igalia.com> on 2020-12-01
Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Update improved test expectation.

  • web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-in-script-disabled-iframe-expected.txt:

Source/WebCore:

Lazy loaded iframe should not lazy load when scripting is disabled [1].

Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-in-script-disabled-iframe.html

[1] https://html.spec.whatwg.org/#will-lazy-load-element-steps

This matches Chrome and Firefox.

  • html/HTMLIFrameElement.cpp:

(WebCore::isFrameLazyLoadable):
(WebCore::HTMLIFrameElement::shouldLoadFrameLazily):

  • html/HTMLImageElement.cpp:

(WebCore::HTMLImageElement::isLazyLoadable const):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r270296 r270300  
     12020-12-01  Rob Buis  <rbuis@igalia.com>
     2
     3        Lazy loaded iframe should not lazy load when scripting is disabled
     4        https://bugs.webkit.org/show_bug.cgi?id=217315
     5
     6        Reviewed by Darin Adler.
     7
     8        Update improved test expectation.
     9
     10        * web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-in-script-disabled-iframe-expected.txt:
     11
    1122020-12-01  Youenn Fablet  <youenn@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-in-script-disabled-iframe-expected.txt

    r269598 r270300  
    11
    22
    3 FAIL Iframes with loading='lazy' in script disabled iframe are not handled
    4        as 'lazy' promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'inner_iframe.contentDocument.body')"
     3PASS Iframes with loading='lazy' in script disabled iframe are not handled
     4       as 'lazy'
    55
  • trunk/Source/WebCore/ChangeLog

    r270297 r270300  
     12020-12-01  Rob Buis  <rbuis@igalia.com>
     2
     3        Lazy loaded iframe should not lazy load when scripting is disabled
     4        https://bugs.webkit.org/show_bug.cgi?id=217315
     5
     6        Reviewed by Darin Adler.
     7
     8        Lazy loaded iframe should not lazy load when scripting is disabled [1].
     9
     10        Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-in-script-disabled-iframe.html
     11
     12        [1] https://html.spec.whatwg.org/#will-lazy-load-element-steps
     13
     14        This matches Chrome and Firefox.
     15
     16        * html/HTMLIFrameElement.cpp:
     17        (WebCore::isFrameLazyLoadable):
     18        (WebCore::HTMLIFrameElement::shouldLoadFrameLazily):
     19        * html/HTMLImageElement.cpp:
     20        (WebCore::HTMLImageElement::isLazyLoadable const):
     21
    1222020-12-01  Tetsuharu Ohzeki  <tetsuharu.ohzeki@gmail.com>
    223
  • trunk/Source/WebCore/html/HTMLIFrameElement.cpp

    r266991 r270300  
    165165}
    166166
    167 static bool isFrameLazyLoadable(const URL& completeURL, const AtomString& loadingAttributeValue)
     167static bool isFrameLazyLoadable(const Document& document, const URL& completeURL, const AtomString& loadingAttributeValue)
    168168{
    169169    if (!completeURL.protocolIsInHTTPFamily())
    170170        return false;
    171171
     172    if (!document.frame() || !document.frame()->script().canExecuteScripts(NotAboutToExecuteScript))
     173        return false;
     174
    172175    return equalLettersIgnoringASCIICase(loadingAttributeValue, "lazy");
    173176}
     
    177180    if (!m_lazyLoadFrameObserver && document().settings().lazyIframeLoadingEnabled()) {
    178181        URL completeURL = document().completeURL(frameURL());
    179         if (isFrameLazyLoadable(completeURL, attributeWithoutSynchronization(HTMLNames::loadingAttr))) {
     182        if (isFrameLazyLoadable(document(), completeURL, attributeWithoutSynchronization(HTMLNames::loadingAttr))) {
    180183            auto currentReferrerPolicy = referrerPolicy();
    181184            lazyLoadFrameObserver().observe(completeURL.string(), currentReferrerPolicy);
  • trunk/Source/WebCore/html/HTMLImageElement.cpp

    r269155 r270300  
    871871bool HTMLImageElement::isLazyLoadable() const
    872872{
    873     if (document().frame() && !document().frame()->script().canExecuteScripts(NotAboutToExecuteScript))
     873    if (!document().frame() || !document().frame()->script().canExecuteScripts(NotAboutToExecuteScript))
    874874        return false;
    875875    return hasLazyLoadableAttributeValue(attributeWithoutSynchronization(HTMLNames::loadingAttr));
Note: See TracChangeset for help on using the changeset viewer.