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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 ASSERT_TRUE(browser_plugin); | 233 ASSERT_TRUE(browser_plugin); |
234 | 234 |
235 WebKit::WebCursorInfo cursor_info; | 235 WebKit::WebCursorInfo cursor_info; |
236 // Send an event and verify that the event is deported. | 236 // Send an event and verify that the event is deported. |
237 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), | 237 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), |
238 cursor_info); | 238 cursor_info); |
239 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 239 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
240 BrowserPluginHostMsg_HandleInputEvent::ID)); | 240 BrowserPluginHostMsg_HandleInputEvent::ID)); |
241 browser_plugin_manager()->sink().ClearMessages(); | 241 browser_plugin_manager()->sink().ClearMessages(); |
242 | 242 |
| 243 const char* kAddEventListener = |
| 244 "var msg;" |
| 245 "function crashListener() {" |
| 246 " msg = 'crashed';" |
| 247 "}" |
| 248 "document.getElementById('browserplugin')." |
| 249 " addEventListener('crash', crashListener);"; |
| 250 |
| 251 ExecuteJavaScript(kAddEventListener); |
| 252 |
243 // Pretend that the guest has crashed | 253 // Pretend that the guest has crashed |
244 browser_plugin->GuestCrashed(); | 254 browser_plugin->GuestCrashed(); |
| 255 |
| 256 // Verify that our event listener has fired. |
| 257 EXPECT_EQ("crashed", ExecuteScriptAndReturnString("msg")); |
| 258 |
245 // Send an event and verify that events are no longer deported. | 259 // Send an event and verify that events are no longer deported. |
246 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), | 260 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), |
247 cursor_info); | 261 cursor_info); |
248 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 262 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
249 BrowserPluginHostMsg_HandleInputEvent::ID)); | 263 BrowserPluginHostMsg_HandleInputEvent::ID)); |
250 | 264 |
251 // Navigate and verify that the guest_crashed_ flag has been reset. | 265 // Navigate and verify that the guest_crashed_ flag has been reset. |
252 browser_plugin->SetSrcAttribute("bar"); | 266 browser_plugin->SetSrcAttribute("bar"); |
253 EXPECT_FALSE(browser_plugin->guest_crashed_); | 267 EXPECT_FALSE(browser_plugin->guest_crashed_); |
254 } | 268 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 313 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
300 | 314 |
301 ExecuteJavaScript(kRemoveEventListener); | 315 ExecuteJavaScript(kRemoveEventListener); |
302 browser_plugin->DidNavigate(GURL(kGoogleNewsURL)); | 316 browser_plugin->DidNavigate(GURL(kGoogleNewsURL)); |
303 // 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 |
304 // listener. | 318 // listener. |
305 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 319 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
306 } | 320 } |
307 | 321 |
308 } // namespace content | 322 } // namespace content |
OLD | NEW |