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/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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestWithSize, true, | 1235 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestWithSize, true, |
1236 embedder_code); | 1236 embedder_code); |
1237 // Check for render view host at position (150, 150) that is outside the | 1237 // Check for render view host at position (150, 150) that is outside the |
1238 // bounds of our guest, so this would respond with the render view host of the | 1238 // bounds of our guest, so this would respond with the render view host of the |
1239 // embedder. | 1239 // embedder. |
1240 test_embedder()->WaitForRenderViewHostAtPosition(150, 150); | 1240 test_embedder()->WaitForRenderViewHostAtPosition(150, 150); |
1241 ASSERT_EQ(test_embedder()->web_contents()->GetRenderViewHost(), | 1241 ASSERT_EQ(test_embedder()->web_contents()->GetRenderViewHost(), |
1242 test_embedder()->last_rvh_at_position_response()); | 1242 test_embedder()->last_rvh_at_position_response()); |
1243 } | 1243 } |
1244 | 1244 |
| 1245 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ChangeWindowName) { |
| 1246 const char kEmbedderURL[] = "files/browser_plugin_naming_embedder.html"; |
| 1247 const char* kGuestURL = "files/browser_plugin_naming_guest.html"; |
| 1248 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, ""); |
| 1249 |
| 1250 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 1251 test_embedder()->web_contents()->GetRenderViewHost()); |
| 1252 { |
| 1253 // Open a channel with the guest, wait until it replies, |
| 1254 // then verify that the plugin's name has been updated. |
| 1255 const string16 expected_title = ASCIIToUTF16("guest"); |
| 1256 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 1257 expected_title); |
| 1258 ExecuteSyncJSFunction(rvh, "OpenCommChannel();"); |
| 1259 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 1260 EXPECT_EQ(expected_title, actual_title); |
| 1261 |
| 1262 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue(string16(), |
| 1263 ASCIIToUTF16("document.getElementById('plugin').name"))); |
| 1264 std::string result; |
| 1265 EXPECT_TRUE(value->GetAsString(&result)); |
| 1266 EXPECT_EQ("guest", result); |
| 1267 } |
| 1268 { |
| 1269 // Set the plugin's name and verify that the window.name of the guest |
| 1270 // has been updated. |
| 1271 const string16 expected_title = ASCIIToUTF16("foobar"); |
| 1272 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 1273 expected_title); |
| 1274 ExecuteSyncJSFunction(rvh, |
| 1275 "document.getElementById('plugin').name = 'foobar';"); |
| 1276 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 1277 EXPECT_EQ(expected_title, actual_title); |
| 1278 |
| 1279 } |
| 1280 } |
| 1281 |
1245 } // namespace content | 1282 } // namespace content |
OLD | NEW |