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

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

Issue 501513002: Change these tests to actually trigger the execCommand from the iframe context. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add copyright Created 6 years, 4 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/test/data/extensions/api_test/clipboard/extension/iframe.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_dom_clipboard_apitest.cc
diff --git a/chrome/browser/extensions/extension_dom_clipboard_apitest.cc b/chrome/browser/extensions/extension_dom_clipboard_apitest.cc
index 20da52acda627c935b35c2e5ca8ab7e4806ad8f0..092dd023b93c56f65f61e47f7e92b256801c929d 100644
--- a/chrome/browser/extensions/extension_dom_clipboard_apitest.cc
+++ b/chrome/browser/extensions/extension_dom_clipboard_apitest.cc
@@ -21,8 +21,7 @@ class ClipboardApiTest : public ExtensionApiTest {
const std::string& launch_page);
bool ExecuteCopyInSelectedTab();
bool ExecutePasteInSelectedTab();
- bool ExecuteCopyInIframeInSelectedTab();
- bool ExecutePasteInIframeInSelectedTab();
+ bool ExecuteCommandInIframeInSelectedTab(const char* command);
private:
bool ExecuteScriptInSelectedTab(const std::string& script);
@@ -69,22 +68,14 @@ bool ClipboardApiTest::ExecutePasteInSelectedTab() {
return ExecuteScriptInSelectedTab(kScript);
}
-bool ClipboardApiTest::ExecuteCopyInIframeInSelectedTab() {
+bool ClipboardApiTest::ExecuteCommandInIframeInSelectedTab(
+ const char* command) {
const char kScript[] =
"var ifr = document.createElement('iframe');\n"
"document.body.appendChild(ifr);\n"
- "window.domAutomationController.send("
- "ifr.contentDocument.execCommand('copy'));";
- return ExecuteScriptInSelectedTab(kScript);
-}
-
-bool ClipboardApiTest::ExecutePasteInIframeInSelectedTab() {
- const char kScript[] =
- "var ifr = document.createElement('iframe');\n"
- "document.body.appendChild(ifr);\n"
- "window.domAutomationController.send("
- "ifr.contentDocument.execCommand('paste'));";
- return ExecuteScriptInSelectedTab(kScript);
+ "ifr.contentDocument.write('<script>parent.domAutomationController.send("
+ "document.execCommand(\"%s\"))</script>');";
+ return ExecuteScriptInSelectedTab(base::StringPrintf(kScript, command));
}
bool ClipboardApiTest::ExecuteScriptInSelectedTab(const std::string& script) {
@@ -114,8 +105,8 @@ IN_PROC_BROWSER_TEST_F(ClipboardApiTest, HostedApp) {
EXPECT_TRUE(ExecuteCopyInSelectedTab()) << message_;
EXPECT_TRUE(ExecutePasteInSelectedTab()) << message_;
- EXPECT_TRUE(ExecuteCopyInIframeInSelectedTab()) << message_;
- EXPECT_TRUE(ExecutePasteInIframeInSelectedTab()) << message_;
+ EXPECT_TRUE(ExecuteCommandInIframeInSelectedTab("copy")) << message_;
+ EXPECT_TRUE(ExecuteCommandInIframeInSelectedTab("paste")) << message_;
}
IN_PROC_BROWSER_TEST_F(ClipboardApiTest, HostedAppNoPermission) {
@@ -124,7 +115,7 @@ IN_PROC_BROWSER_TEST_F(ClipboardApiTest, HostedAppNoPermission) {
EXPECT_FALSE(ExecuteCopyInSelectedTab()) << message_;
EXPECT_FALSE(ExecutePasteInSelectedTab()) << message_;
- EXPECT_FALSE(ExecuteCopyInIframeInSelectedTab()) << message_;
- EXPECT_FALSE(ExecutePasteInIframeInSelectedTab()) << message_;
+ EXPECT_FALSE(ExecuteCommandInIframeInSelectedTab("copy")) << message_;
+ EXPECT_FALSE(ExecuteCommandInIframeInSelectedTab("paste")) << message_;
}
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/clipboard/extension/iframe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698