Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / clipboard / extension / content_script.js
blob27a4b5b621cf5e1b49fdc90ea913bf8243770ec8
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.
5 // TODO(kalman): Consolidate this test script with the other clipboard tests.
7 function appendTextarea() {
8 return document.body.appendChild(document.createElement('textarea'));
11 function run() {
12 var textIn = appendTextarea();
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';
21 var textOut = appendTextarea();
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;
29 return '';
32 chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
33 sendResponse(run());
34 });