Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11226)

Unified Diff: chrome/test/data/extensions/api_test/clipboard/extension/content_script.js

Issue 498513002: Respect the clipboardRead and clipboardWrite permissions in content scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address more comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/clipboard/extension/content_script.js
diff --git a/chrome/test/data/extensions/api_test/clipboard/extension/content_script.js b/chrome/test/data/extensions/api_test/clipboard/extension/content_script.js
new file mode 100644
index 0000000000000000000000000000000000000000..27a4b5b621cf5e1b49fdc90ea913bf8243770ec8
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/clipboard/extension/content_script.js
@@ -0,0 +1,34 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// TODO(kalman): Consolidate this test script with the other clipboard tests.
+
+function appendTextarea() {
+ return document.body.appendChild(document.createElement('textarea'));
+}
+
+function run() {
+ var textIn = appendTextarea();
+
+ textIn.focus();
+ textIn.value = 'foobar';
+ textIn.selectionStart = 0;
+ textIn.selectionEnd = 'foobar'.length;
+ if (!document.execCommand('copy'))
+ return 'Failed to copy';
+
+ var textOut = appendTextarea();
+
+ textOut.focus();
+ if (!document.execCommand('paste'))
+ return 'Failed to paste';
+ if (textOut.value != 'foobar')
+ return 'Expected "foobar", got ' + textOut.value;
+
+ return '';
+}
+
+chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
+ sendResponse(run());
+});

Powered by Google App Engine
This is Rietveld 408576698