Index: content/renderer/render_view_browsertest_mac.mm |
diff --git a/content/renderer/render_view_browsertest_mac.mm b/content/renderer/render_view_browsertest_mac.mm |
index b2473c6f40a1d443bd9c42ebe455600c6c24a897..616b17f15b301e43787c217a217a3ef5c3fc82ea 100644 |
--- a/content/renderer/render_view_browsertest_mac.mm |
+++ b/content/renderer/render_view_browsertest_mac.mm |
@@ -140,4 +140,45 @@ TEST_F(RenderViewTest, MacTestCmdUp) { |
EXPECT_EQ(kArrowUpNoScroll, base::UTF16ToASCII(output)); |
} |
+TEST_F(RenderViewTest, OnTtsForEmptySelection) { |
+ #define HTML(s) #s |
+ const char* kRawHtml = HTML( |
+ <!DOCTYPE html> |
+ <style> |
+ /* Add a vertical scrollbar */ |
+ body { height: 10128px; } |
+ </style> |
+ <div id='text'> |
+ <p> A "Hello World" program has become the traditional first program that |
+ many people learn. In general it is simple enough so that people who |
+ experience with computer programming can easily understand it especially |
+ the guidance of a teacher a written guide. Using this simple program |
+ basis computer science principles elements of a specific programming |
+ language can be explained to novice programmers. Experienced programmers |
+ learning languages can also gain a lot of information about a given |
+ languages syntax structure from a hello world program. </p> |
+ </div> |
+ ); |
+ #undef HTML |
+ |
+ RenderViewImpl* view = static_cast<RenderViewImpl*>(view_); |
Alexei Svitkine (slow)
2014/06/25 13:58:29
Nit: Move this closer to where it's used - i.e. ri
|
+ |
+ const int kMaxOutputCharacters = 1024; |
+ base::string16 select_all_text; |
+ base::string16 output; |
Alexei Svitkine (slow)
2014/06/25 13:58:29
Nit: Move this closer to where it's used - i.e. yo
|
+ |
+ view->set_send_content_state_immediately(true); |
+ LoadHTML(kRawHtml); |
+ render_thread_->sink().ClearMessages(); |
+ // contentAsText doesn't depend on scroll position or focussed frame location |
+ // hence the returned value would be same throughout. |
+ // Scroll down further. |
+ ExecuteJavaScript("window.scrollTo(0, 9030)"); |
+ // Execute a command to Select all text in DOM. |
+ ExecuteJavaScript("document.execCommand('SelectAll', false, null)"); |
+ output = GetMainFrame()->contentAsText(kMaxOutputCharacters); |
+ select_all_text = GetMainFrame()->selectionAsText(); |
+ EXPECT_EQ(output, select_all_text); |
+} |
+ |
} // namespace content |