| Index: third_party/WebKit/LayoutTests/editing/pasteboard/copy-text-with-backgroundcolor.html
|
| diff --git a/third_party/WebKit/LayoutTests/editing/pasteboard/copy-text-with-backgroundcolor.html b/third_party/WebKit/LayoutTests/editing/pasteboard/copy-text-with-backgroundcolor.html
|
| index 07484d77980a783362e573aebf04e7d9acfbe00b..7c4da1cc99680c2fb505c8ba3b94a6044be67cf9 100644
|
| --- a/third_party/WebKit/LayoutTests/editing/pasteboard/copy-text-with-backgroundcolor.html
|
| +++ b/third_party/WebKit/LayoutTests/editing/pasteboard/copy-text-with-backgroundcolor.html
|
| @@ -1,76 +1,82 @@
|
| -<!DOCTYPE html>
|
| -<html>
|
| -<head>
|
| -
|
| -<style>
|
| -.editing {
|
| - border: 2px solid red;
|
| - font-size: 24px;
|
| -}
|
| -.explanation {
|
| - border: 2px solid blue;
|
| - padding: 12px;
|
| - font-size: 24px;
|
| - margin-bottom: 24px;
|
| -}
|
| -.scenario { margin-bottom: 16px;}
|
| -.scenario:first-line { font-weight: bold; margin-bottom: 16px;}
|
| -.expected-results:first-line { font-weight: bold }
|
| -</style>
|
| -<script src=../editing.js></script>
|
| -<script src="../../resources/dump-as-markup.js"></script>
|
| -
|
| +<!doctype html>
|
| +<script src="../../resources/testharness.js"></script>
|
| +<script src="../../resources/testharnessreport.js"></script>
|
| +<script src="../assert_selection.js"></script>
|
| <script>
|
| -if (window.internals)
|
| - internals.settings.setEditingBehavior('mac');
|
| -if (window.testRunner)
|
| - testRunner.dumpAsText();
|
| -
|
| -function performCopyPaste(elementName)
|
| -{
|
| - var element = document.getElementById(elementName);
|
| - window.getSelection().collapse(element.firstChild, 0);
|
| - window.getSelection().modify('extend', 'forward', 'word');
|
| - window.getSelection().modify('extend', 'forward', 'word');
|
| - copyCommand();
|
| - window.getSelection().modify('move', 'forward', 'character');
|
| - pasteCommand();
|
| -}
|
| +test(() => {
|
| + assert_not_equals(window.internals, undefined,
|
| + 'This test requires to access clipboard from JavaScript');
|
|
|
| -function editingTest() {
|
| - Markup.dump('test', 'Markup before');
|
| - performCopyPaste("test");
|
| - performCopyPaste("test2");
|
| - performCopyPaste("test3");
|
| - Markup.dump('test', 'Markup after');
|
| -}
|
| -</script>
|
| + assert_selection(
|
| + [
|
| + '<div contenteditable>',
|
| + '<span style="background-color: red">^abc|</span>',
|
| + '<span id="dst" style="background-color: red">def</span>',
|
| + '</div>',
|
| + ].join(''),
|
| + selection => {
|
| + selection.document.execCommand('copy');
|
| + selection.collapse(selection.document.getElementById('dst'), 0);
|
| + selection.document.execCommand('paste');
|
| + },
|
| + [
|
| + '<div contenteditable>',
|
| + '<span style="background-color: red">abc</span>',
|
| + '<span id="dst" style="background-color: red">abc|def</span>',
|
| + '</div>',
|
| + ].join(''),
|
| + 'Paste to same background-color');
|
|
|
| -<title>Editing Test</title>
|
| -</head>
|
| -<body>
|
| -<div class="explanation">
|
| -<div class="scenario">
|
| -Tests:
|
| -<br>
|
| -Fix for this bug:
|
| -<a href="https://bugs.webkit.org/show_bug.cgi?id=58925"><https://bugs.webkit.org/show_bug.cgi?id=58925></a> REGRESSION(r55762): Highlight color can't be copied in gmail.
|
| -</div>
|
| -<div class="expected-results">
|
| -Expected Results:
|
| -<br>
|
| -The pasted text should have the same background color as the copied text. To run the test manually, select each of the two words with the same background color, copy, move the selection at the end of the second word and paste.
|
| -</div>
|
| -</div>
|
| -<div contenteditable id="test" class="editing">
|
| -<span style="background-color: rgb(255, 0, 0);">Red background</span>
|
| -<div id="test2"><span style="background-color: green;">Green background</span></div>
|
| -<div id="test3"><span style="background-color: rgb(255, 0, 0, 0);">Transparent background</span></div>
|
| -</div>
|
| + assert_selection(
|
| + [
|
| + '<div contenteditable>',
|
| + '<span style="background-color: red">^abc|</span>',
|
| + '<span id="dst" style="background-color: green">def</span>',
|
| + '</div>',
|
| + ].join(''),
|
| + selection => {
|
| + selection.document.execCommand('copy');
|
| + selection.collapse(selection.document.getElementById('dst'), 0);
|
| + selection.document.execCommand('paste');
|
| + },
|
| + [
|
| + '<div contenteditable>',
|
| + '<span style="background-color: red">abc</span>',
|
| + '<span id="dst" style="background-color: green">',
|
| + '<span style="background-color: rgb(255, 0, 0);">',
|
| + 'abc|',
|
| + '</span>',
|
| + 'def',
|
| + '</span>',
|
| + '</div>',
|
| + ].join(''),
|
| + 'Paste to different background-color');
|
|
|
| -<script>
|
| -runEditingTest();
|
| + assert_selection(
|
| + [
|
| + '<div contenteditable>',
|
| + '<span style="background-color: red">^abc|</span>',
|
| + '<span id="dst" style="background-color: rgba(255, 0, 0, 0)">',
|
| + 'def',
|
| + '</span>',
|
| + '</div>',
|
| + ].join(''),
|
| + selection => {
|
| + selection.document.execCommand('copy');
|
| + selection.collapse(selection.document.getElementById('dst'), 0);
|
| + selection.document.execCommand('paste');
|
| + },
|
| + [
|
| + '<div contenteditable>',
|
| + '<span style="background-color: red">abc</span>',
|
| + '<span id="dst" style="background-color: rgba(255, 0, 0, 0)">',
|
| + '<span style="background-color: rgb(255, 0, 0);">',
|
| + 'abc|',
|
| + '</span>',
|
| + 'def',
|
| + '</span>',
|
| + '</div>',
|
| + ].join(''),
|
| + 'Paste to transparent background-color');
|
| +});
|
| </script>
|
| -
|
| -</body>
|
| -</html>
|
|
|