Title: [270300] trunk
Revision
270300
Author
[email protected]
Date
2020-12-01 09:14:28 -0800 (Tue, 01 Dec 2020)

Log 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 <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (270299 => 270300)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-12-01 15:53:23 UTC (rev 270299)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-12-01 17:14:28 UTC (rev 270300)
@@ -1,3 +1,14 @@
+2020-12-01  Rob Buis  <[email protected]>
+
+        Lazy loaded iframe should not lazy load when scripting is disabled
+        https://bugs.webkit.org/show_bug.cgi?id=217315
+
+        Reviewed by Darin Adler.
+
+        Update improved test expectation.
+
+        * web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-in-script-disabled-iframe-expected.txt:
+
 2020-12-01  Youenn Fablet  <[email protected]>
 
         CSSStyleSheet.cssRules and rules should throw in case of opaque stylesheets

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-in-script-disabled-iframe-expected.txt (270299 => 270300)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-in-script-disabled-iframe-expected.txt	2020-12-01 15:53:23 UTC (rev 270299)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-in-script-disabled-iframe-expected.txt	2020-12-01 17:14:28 UTC (rev 270300)
@@ -1,5 +1,5 @@
 
 
-FAIL Iframes with loading='lazy' in script disabled iframe are not handled
-       as 'lazy' promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'inner_iframe.contentDocument.body')"
+PASS Iframes with loading='lazy' in script disabled iframe are not handled
+       as 'lazy'
 

Modified: trunk/Source/WebCore/ChangeLog (270299 => 270300)


--- trunk/Source/WebCore/ChangeLog	2020-12-01 15:53:23 UTC (rev 270299)
+++ trunk/Source/WebCore/ChangeLog	2020-12-01 17:14:28 UTC (rev 270300)
@@ -1,3 +1,24 @@
+2020-12-01  Rob Buis  <[email protected]>
+
+        Lazy loaded iframe should not lazy load when scripting is disabled
+        https://bugs.webkit.org/show_bug.cgi?id=217315
+
+        Reviewed by Darin Adler.
+
+        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):
+
 2020-12-01  Tetsuharu Ohzeki  <[email protected]>
 
         [WebIDL] Move ShadowRootInit to dedicated idl file from Element.idl

Modified: trunk/Source/WebCore/html/HTMLIFrameElement.cpp (270299 => 270300)


--- trunk/Source/WebCore/html/HTMLIFrameElement.cpp	2020-12-01 15:53:23 UTC (rev 270299)
+++ trunk/Source/WebCore/html/HTMLIFrameElement.cpp	2020-12-01 17:14:28 UTC (rev 270300)
@@ -164,11 +164,14 @@
     setAttributeWithoutSynchronization(loadingAttr, value);
 }
 
-static bool isFrameLazyLoadable(const URL& completeURL, const AtomString& loadingAttributeValue)
+static bool isFrameLazyLoadable(const Document& document, const URL& completeURL, const AtomString& loadingAttributeValue)
 {
     if (!completeURL.protocolIsInHTTPFamily())
         return false;
 
+    if (!document.frame() || !document.frame()->script().canExecuteScripts(NotAboutToExecuteScript))
+        return false;
+
     return equalLettersIgnoringASCIICase(loadingAttributeValue, "lazy");
 }
 
@@ -176,7 +179,7 @@
 {
     if (!m_lazyLoadFrameObserver && document().settings().lazyIframeLoadingEnabled()) {
         URL completeURL = document().completeURL(frameURL());
-        if (isFrameLazyLoadable(completeURL, attributeWithoutSynchronization(HTMLNames::loadingAttr))) {
+        if (isFrameLazyLoadable(document(), completeURL, attributeWithoutSynchronization(HTMLNames::loadingAttr))) {
             auto currentReferrerPolicy = referrerPolicy();
             lazyLoadFrameObserver().observe(completeURL.string(), currentReferrerPolicy);
             return true;

Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (270299 => 270300)


--- trunk/Source/WebCore/html/HTMLImageElement.cpp	2020-12-01 15:53:23 UTC (rev 270299)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp	2020-12-01 17:14:28 UTC (rev 270300)
@@ -870,7 +870,7 @@
 
 bool HTMLImageElement::isLazyLoadable() const
 {
-    if (document().frame() && !document().frame()->script().canExecuteScripts(NotAboutToExecuteScript))
+    if (!document().frame() || !document().frame()->script().canExecuteScripts(NotAboutToExecuteScript))
         return false;
     return hasLazyLoadableAttributeValue(attributeWithoutSynchronization(HTMLNames::loadingAttr));
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to