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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_host_browsertest.cc

Issue 11027065: Browser plugin: Implement titleChanged event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for pages with no title Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/singleton.h" 6 #include "base/memory/singleton.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "content/browser/browser_plugin/browser_plugin_guest.h" 10 #include "content/browser/browser_plugin/browser_plugin_guest.h"
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 1003
1004 string16 actual_title = title_watcher.WaitAndGetTitle(); 1004 string16 actual_title = title_watcher.WaitAndGetTitle();
1005 EXPECT_EQ(expected_title, actual_title); 1005 EXPECT_EQ(expected_title, actual_title);
1006 scoped_ptr<base::Value> is_top_level(rvh->ExecuteJavascriptAndGetValue( 1006 scoped_ptr<base::Value> is_top_level(rvh->ExecuteJavascriptAndGetValue(
1007 string16(), ASCIIToUTF16("commitIsTopLevel"))); 1007 string16(), ASCIIToUTF16("commitIsTopLevel")));
1008 bool top_level_bool = false; 1008 bool top_level_bool = false;
1009 EXPECT_TRUE(is_top_level->GetAsBoolean(&top_level_bool)); 1009 EXPECT_TRUE(is_top_level->GetAsBoolean(&top_level_bool));
1010 EXPECT_EQ(true, top_level_bool); 1010 EXPECT_EQ(true, top_level_bool);
1011 } 1011 }
1012 1012
1013 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, TitleChange) {
1014 const char* kEmbedderURL = "files/browser_plugin_embedder_titlechange.html";
1015 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, "");
1016
1017 // Navigate and wait until the title changes.
1018 const string16 expected_title = ASCIIToUTF16("Title Of Awesomeness");
1019 content::TitleWatcher title_watcher(test_embedder()->web_contents(),
1020 expected_title);
1021 GURL title_url(test_server()->GetURL("files/title2.html"));
1022 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
1023 test_embedder()->web_contents()->GetRenderViewHost());
1024 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetSrc('%s');",
1025 title_url.spec().c_str())));
1026 string16 actual_title = title_watcher.WaitAndGetTitle();
1027 EXPECT_EQ(expected_title, actual_title);
1028
1029 // Navigate to a page with a different title and wait for the update.
1030 const string16 expected_title2 = ASCIIToUTF16("Title Of More Awesomeness");
1031 content::TitleWatcher title_watcher2(test_embedder()->web_contents(),
1032 expected_title2);
1033 GURL title_url2(test_server()->GetURL("files/title3.html"));
1034 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetSrc('%s');",
1035 title_url2.spec().c_str())));
1036 actual_title = title_watcher2.WaitAndGetTitle();
1037 EXPECT_EQ(expected_title2, actual_title);
1038
1039 // Go back and expect the title to revert to expected_title.
1040 content::TitleWatcher title_watcher3(test_embedder()->web_contents(),
1041 expected_title);
1042 ExecuteSyncJSFunction(rvh, ASCIIToUTF16("Back();"));
1043 actual_title = title_watcher3.WaitAndGetTitle();
1044 EXPECT_EQ(expected_title, actual_title);
1045
1046 // Navigate to a page with no title and wait for the update.
1047 // It should include the URL (host, port, path) with no http://.
1048 GURL no_title_url(test_server()->GetURL("files/title1.html"));
1049 std::string no_title_str = no_title_url.host();
1050 no_title_str.append(":");
1051 no_title_str.append(no_title_url.port());
1052 no_title_str.append(no_title_url.path());
1053 const string16 no_title = ASCIIToUTF16(no_title_str);
1054 content::TitleWatcher title_watcher4(test_embedder()->web_contents(),
1055 no_title);
1056 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetSrc('%s');",
1057 no_title_url.spec().c_str())));
1058 actual_title = title_watcher4.WaitAndGetTitle();
1059 EXPECT_EQ(no_title, actual_title);
1060 }
1061
1013 // This test verifies that if a browser plugin is hidden before navigation, 1062 // This test verifies that if a browser plugin is hidden before navigation,
1014 // the guest starts off hidden. 1063 // the guest starts off hidden.
1015 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, HiddenBeforeNavigation) { 1064 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, HiddenBeforeNavigation) {
1016 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; 1065 const char* kEmbedderURL = "files/browser_plugin_embedder.html";
1017 const std::string embedder_code = 1066 const std::string embedder_code =
1018 "document.getElementById('plugin').style.visibility = 'hidden'"; 1067 "document.getElementById('plugin').style.visibility = 'hidden'";
1019 StartBrowserPluginTest( 1068 StartBrowserPluginTest(
1020 kEmbedderURL, kHTMLForGuest, true, embedder_code); 1069 kEmbedderURL, kHTMLForGuest, true, embedder_code);
1021 EXPECT_FALSE(test_guest()->visible()); 1070 EXPECT_FALSE(test_guest()->visible());
1022 } 1071 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 scoped_ptr<base::Value> value( 1152 scoped_ptr<base::Value> value(
1104 guest_rvh->ExecuteJavascriptAndGetValue(string16(), 1153 guest_rvh->ExecuteJavascriptAndGetValue(string16(),
1105 ASCIIToUTF16("document.hasFocus()"))); 1154 ASCIIToUTF16("document.hasFocus()")));
1106 bool result = false; 1155 bool result = false;
1107 ASSERT_TRUE(value->GetAsBoolean(&result)); 1156 ASSERT_TRUE(value->GetAsBoolean(&result));
1108 EXPECT_TRUE(result); 1157 EXPECT_TRUE(result);
1109 } 1158 }
1110 } 1159 }
1111 1160
1112 } // namespace content 1161 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.cc ('k') | content/common/browser_plugin_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698