summaryrefslogtreecommitdiffstats
path: root/content/browser/frame_host/interstitial_page_impl_browsertest.cc
diff options
context:
space:
mode:
authorlgarron <lgarron@chromium.org>2015-07-10 00:39:56 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-10 07:41:48 +0000
commit145aaa8a7762909442a684415333ebce4f65a229 (patch)
treeced809b5822f9a1d00d2cd42c5a2c84ce1dc2456 /content/browser/frame_host/interstitial_page_impl_browsertest.cc
parentcd131d403bc15f9a7aca116b14d08268a3c6aded (diff)
downloadchromium_src-145aaa8a7762909442a684415333ebce4f65a229.zip
chromium_src-145aaa8a7762909442a684415333ebce4f65a229.tar.gz
chromium_src-145aaa8a7762909442a684415333ebce4f65a229.tar.bz2
Route 'Select All' OS method through RenderWidgetHostDelegate.
This allows Cmd-A / "Select All" to be used on SSL interstitials on OSX. BUG=507416 Review URL: https://codereview.chromium.org/1212373009 Cr-Commit-Position: refs/heads/master@{#338248}
Diffstat (limited to 'content/browser/frame_host/interstitial_page_impl_browsertest.cc')
-rw-r--r--content/browser/frame_host/interstitial_page_impl_browsertest.cc54
1 files changed, 43 insertions, 11 deletions
diff --git a/content/browser/frame_host/interstitial_page_impl_browsertest.cc b/content/browser/frame_host/interstitial_page_impl_browsertest.cc
index 70a07e6..405b3b1 100644
--- a/content/browser/frame_host/interstitial_page_impl_browsertest.cc
+++ b/content/browser/frame_host/interstitial_page_impl_browsertest.cc
@@ -30,21 +30,28 @@ class TestInterstitialPageDelegate : public InterstitialPageDelegate {
return "<html>"
"<head>"
"<script>"
+ "function create_input_and_set_text(text) {"
+ " var input = document.createElement('input');"
+ " input.id = 'input';"
+ " document.body.appendChild(input);"
+ " document.getElementById('input').value = text;"
+ " input.addEventListener('input',"
+ " function() { document.title='TEXT_CHANGED'; });"
+ "}"
"function focus_select_input() {"
" document.getElementById('input').select();"
"}"
- "function set_input_text(text) {"
- " document.getElementById('input').value = text;"
- "}"
"function get_input_text() {"
" window.domAutomationController.send("
" document.getElementById('input').value);"
"}"
+ "function get_selection() {"
+ " window.domAutomationController.send("
+ " window.getSelection().toString());"
+ "}"
"</script>"
"</head>"
- "<body>"
- " <input id='input' oninput='document.title=\"TEXT_CHANGED\"'>"
- "</body>"
+ "<body>original body text</body>"
"</html>";
}
};
@@ -259,9 +266,14 @@ class InterstitialPageImplTest : public ContentBrowserTest {
"get_input_text()", input_text);
}
- bool SetInputText(const std::string& text) {
+ bool GetSelection(std::string* input_text) {
+ return ExecuteScriptAndExtractString(interstitial_->GetMainFrame(),
+ "get_selection()", input_text);
+ }
+
+ bool CreateInputAndSetText(const std::string& text) {
return ExecuteScript(interstitial_->GetMainFrame(),
- "set_input_text('" + text + "')");
+ "create_input_and_set_text('" + text + "')");
}
std::string PerformCut() {
@@ -292,6 +304,12 @@ class InterstitialPageImplTest : public ContentBrowserTest {
title_update_watcher_->Wait();
}
+ void PerformSelectAll() {
+ RenderFrameHostImpl* rfh =
+ static_cast<RenderFrameHostImpl*>(interstitial_->GetMainFrame());
+ rfh->GetRenderWidgetHost()->delegate()->SelectAll();
+ }
+
private:
void RunTaskOnIOThreadAndWait(const base::Closure& task) {
base::WaitableEvent completion(false, false);
@@ -316,7 +334,7 @@ class InterstitialPageImplTest : public ContentBrowserTest {
IN_PROC_BROWSER_TEST_F(InterstitialPageImplTest, Cut) {
SetUpInterstitialPage();
- ASSERT_TRUE(SetInputText("text-to-cut"));
+ ASSERT_TRUE(CreateInputAndSetText("text-to-cut"));
ASSERT_TRUE(FocusInputAndSelectText());
std::string clipboard_text = PerformCut();
@@ -332,7 +350,7 @@ IN_PROC_BROWSER_TEST_F(InterstitialPageImplTest, Cut) {
IN_PROC_BROWSER_TEST_F(InterstitialPageImplTest, Copy) {
SetUpInterstitialPage();
- ASSERT_TRUE(SetInputText("text-to-copy"));
+ ASSERT_TRUE(CreateInputAndSetText("text-to-copy"));
ASSERT_TRUE(FocusInputAndSelectText());
std::string clipboard_text = PerformCopy();
@@ -351,7 +369,7 @@ IN_PROC_BROWSER_TEST_F(InterstitialPageImplTest, Paste) {
SetClipboardText("text-to-paste");
- ASSERT_TRUE(SetInputText(std::string()));
+ ASSERT_TRUE(CreateInputAndSetText(std::string()));
ASSERT_TRUE(FocusInputAndSelectText());
PerformPaste();
@@ -364,4 +382,18 @@ IN_PROC_BROWSER_TEST_F(InterstitialPageImplTest, Paste) {
TearDownTestClipboard();
}
+IN_PROC_BROWSER_TEST_F(InterstitialPageImplTest, SelectAll) {
+ SetUpInterstitialPage();
+
+ std::string input_text;
+ ASSERT_TRUE(GetSelection(&input_text));
+ EXPECT_EQ(std::string(), input_text);
+
+ PerformSelectAll();
+ ASSERT_TRUE(GetSelection(&input_text));
+ EXPECT_EQ("original body text", input_text);
+
+ TearDownInterstitialPage();
+}
+
} // namespace content