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

Unified Diff: chrome/browser/extensions/clipboard_app_apitest.cc

Issue 6976002: Support clipboardRead and clipboardWrite permission for hosted apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 7 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
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/clipboard_app_apitest.cc
diff --git a/chrome/browser/extensions/clipboard_app_apitest.cc b/chrome/browser/extensions/clipboard_app_apitest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a5e450c8052a0e187bb9cdb90949625d1998db14
--- /dev/null
+++ b/chrome/browser/extensions/clipboard_app_apitest.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 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.
+
+#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/test/ui_test_utils.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/mock_host_resolver.h"
+
+IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ClipboardApp) {
+ host_resolver()->AddRule("*", "127.0.0.1");
+ ASSERT_TRUE(StartTestServer());
+
+ ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("clipboard_app")));
+
+ GURL base_url = test_server()->GetURL(
+ "files/extensions/api_test/clipboard_app/");
+ GURL::Replacements replace_host;
+ std::string host_str("localhost"); // Must stay in scope with replace_host.
+ replace_host.SetHostStr(host_str);
+ base_url = base_url.ReplaceComponents(replace_host);
+
+ ui_test_utils::NavigateToURL(browser(), base_url.Resolve("main.html"));
+
+ const wchar_t kScript[] =
+ L"function runTest() {"
+ L" document.body.addEventListener('copy', runTest2);"
Erik does not do reviews 2011/05/20 21:49:01 This approach is a bit of a bummer since it depend
+ L" document.execCommand('copy');"
+ L"}"
+ L"function runTest2() {"
+ L" document.body.addEventListener('paste', runTest3);"
+ L" document.execCommand('paste');"
+ L"}"
+ L"function runTest3() {"
+ L" window.domAutomationController.send(true);"
+ L"}"
+ L"runTest();";
+
+ bool result = false;
+ ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
+ browser()->GetSelectedTabContents()->render_view_host(),
+ L"",
+ kScript,
+ &result));
+ EXPECT_TRUE(result);
+}
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698