Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_browsertest.cc

Issue 10832207: Browser Plugin: Report Guest crash to Javascript (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698