| Index: third_party/WebKit/LayoutTests/editing/assert_selection.js
|
| diff --git a/third_party/WebKit/LayoutTests/editing/assert_selection.js b/third_party/WebKit/LayoutTests/editing/assert_selection.js
|
| index 9d26d1fcc2baa79ab62ea384a08088c5ff163fd9..4c4ead925d78b20cba4ebe74a42004950c36632f 100644
|
| --- a/third_party/WebKit/LayoutTests/editing/assert_selection.js
|
| +++ b/third_party/WebKit/LayoutTests/editing/assert_selection.js
|
| @@ -508,6 +508,32 @@ class Serializer {
|
| }
|
| }
|
|
|
| +/**
|
| + * @this {!DOMSelection}
|
| + * @param {string} html
|
| + * @param {string=} opt_text
|
| + */
|
| +function setClipboardData(html, opt_text) {
|
| + assert_not_equals(window.internals, undefined,
|
| + 'This test requests clipboard access from JavaScript.');
|
| + function computeTextData() {
|
| + if (opt_text !== undefined)
|
| + return opt_text;
|
| + const element = document.createElement('div');
|
| + element.innerHTML = html;
|
| + return element.textContent;
|
| + }
|
| + function copyHandler(event) {
|
| + const clipboardData = event.clipboardData;
|
| + clipboardData.setData('text/plain', computeTextData());
|
| + clipboardData.setData('text/html', html);
|
| + event.preventDefault();
|
| + }
|
| + document.addEventListener('copy', copyHandler);
|
| + document.execCommand('copy');
|
| + document.removeEventListener('copy', copyHandler);
|
| +}
|
| +
|
| class Sample {
|
| /**
|
| * @public
|
| @@ -526,6 +552,7 @@ class Sample {
|
| this.selection_.document = this.document_;
|
| this.selection_.document.offsetLeft = this.iframe_.offsetLeft;
|
| this.selection_.document.offsetTop = this.iframe_.offsetTop;
|
| + this.selection_.setClipboardData = setClipboardData;
|
|
|
| this.load(sampleText);
|
| }
|
|
|