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

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

Issue 10836169: Revert 150664 - Browser Plugin: Report Guest crash to Javascript (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 ASSERT_TRUE(browser_plugin); 231 ASSERT_TRUE(browser_plugin);
232 232
233 WebKit::WebCursorInfo cursor_info; 233 WebKit::WebCursorInfo cursor_info;
234 // Send an event and verify that the event is deported. 234 // Send an event and verify that the event is deported.
235 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), 235 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(),
236 cursor_info); 236 cursor_info);
237 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( 237 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
238 BrowserPluginHostMsg_HandleInputEvent::ID)); 238 BrowserPluginHostMsg_HandleInputEvent::ID));
239 browser_plugin_manager()->sink().ClearMessages(); 239 browser_plugin_manager()->sink().ClearMessages();
240 240
241 const char* kAddEventListener =
242 "var msg;"
243 "function crashListener() {"
244 " msg = 'crashed';"
245 "}"
246 "document.getElementById('browserplugin')."
247 " addEventListener('crash', crashListener);";
248
249 ExecuteJavaScript(kAddEventListener);
250
251 // Pretend that the guest has crashed 241 // Pretend that the guest has crashed
252 browser_plugin->GuestCrashed(); 242 browser_plugin->GuestCrashed();
253
254 // Verify that our event listener has fired.
255 EXPECT_EQ("crashed", ExecuteScriptAndReturnString("msg"));
256
257 // Send an event and verify that events are no longer deported. 243 // Send an event and verify that events are no longer deported.
258 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), 244 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(),
259 cursor_info); 245 cursor_info);
260 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( 246 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
261 BrowserPluginHostMsg_HandleInputEvent::ID)); 247 BrowserPluginHostMsg_HandleInputEvent::ID));
262 248
263 // Navigate and verify that the guest_crashed_ flag has been reset. 249 // Navigate and verify that the guest_crashed_ flag has been reset.
264 browser_plugin->SetSrcAttribute("bar"); 250 browser_plugin->SetSrcAttribute("bar");
265 EXPECT_FALSE(browser_plugin->guest_crashed_); 251 EXPECT_FALSE(browser_plugin->guest_crashed_);
252
266 } 253 }
267 254
268 TEST_F(BrowserPluginTest, RemovePlugin) { 255 TEST_F(BrowserPluginTest, RemovePlugin) {
269 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); 256 LoadHTML(GetHTMLForBrowserPluginObject().c_str());
270 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( 257 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
271 BrowserPluginHostMsg_PluginDestroyed::ID)); 258 BrowserPluginHostMsg_PluginDestroyed::ID));
272 ExecuteJavaScript("x = document.getElementById('browserplugin'); " 259 ExecuteJavaScript("x = document.getElementById('browserplugin'); "
273 "x.parentNode.removeChild(x);"); 260 "x.parentNode.removeChild(x);");
274 ProcessPendingMessages(); 261 ProcessPendingMessages();
275 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( 262 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); 298 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
312 299
313 ExecuteJavaScript(kRemoveEventListener); 300 ExecuteJavaScript(kRemoveEventListener);
314 browser_plugin->DidNavigate(GURL(kGoogleNewsURL)); 301 browser_plugin->DidNavigate(GURL(kGoogleNewsURL));
315 // The URL variable should not change because we've removed the event 302 // The URL variable should not change because we've removed the event
316 // listener. 303 // listener.
317 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); 304 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
318 } 305 }
319 306
320 } // namespace content 307 } // 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