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 "content/renderer/browser_plugin/browser_plugin_browsertest.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_browsertest.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "content/common/browser_plugin_messages.h" | 10 #include "content/common/browser_plugin_messages.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Verify that we're reporting the correct URL to navigate to based on the | 133 // Verify that we're reporting the correct URL to navigate to based on the |
134 // src attribute. | 134 // src attribute. |
135 { | 135 { |
136 const IPC::Message* msg = | 136 const IPC::Message* msg = |
137 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 137 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
138 BrowserPluginHostMsg_NavigateGuest::ID); | 138 BrowserPluginHostMsg_NavigateGuest::ID); |
139 ASSERT_TRUE(msg); | 139 ASSERT_TRUE(msg); |
140 | 140 |
141 int instance_id; | 141 int instance_id; |
142 std::string src; | 142 std::string src; |
143 gfx::Size size; | 143 BrowserPluginHostMsg_ResizeGuest_Params resize_params; |
144 BrowserPluginHostMsg_NavigateGuest::Read( | 144 BrowserPluginHostMsg_NavigateGuest::Read( |
145 msg, | 145 msg, |
146 &instance_id, | 146 &instance_id, |
147 &src, | 147 &src, |
148 &size); | 148 &resize_params); |
149 EXPECT_EQ("foo", src); | 149 EXPECT_EQ("foo", src); |
150 } | 150 } |
151 | 151 |
152 browser_plugin_manager()->sink().ClearMessages(); | 152 browser_plugin_manager()->sink().ClearMessages(); |
153 // Navigate to bar and observe the associated | 153 // Navigate to bar and observe the associated |
154 // BrowserPluginHostMsg_NavigateGuest message. | 154 // BrowserPluginHostMsg_NavigateGuest message. |
155 // Verify that the src attribute is updated as well. | 155 // Verify that the src attribute is updated as well. |
156 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 156 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
157 { | 157 { |
158 const IPC::Message* msg = | 158 const IPC::Message* msg = |
159 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 159 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
160 BrowserPluginHostMsg_NavigateGuest::ID); | 160 BrowserPluginHostMsg_NavigateGuest::ID); |
161 ASSERT_TRUE(msg); | 161 ASSERT_TRUE(msg); |
162 | 162 |
163 int instance_id; | 163 int instance_id; |
164 std::string src; | 164 std::string src; |
165 gfx::Size size; | 165 BrowserPluginHostMsg_ResizeGuest_Params resize_params; |
166 BrowserPluginHostMsg_NavigateGuest::Read( | 166 BrowserPluginHostMsg_NavigateGuest::Read( |
167 msg, | 167 msg, |
168 &instance_id, | 168 &instance_id, |
169 &src, | 169 &src, |
170 &size); | 170 &resize_params); |
171 EXPECT_EQ("bar", src); | 171 EXPECT_EQ("bar", src); |
172 std::string src_value = | 172 std::string src_value = |
173 ExecuteScriptAndReturnString( | 173 ExecuteScriptAndReturnString( |
174 "document.getElementById('browserplugin').src"); | 174 "document.getElementById('browserplugin').src"); |
175 EXPECT_EQ("bar", src_value); | 175 EXPECT_EQ("bar", src_value); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 TEST_F(BrowserPluginTest, ResizeFlowControl) { | 179 TEST_F(BrowserPluginTest, ResizeFlowControl) { |
180 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 180 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 426 |
427 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 427 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
428 { | 428 { |
429 const IPC::Message* msg = | 429 const IPC::Message* msg = |
430 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 430 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
431 BrowserPluginHostMsg_NavigateGuest::ID); | 431 BrowserPluginHostMsg_NavigateGuest::ID); |
432 ASSERT_TRUE(msg); | 432 ASSERT_TRUE(msg); |
433 | 433 |
434 int instance_id; | 434 int instance_id; |
435 std::string src; | 435 std::string src; |
436 gfx::Size size; | 436 BrowserPluginHostMsg_ResizeGuest_Params resize_params; |
437 BrowserPluginHostMsg_NavigateGuest::Read( | 437 BrowserPluginHostMsg_NavigateGuest::Read( |
438 msg, | 438 msg, |
439 &instance_id, | 439 &instance_id, |
440 &src, | 440 &src, |
441 &size); | 441 &resize_params); |
442 EXPECT_STREQ("bar", src.c_str()); | 442 EXPECT_STREQ("bar", src.c_str()); |
443 } | 443 } |
444 | 444 |
445 // Setting the partition should throw an exception and the value should not | 445 // Setting the partition should throw an exception and the value should not |
446 // change. | 446 // change. |
447 ExecuteJavaScript( | 447 ExecuteJavaScript( |
448 "try {" | 448 "try {" |
449 " document.getElementById('browserplugin').partition = 'someid';" | 449 " document.getElementById('browserplugin').partition = 'someid';" |
450 " document.title = 'success';" | 450 " document.title = 'success';" |
451 "} catch (e) { document.title = e.message; }"); | 451 "} catch (e) { document.title = e.message; }"); |
452 | 452 |
453 std::string title = ExecuteScriptAndReturnString("document.title"); | 453 std::string title = ExecuteScriptAndReturnString("document.title"); |
454 EXPECT_STREQ( | 454 EXPECT_STREQ( |
455 "The object has already navigated, so its partition cannot be changed.", | 455 "The object has already navigated, so its partition cannot be changed.", |
456 title.c_str()); | 456 title.c_str()); |
457 | 457 |
458 partition_value = ExecuteScriptAndReturnString( | 458 partition_value = ExecuteScriptAndReturnString( |
459 "document.getElementById('browserplugin').partition"); | 459 "document.getElementById('browserplugin').partition"); |
460 EXPECT_STREQ("storage", partition_value.c_str()); | 460 EXPECT_STREQ("storage", partition_value.c_str()); |
461 } | 461 } |
462 | 462 |
463 } // namespace content | 463 } // namespace content |
OLD | NEW |