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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 132 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
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 long long frame_id; | |
143 std::string src; | 142 std::string src; |
144 gfx::Size size; | 143 gfx::Size size; |
145 BrowserPluginHostMsg_NavigateGuest::Read( | 144 BrowserPluginHostMsg_NavigateGuest::Read( |
146 msg, | 145 msg, |
147 &instance_id, | 146 &instance_id, |
148 &frame_id, | |
149 &src, | 147 &src, |
150 &size); | 148 &size); |
151 EXPECT_EQ("foo", src); | 149 EXPECT_EQ("foo", src); |
152 } | 150 } |
153 | 151 |
154 browser_plugin_manager()->sink().ClearMessages(); | 152 browser_plugin_manager()->sink().ClearMessages(); |
155 // Navigate to bar and observe the associated | 153 // Navigate to bar and observe the associated |
156 // BrowserPluginHostMsg_NavigateGuest message. | 154 // BrowserPluginHostMsg_NavigateGuest message. |
157 // Verify that the src attribute is updated as well. | 155 // Verify that the src attribute is updated as well. |
158 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 156 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
159 { | 157 { |
160 const IPC::Message* msg = | 158 const IPC::Message* msg = |
161 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 159 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
162 BrowserPluginHostMsg_NavigateGuest::ID); | 160 BrowserPluginHostMsg_NavigateGuest::ID); |
163 ASSERT_TRUE(msg); | 161 ASSERT_TRUE(msg); |
164 | 162 |
165 int instance_id; | 163 int instance_id; |
166 long long frame_id; | |
167 std::string src; | 164 std::string src; |
168 gfx::Size size; | 165 gfx::Size size; |
169 BrowserPluginHostMsg_NavigateGuest::Read( | 166 BrowserPluginHostMsg_NavigateGuest::Read( |
170 msg, | 167 msg, |
171 &instance_id, | 168 &instance_id, |
172 &frame_id, | |
173 &src, | 169 &src, |
174 &size); | 170 &size); |
175 EXPECT_EQ("bar", src); | 171 EXPECT_EQ("bar", src); |
176 std::string src_value = | 172 std::string src_value = |
177 ExecuteScriptAndReturnString( | 173 ExecuteScriptAndReturnString( |
178 "document.getElementById('browserplugin').src"); | 174 "document.getElementById('browserplugin').src"); |
179 EXPECT_EQ("bar", src_value); | 175 EXPECT_EQ("bar", src_value); |
180 } | 176 } |
181 } | 177 } |
182 | 178 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 EXPECT_STREQ("", src_value.c_str()); | 425 EXPECT_STREQ("", src_value.c_str()); |
430 | 426 |
431 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 427 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
432 { | 428 { |
433 const IPC::Message* msg = | 429 const IPC::Message* msg = |
434 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 430 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
435 BrowserPluginHostMsg_NavigateGuest::ID); | 431 BrowserPluginHostMsg_NavigateGuest::ID); |
436 ASSERT_TRUE(msg); | 432 ASSERT_TRUE(msg); |
437 | 433 |
438 int instance_id; | 434 int instance_id; |
439 long long frame_id; | |
440 std::string src; | 435 std::string src; |
441 gfx::Size size; | 436 gfx::Size size; |
442 BrowserPluginHostMsg_NavigateGuest::Read( | 437 BrowserPluginHostMsg_NavigateGuest::Read( |
443 msg, | 438 msg, |
444 &instance_id, | 439 &instance_id, |
445 &frame_id, | |
446 &src, | 440 &src, |
447 &size); | 441 &size); |
448 EXPECT_STREQ("bar", src.c_str()); | 442 EXPECT_STREQ("bar", src.c_str()); |
449 } | 443 } |
450 | 444 |
451 // 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 |
452 // change. | 446 // change. |
453 ExecuteJavaScript( | 447 ExecuteJavaScript( |
454 "try {" | 448 "try {" |
455 " document.getElementById('browserplugin').partition = 'someid';" | 449 " document.getElementById('browserplugin').partition = 'someid';" |
456 " document.title = 'success';" | 450 " document.title = 'success';" |
457 "} catch (e) { document.title = e.message; }"); | 451 "} catch (e) { document.title = e.message; }"); |
458 | 452 |
459 std::string title = ExecuteScriptAndReturnString("document.title"); | 453 std::string title = ExecuteScriptAndReturnString("document.title"); |
460 EXPECT_STREQ( | 454 EXPECT_STREQ( |
461 "The object has already navigated, so its partition cannot be changed.", | 455 "The object has already navigated, so its partition cannot be changed.", |
462 title.c_str()); | 456 title.c_str()); |
463 | 457 |
464 partition_value = ExecuteScriptAndReturnString( | 458 partition_value = ExecuteScriptAndReturnString( |
465 "document.getElementById('browserplugin').partition"); | 459 "document.getElementById('browserplugin').partition"); |
466 EXPECT_STREQ("storage", partition_value.c_str()); | 460 EXPECT_STREQ("storage", partition_value.c_str()); |
467 } | 461 } |
468 | 462 |
469 } // namespace content | 463 } // namespace content |
OLD | NEW |