From c91cd9645e2cebf73f5231a162fcba3e9914eaa5 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 18 Jan 2021 09:26:18 +0000 Subject: [PATCH] Bug 1130891 part 5 - Add test for the copy behavior. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D102099 --- dom/base/test/copypaste.js | 23 +++++++++++++++++++++++ dom/base/test/test_copypaste.html | 2 ++ 2 files changed, 25 insertions(+) diff --git a/dom/base/test/copypaste.js b/dom/base/test/copypaste.js index e04f342133a3..48227a193a8b 100644 --- a/dom/base/test/copypaste.js +++ b/dom/base/test/copypaste.js @@ -530,4 +530,27 @@ async function testCopyPaste(isXHTML) { await new Promise(resolve => { setTimeout(resolve, 0); }); + + if (!isXHTML) { + // ============ copy from ruby + + const ruby1 = $("ruby1"); + const ruby1Container = ruby1.parentNode; + + // Ruby annotation is included when selecting inside ruby. + await copyRangeToClipboard(ruby1, 0, ruby1, 6); + testClipboardValue("text/unicode", "aabb(AABB)"); + + // Ruby annotation is ignored when selecting across ruby. + await copyRangeToClipboard(ruby1Container, 0, ruby1Container, 3); + testClipboardValue("text/unicode", "XaabbY"); + + // ... unless converter.html2txt.always_include_ruby is set + await SpecialPowers.pushPrefEnv({ + set: [["converter.html2txt.always_include_ruby", true]], + }); + await copyRangeToClipboard(ruby1Container, 0, ruby1Container, 3); + testClipboardValue("text/unicode", "Xaabb(AABB)Y"); + await SpecialPowers.popPrefEnv(); + } } diff --git a/dom/base/test/test_copypaste.html b/dom/base/test/test_copypaste.html index 99c3411b06df..014ac7f9dcb4 100644 --- a/dom/base/test/test_copypaste.html +++ b/dom/base/test/test_copypaste.html @@ -118,6 +118,8 @@ x.appendChild(document.createTextNode('10'))
foobar
12
34
56
+
Xaabb(AABB)Y
+