| 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 12 matching lines...) Expand all Loading... |
| 23 namespace { | 23 namespace { |
| 24 const char kHTMLForBrowserPluginObject[] = | 24 const char kHTMLForBrowserPluginObject[] = |
| 25 "<object id='browserplugin' width='640px' height='480px'" | 25 "<object id='browserplugin' width='640px' height='480px'" |
| 26 " src='foo' type='%s'>"; | 26 " src='foo' type='%s'>"; |
| 27 | 27 |
| 28 std::string GetHTMLForBrowserPluginObject() { | 28 std::string GetHTMLForBrowserPluginObject() { |
| 29 return StringPrintf(kHTMLForBrowserPluginObject, | 29 return StringPrintf(kHTMLForBrowserPluginObject, |
| 30 content::kBrowserPluginNewMimeType); | 30 content::kBrowserPluginNewMimeType); |
| 31 } | 31 } |
| 32 | 32 |
| 33 } // namespace | 33 } |
| 34 | 34 |
| 35 namespace content { | 35 namespace content { |
| 36 | 36 |
| 37 BrowserPluginTest::BrowserPluginTest() {} | 37 BrowserPluginTest::BrowserPluginTest() {} |
| 38 | 38 |
| 39 BrowserPluginTest::~BrowserPluginTest() {} | 39 BrowserPluginTest::~BrowserPluginTest() {} |
| 40 | 40 |
| 41 void BrowserPluginTest::SetUp() { | 41 void BrowserPluginTest::SetUp() { |
| 42 GetContentClient()->set_renderer_for_testing(&content_renderer_client_); | 42 GetContentClient()->set_renderer_for_testing(&content_renderer_client_); |
| 43 content::RenderViewTest::SetUp(); | 43 content::RenderViewTest::SetUp(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Verify that the src attribute on the browser plugin works as expected. | 109 // Verify that the src attribute on the browser plugin works as expected. |
| 110 TEST_F(BrowserPluginTest, SrcAttribute) { | 110 TEST_F(BrowserPluginTest, SrcAttribute) { |
| 111 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 111 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 112 // Verify that we're reporting the correct URL to navigate to based on the | 112 // Verify that we're reporting the correct URL to navigate to based on the |
| 113 // src attribute. | 113 // src attribute. |
| 114 { | 114 { |
| 115 const IPC::Message* msg = | 115 const IPC::Message* msg = |
| 116 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 116 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 117 BrowserPluginHostMsg_NavigateGuest::ID); | 117 BrowserPluginHostMsg_NavigateOrCreateGuest::ID); |
| 118 ASSERT_TRUE(msg); | 118 ASSERT_TRUE(msg); |
| 119 | 119 |
| 120 int instance_id; | 120 int instance_id; |
| 121 long long frame_id; | 121 long long frame_id; |
| 122 std::string src; | 122 std::string src; |
| 123 gfx::Size size; | 123 BrowserPluginHostMsg_NavigateOrCreateGuest::Read( |
| 124 BrowserPluginHostMsg_NavigateGuest::Read( | |
| 125 msg, | 124 msg, |
| 126 &instance_id, | 125 &instance_id, |
| 127 &frame_id, | 126 &frame_id, |
| 128 &src, | 127 &src); |
| 129 &size); | |
| 130 EXPECT_EQ("foo", src); | 128 EXPECT_EQ("foo", src); |
| 131 } | 129 } |
| 132 | 130 |
| 133 browser_plugin_manager()->sink().ClearMessages(); | 131 browser_plugin_manager()->sink().ClearMessages(); |
| 134 // Navigate to bar and observe the associated | 132 // Navigate to bar and observe the associated |
| 135 // BrowserPluginHostMsg_NavigateGuest message. | 133 // BrowserPluginHostMsg_NavigateOrCreateGuest message. |
| 136 // Verify that the src attribute is updated as well. | 134 // Verify that the src attribute is updated as well. |
| 137 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); | 135 ExecuteJavaScript("document.getElementById('browserplugin').src = 'bar'"); |
| 138 { | 136 { |
| 139 const IPC::Message* msg = | 137 const IPC::Message* msg = |
| 140 browser_plugin_manager()->sink().GetUniqueMessageMatching( | 138 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 141 BrowserPluginHostMsg_NavigateGuest::ID); | 139 BrowserPluginHostMsg_NavigateOrCreateGuest::ID); |
| 142 ASSERT_TRUE(msg); | 140 ASSERT_TRUE(msg); |
| 143 | 141 |
| 144 int instance_id; | 142 int instance_id; |
| 145 long long frame_id; | 143 long long frame_id; |
| 146 std::string src; | 144 std::string src; |
| 147 gfx::Size size; | 145 BrowserPluginHostMsg_NavigateOrCreateGuest::Read( |
| 148 BrowserPluginHostMsg_NavigateGuest::Read( | |
| 149 msg, | 146 msg, |
| 150 &instance_id, | 147 &instance_id, |
| 151 &frame_id, | 148 &frame_id, |
| 152 &src, | 149 &src); |
| 153 &size); | |
| 154 EXPECT_EQ("bar", src); | 150 EXPECT_EQ("bar", src); |
| 155 std::string src_value = | 151 std::string src_value = |
| 156 ExecuteScriptAndReturnString( | 152 ExecuteScriptAndReturnString( |
| 157 "document.getElementById('browserplugin').src"); | 153 "document.getElementById('browserplugin').src"); |
| 158 EXPECT_EQ("bar", src_value); | 154 EXPECT_EQ("bar", src_value); |
| 159 } | 155 } |
| 160 } | 156 } |
| 161 | 157 |
| 162 TEST_F(BrowserPluginTest, ResizeFlowControl) { | 158 TEST_F(BrowserPluginTest, ResizeFlowControl) { |
| 163 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 159 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 313 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
| 318 | 314 |
| 319 ExecuteJavaScript(kRemoveEventListener); | 315 ExecuteJavaScript(kRemoveEventListener); |
| 320 browser_plugin->DidNavigate(GURL(kGoogleNewsURL)); | 316 browser_plugin->DidNavigate(GURL(kGoogleNewsURL)); |
| 321 // The URL variable should not change because we've removed the event | 317 // The URL variable should not change because we've removed the event |
| 322 // listener. | 318 // listener. |
| 323 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 319 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
| 324 } | 320 } |
| 325 | 321 |
| 326 } // namespace content | 322 } // namespace content |
| OLD | NEW |