OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/string_util.h" | 5 #include "base/string_util.h" |
6 #include "content/public/browser/web_contents.h" | 6 #include "content/public/browser/web_contents.h" |
7 #include "content/public/test/browser_test_utils.h" | 7 #include "content/public/test/browser_test_utils.h" |
8 #include "content/public/test/test_utils.h" | 8 #include "content/public/test/test_utils.h" |
9 #include "content/shell/shell.h" | 9 #include "content/shell/shell.h" |
10 #include "content/test/content_browser_test.h" | 10 #include "content/test/content_browser_test.h" |
11 #include "content/test/content_browser_test_utils.h" | 11 #include "content/test/content_browser_test_utils.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 class BookmarkletTest : public ContentBrowserTest { | 16 class BookmarkletTest : public ContentBrowserTest { |
17 public: | 17 public: |
18 void NavigateToStartPage() { | 18 void NavigateToStartPage() { |
19 NavigateToURL(shell(), GURL("data:text/html,start page")); | 19 NavigateToURL(shell(), GURL("data:text/html,start page")); |
20 EXPECT_EQ("start page", GetBodyText()); | 20 EXPECT_EQ("start page", GetBodyText()); |
21 } | 21 } |
22 | 22 |
23 std::string GetBodyText() { | 23 std::string GetBodyText() { |
24 std::string body_text; | 24 std::string body_text; |
25 EXPECT_TRUE(ExecuteJavaScriptAndExtractString( | 25 EXPECT_TRUE(ExecuteScriptAndExtractString( |
26 shell()->web_contents()->GetRenderViewHost(), | 26 shell()->web_contents(), |
27 "", | |
28 "window.domAutomationController.send(document.body.innerText);", | 27 "window.domAutomationController.send(document.body.innerText);", |
29 &body_text)); | 28 &body_text)); |
30 return body_text; | 29 return body_text; |
31 } | 30 } |
32 }; | 31 }; |
33 | 32 |
34 IN_PROC_BROWSER_TEST_F(BookmarkletTest, Redirect) { | 33 IN_PROC_BROWSER_TEST_F(BookmarkletTest, Redirect) { |
35 NavigateToStartPage(); | 34 NavigateToStartPage(); |
36 | 35 |
37 NavigateToURL(shell(), GURL( | 36 NavigateToURL(shell(), GURL( |
(...skipping 28 matching lines...) Expand all Loading... |
66 shell()->LoadURL(GURL( | 65 shell()->LoadURL(GURL( |
67 "javascript:document.open();" | 66 "javascript:document.open();" |
68 "document.write('hello world');" | 67 "document.write('hello world');" |
69 "document.close();")); | 68 "document.close();")); |
70 EXPECT_EQ("hello world", GetBodyText()); | 69 EXPECT_EQ("hello world", GetBodyText()); |
71 } | 70 } |
72 | 71 |
73 | 72 |
74 } // namespace content | 73 } // namespace content |
75 | 74 |
OLD | NEW |