Title: [226216] trunk
Revision
226216
Author
[email protected]
Date
2017-12-20 22:48:48 -0800 (Wed, 20 Dec 2017)

Log Message

DeferredLoadingScope incorrectly disabled images or enables deferred loading
https://bugs.webkit.org/show_bug.cgi?id=181077

Reviewed by Wenson Hsieh.

Source/WebCore:

Fixed the bug that DeferredLoadingScope::~DeferredLoadingScope was checking the wrong flag
for restoring the disabledness of images and deferred loading.

Test: editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading.html

* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::DeferredLoadingScope::~DeferredLoadingScope): Fixed the bug.
* testing/Internals.cpp:
(WebCore::Internals::pageDefersLoading): Added for testing.
* testing/Internals.h:
* testing/Internals.idl: Added pageDefersLoading.

LayoutTests:

Added a regression test.

* editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading-expected.txt: Added.
* editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (226215 => 226216)


--- trunk/LayoutTests/ChangeLog	2017-12-21 05:39:31 UTC (rev 226215)
+++ trunk/LayoutTests/ChangeLog	2017-12-21 06:48:48 UTC (rev 226216)
@@ -1,3 +1,15 @@
+2017-12-20  Ryosuke Niwa  <[email protected]>
+
+        DeferredLoadingScope incorrectly disabled images or enables deferred loading
+        https://bugs.webkit.org/show_bug.cgi?id=181077
+
+        Reviewed by Wenson Hsieh.
+
+        Added a regression test.
+
+        * editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading-expected.txt: Added.
+        * editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading.html: Added.
+
 2017-12-20  Eric Carlson  <[email protected]>
 
         [MediaStream] Add screen capture IDL and stub functions

Added: trunk/LayoutTests/editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading-expected.txt (0 => 226216)


--- trunk/LayoutTests/editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading-expected.txt	2017-12-21 06:48:48 UTC (rev 226216)
@@ -0,0 +1,17 @@
+This tests makes sure that pasting content while images are disabled does not enable deferred loading.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+internals.settings.setImagesEnabled(false)
+document.execCommand("copy")
+PASS editor.querySelector("img").width is 76
+setTimeout(waitForImagesToBeDisabled, 0)
+PASS internals.pageDefersLoading() is false
+document.execCommand("paste")
+PASS internals.pageDefersLoading() is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+hello
+

Added: trunk/LayoutTests/editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading.html (0 => 226216)


--- trunk/LayoutTests/editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading.html	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading.html	2017-12-21 06:48:48 UTC (rev 226216)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<div id="editor" contenteditable>hello<img src=""
+<script>
+
+description('This tests makes sure that pasting content while images are disabled does not enable deferred loading.')
+
+if (!window.internals)
+    testFailed('This test requires internals.settings');
+else {
+    jsTestIsAsync = true;
+
+    window._onload_ = () => {
+        editor.focus();
+        document.execCommand("selectAll");
+        evalAndLog('internals.settings.setImagesEnabled(false)');
+        evalAndLog('document.execCommand("copy")');
+        shouldBe('editor.querySelector("img").width', '76');
+        evalAndLog('setTimeout(waitForImagesToBeDisabled, 0)');
+    }
+
+    function waitForImagesToBeDisabled()
+    {
+        shouldBeFalse('internals.pageDefersLoading()');
+        evalAndLog('document.execCommand("paste")');
+        shouldBeFalse('internals.pageDefersLoading()');
+        finishJSTest();
+    }
+
+}
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (226215 => 226216)


--- trunk/Source/WebCore/ChangeLog	2017-12-21 05:39:31 UTC (rev 226215)
+++ trunk/Source/WebCore/ChangeLog	2017-12-21 06:48:48 UTC (rev 226216)
@@ -1,5 +1,24 @@
 2017-12-20  Ryosuke Niwa  <[email protected]>
 
+        DeferredLoadingScope incorrectly disabled images or enables deferred loading
+        https://bugs.webkit.org/show_bug.cgi?id=181077
+
+        Reviewed by Wenson Hsieh.
+
+        Fixed the bug that DeferredLoadingScope::~DeferredLoadingScope was checking the wrong flag
+        for restoring the disabledness of images and deferred loading.
+
+        Test: editing/pasteboard/pasting-with-images-disabled-should-not-enable-deferred-loading.html
+
+        * editing/cocoa/WebContentReaderCocoa.mm:
+        (WebCore::DeferredLoadingScope::~DeferredLoadingScope): Fixed the bug.
+        * testing/Internals.cpp:
+        (WebCore::Internals::pageDefersLoading): Added for testing.
+        * testing/Internals.h:
+        * testing/Internals.idl: Added pageDefersLoading.
+
+2017-12-20  Ryosuke Niwa  <[email protected]>
+
         isSafari check should take Safari Technology Preview into account
         https://bugs.webkit.org/show_bug.cgi?id=181076
 

Modified: trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (226215 => 226216)


--- trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm	2017-12-21 05:39:31 UTC (rev 226215)
+++ trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm	2017-12-21 06:48:48 UTC (rev 226216)
@@ -162,9 +162,9 @@
 
     ~DeferredLoadingScope()
     {
+        if (m_didDisableImage)
+            m_cachedResourceLoader->setImagesEnabled(true);
         if (m_didEnabledDeferredLoading)
-            m_cachedResourceLoader->setImagesEnabled(true);
-        if (m_didDisableImage)
             m_frame->page()->setDefersLoading(false);
     }
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (226215 => 226216)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-12-21 05:39:31 UTC (rev 226215)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-12-21 06:48:48 UTC (rev 226216)
@@ -3694,6 +3694,14 @@
         page->setDefersLoading(defersLoading);
 }
 
+ExceptionOr<bool> Internals::pageDefersLoading()
+{
+    Document* document = contextDocument();
+    if (!document || !document->page())
+        return Exception { InvalidAccessError };
+    return document->page()->defersLoading();
+}
+
 RefPtr<File> Internals::createFile(const String& path)
 {
     Document* document = contextDocument();

Modified: trunk/Source/WebCore/testing/Internals.h (226215 => 226216)


--- trunk/Source/WebCore/testing/Internals.h	2017-12-21 05:39:31 UTC (rev 226215)
+++ trunk/Source/WebCore/testing/Internals.h	2017-12-21 06:48:48 UTC (rev 226216)
@@ -530,6 +530,7 @@
     String pageMediaState();
 
     void setPageDefersLoading(bool);
+    ExceptionOr<bool> pageDefersLoading();
 
     RefPtr<File> createFile(const String&);
     void queueMicroTask(int);

Modified: trunk/Source/WebCore/testing/Internals.idl (226215 => 226216)


--- trunk/Source/WebCore/testing/Internals.idl	2017-12-21 05:39:31 UTC (rev 226215)
+++ trunk/Source/WebCore/testing/Internals.idl	2017-12-21 06:48:48 UTC (rev 226216)
@@ -484,6 +484,7 @@
     DOMString pageMediaState();
 
     void setPageDefersLoading(boolean defersLoading);
+    [MayThrowException] boolean pageDefersLoading();
 
     File? createFile(DOMString url);
     void queueMicroTask(long testNumber);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to