OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // TODO(kalman): Consolidate this test script with the other clipboard tests. |
| 6 |
| 7 function appendTextarea() { |
| 8 return document.body.appendChild(document.createElement('textarea')); |
| 9 } |
| 10 |
| 11 function run() { |
| 12 var textIn = appendTextarea(); |
| 13 |
| 14 textIn.focus(); |
| 15 textIn.value = 'foobar'; |
| 16 textIn.selectionStart = 0; |
| 17 textIn.selectionEnd = 'foobar'.length; |
| 18 if (!document.execCommand('copy')) |
| 19 return 'Failed to copy'; |
| 20 |
| 21 var textOut = appendTextarea(); |
| 22 |
| 23 textOut.focus(); |
| 24 if (!document.execCommand('paste')) |
| 25 return 'Failed to paste'; |
| 26 if (textOut.value != 'foobar') |
| 27 return 'Expected "foobar", got ' + textOut.value; |
| 28 |
| 29 return ''; |
| 30 } |
| 31 |
| 32 chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) { |
| 33 sendResponse(run()); |
| 34 }); |
OLD | NEW |