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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 const char* kAddEventListener = | 274 const char* kAddEventListener = |
275 "var msg;" | 275 "var msg;" |
276 "function exitListener(e) {" | 276 "function exitListener(e) {" |
277 " msg = e.type;" | 277 " msg = e.type;" |
278 "}" | 278 "}" |
279 "document.getElementById('browserplugin')." | 279 "document.getElementById('browserplugin')." |
280 " addEventListener('exit', exitListener);"; | 280 " addEventListener('exit', exitListener);"; |
281 | 281 |
282 ExecuteJavaScript(kAddEventListener); | 282 ExecuteJavaScript(kAddEventListener); |
283 | 283 |
284 // Pretend that the guest has crashed | 284 // Pretend that the guest has terminated normally. |
285 browser_plugin->GuestGone(0, base::TERMINATION_STATUS_NORMAL_TERMINATION); | 285 browser_plugin->GuestGone(0, base::TERMINATION_STATUS_NORMAL_TERMINATION); |
286 | 286 |
287 // Verify that our event listener has fired. | 287 // Verify that our event listener has fired. |
288 EXPECT_EQ("normal", ExecuteScriptAndReturnString("msg")); | 288 EXPECT_EQ("normal", ExecuteScriptAndReturnString("msg")); |
289 | 289 |
| 290 // Pretend that the guest has crashed. |
| 291 browser_plugin->GuestGone(0, base::TERMINATION_STATUS_PROCESS_CRASHED); |
| 292 |
| 293 // Verify that our event listener has fired. |
| 294 EXPECT_EQ("crashed", ExecuteScriptAndReturnString("msg")); |
| 295 |
290 // Send an event and verify that events are no longer deported. | 296 // Send an event and verify that events are no longer deported. |
291 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), | 297 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), |
292 cursor_info); | 298 cursor_info); |
293 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 299 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
294 BrowserPluginHostMsg_HandleInputEvent::ID)); | 300 BrowserPluginHostMsg_HandleInputEvent::ID)); |
295 } | 301 } |
296 | 302 |
297 TEST_F(BrowserPluginTest, RemovePlugin) { | 303 TEST_F(BrowserPluginTest, RemovePlugin) { |
298 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); | 304 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
299 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( | 305 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 530 |
525 // Pretend that the guest has crashed. | 531 // Pretend that the guest has crashed. |
526 browser_plugin->GuestGone(0, base::TERMINATION_STATUS_PROCESS_WAS_KILLED); | 532 browser_plugin->GuestGone(0, base::TERMINATION_STATUS_PROCESS_WAS_KILLED); |
527 | 533 |
528 ProcessPendingMessages(); | 534 ProcessPendingMessages(); |
529 | 535 |
530 EXPECT_EQ(NULL, browser_plugin_manager()->GetBrowserPlugin(instance_id)); | 536 EXPECT_EQ(NULL, browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
531 } | 537 } |
532 | 538 |
533 } // namespace content | 539 } // namespace content |
OLD | NEW |