Title: [243653] trunk
Revision
243653
Author
[email protected]
Date
2019-03-29 11:39:51 -0700 (Fri, 29 Mar 2019)

Log Message

Pasting a table from Confluence strip of table cell content
https://bugs.webkit.org/show_bug.cgi?id=196390

Reviewed by Antti Koivisto.

Source/WebCore:

The bug was ultimately caused by FrameView of the document we use to sanitize the pasteboard content
having 0px by 0px dimension. This caused div with `overflow-x: auto` surrounding a table to have
the height of 0px. Because StyledMarkupAccumulator::renderedTextRespectingRange uses TextIterator
to serialize a text node and this div was an ancestor of the text node, TextIterator::handleTextNode
ended up exiting early.

Fixed the bug by giving FrameView, which is used to sanitize the content, a dimension of 800px by 600px.

Using TextIteratorIgnoresStyleVisibility is not a great alternative since removing invisible content
during paste is an important privacy feature.

Test: editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin.html

* editing/markup.cpp:
(WebCore::createPageForSanitizingWebContent):

LayoutTests:

Added a regression test.

* editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin-expected.txt: Added.
* editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (243652 => 243653)


--- trunk/LayoutTests/ChangeLog	2019-03-29 18:36:35 UTC (rev 243652)
+++ trunk/LayoutTests/ChangeLog	2019-03-29 18:39:51 UTC (rev 243653)
@@ -1,3 +1,15 @@
+2019-03-29  Ryosuke Niwa  <[email protected]>
+
+        Pasting a table from Confluence strip of table cell content
+        https://bugs.webkit.org/show_bug.cgi?id=196390
+
+        Reviewed by Antti Koivisto.
+
+        Added a regression test.
+
+        * editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin-expected.txt: Added.
+        * editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin.html: Added.
+
 2019-03-29  Shawn Roberts  <[email protected]>
 
         fast/mediastream/MediaStreamTrack-getSettings.html is a flaky failure

Added: trunk/LayoutTests/editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin-expected.txt (0 => 243653)


--- trunk/LayoutTests/editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin-expected.txt	2019-03-29 18:39:51 UTC (rev 243653)
@@ -0,0 +1,16 @@
+This tests copying and pasting content with "overflow: auto" would not strip its content.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS markup.includes("secret") is false
+PASS markup.includes("Start</div>") is true
+PASS markup.includes("Content</p>") is true
+PASS markup.includes("End</span>") is true
+PASS editor.querySelector("div").textContent is "Start"
+PASS editor.querySelector("p").textContent is "Content"
+PASS editor.querySelector("span").textContent is "End"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin.html (0 => 243653)


--- trunk/LayoutTests/editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin.html	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin.html	2019-03-29 18:39:51 UTC (rev 243653)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+
+description('This tests copying and pasting content with "overflow: auto" would not strip its content.');
+
+function startTest() {
+    const iframe = document.createElement('iframe');
+    document.body.appendChild(iframe);
+    iframe.src = "" html>
+    <body><button _onclick_="document.execCommand('selectAll'); document.execCommand('copy'); getSelection().removeAllRanges();">Start</button>
+    <script>
+    document.addEventListener('copy', () => {
+        event.preventDefault();
+        event.clipboardData.setData('text/html', '<div>Start</div><div style="height: 1000px;"></div><!-- secret -->'
+            + '<div style="visibility: hidden;">secret</div><p style="overflow: auto;">Content</p><div style="height: 1000px;"></div><span id="end">End</span>');
+        window.parent.postMessage({}, '*');
+    });
+    window._onload_ = () => {
+        document.execCommand('selectAll');
+        document.execCommand('copy');
+    }
+    </sc` + `ript>
+    </body>`;
+}
+
+
+function continueTest() {
+    editor.focus();
+    document.execCommand('selectAll');
+    if (window.testRunner)
+        testRunner.execCommand('paste');
+}
+
+function didPaste(event) {
+    window.markup = event.clipboardData.getData('text/html');
+    shouldBeFalse('markup.includes("secret")');
+    shouldBeTrue('markup.includes("Start</div>")');
+    shouldBeTrue('markup.includes("Content</p>")');
+    shouldBeTrue('markup.includes("End</span>")');
+
+    setTimeout(() => {
+        shouldBeEqualToString('editor.querySelector("div").textContent', 'Start');
+        shouldBeEqualToString('editor.querySelector("p").textContent', 'Content');
+        shouldBeEqualToString('editor.querySelector("span").textContent', 'End');
+        editor.textContent = editor.innerHTML;
+        editor.contentEditable = false;
+        if (window.testRunner)
+            editor.style.display = 'none';
+        finishJSTest();
+    }, 0);
+}
+
+_onload_ = startTest;
+_onmessage_ = continueTest;
+jsTestIsAsync = true;
+
+</script>
+<div id="editor" _onpaste_="didPaste(event)" contenteditable>Paste now</div>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (243652 => 243653)


--- trunk/Source/WebCore/ChangeLog	2019-03-29 18:36:35 UTC (rev 243652)
+++ trunk/Source/WebCore/ChangeLog	2019-03-29 18:39:51 UTC (rev 243653)
@@ -1,3 +1,26 @@
+2019-03-29  Ryosuke Niwa  <[email protected]>
+
+        Pasting a table from Confluence strip of table cell content
+        https://bugs.webkit.org/show_bug.cgi?id=196390
+
+        Reviewed by Antti Koivisto.
+
+        The bug was ultimately caused by FrameView of the document we use to sanitize the pasteboard content
+        having 0px by 0px dimension. This caused div with `overflow-x: auto` surrounding a table to have
+        the height of 0px. Because StyledMarkupAccumulator::renderedTextRespectingRange uses TextIterator
+        to serialize a text node and this div was an ancestor of the text node, TextIterator::handleTextNode
+        ended up exiting early.
+
+        Fixed the bug by giving FrameView, which is used to sanitize the content, a dimension of 800px by 600px.
+
+        Using TextIteratorIgnoresStyleVisibility is not a great alternative since removing invisible content
+        during paste is an important privacy feature.
+
+        Test: editing/pasteboard/paste-content-with-overflow-auto-parent-across-origin.html
+
+        * editing/markup.cpp:
+        (WebCore::createPageForSanitizingWebContent):
+
 2019-03-29  Antoine Quint  <[email protected]>
 
         WebKitTestRunner crashes when running pointerevents/ios/touch-action-none-in-overflow-scrolling-touch.html

Modified: trunk/Source/WebCore/editing/markup.cpp (243652 => 243653)


--- trunk/Source/WebCore/editing/markup.cpp	2019-03-29 18:36:35 UTC (rev 243652)
+++ trunk/Source/WebCore/editing/markup.cpp	2019-03-29 18:39:51 UTC (rev 243653)
@@ -183,7 +183,7 @@
     page->settings().setAcceleratedCompositingEnabled(false);
 
     Frame& frame = page->mainFrame();
-    frame.setView(FrameView::create(frame));
+    frame.setView(FrameView::create(frame, IntSize { 800, 600 }));
     frame.init();
 
     FrameLoader& loader = frame.loader();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to