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

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

Issue 11377089: browser-plugin: Send a JSON string for the detail data with the events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // Send an event and verify that the event is deported. 267 // Send an event and verify that the event is deported.
268 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(), 268 browser_plugin->handleInputEvent(WebKit::WebMouseEvent(),
269 cursor_info); 269 cursor_info);
270 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( 270 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
271 BrowserPluginHostMsg_HandleInputEvent::ID)); 271 BrowserPluginHostMsg_HandleInputEvent::ID));
272 browser_plugin_manager()->sink().ClearMessages(); 272 browser_plugin_manager()->sink().ClearMessages();
273 273
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.detail.reason;" 277 " msg = JSON.parse(e.detail).reason;"
278 "}" 278 "}"
279 "document.getElementById('browserplugin')." 279 "document.getElementById('browserplugin')."
280 " addEventListener('-internal-exit', exitListener);"; 280 " addEventListener('-internal-exit', exitListener);";
281 281
282 ExecuteJavaScript(kAddEventListener); 282 ExecuteJavaScript(kAddEventListener);
283 283
284 // Pretend that the guest has terminated normally. 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.
(...skipping 19 matching lines...) Expand all
307 ExecuteJavaScript("x = document.getElementById('browserplugin'); " 307 ExecuteJavaScript("x = document.getElementById('browserplugin'); "
308 "x.parentNode.removeChild(x);"); 308 "x.parentNode.removeChild(x);");
309 ProcessPendingMessages(); 309 ProcessPendingMessages();
310 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( 310 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
311 BrowserPluginHostMsg_PluginDestroyed::ID)); 311 BrowserPluginHostMsg_PluginDestroyed::ID));
312 } 312 }
313 313
314 TEST_F(BrowserPluginTest, CustomEvents) { 314 TEST_F(BrowserPluginTest, CustomEvents) {
315 const char* kAddEventListener = 315 const char* kAddEventListener =
316 "var url;" 316 "var url;"
317 "function nav(u) {" 317 "function nav(e) {"
318 " url = u.detail.url;" 318 " url = JSON.parse(e.detail).url;"
319 "}" 319 "}"
320 "document.getElementById('browserplugin')." 320 "document.getElementById('browserplugin')."
321 " addEventListener('-internal-loadcommit', nav);"; 321 " addEventListener('-internal-loadcommit', nav);";
322 const char* kRemoveEventListener = 322 const char* kRemoveEventListener =
323 "document.getElementById('browserplugin')." 323 "document.getElementById('browserplugin')."
324 " removeEventListener('-internal-loadcommit', nav);"; 324 " removeEventListener('-internal-loadcommit', nav);";
325 const char* kGetProcessID = 325 const char* kGetProcessID =
326 "document.getElementById('browserplugin').getProcessId()"; 326 "document.getElementById('browserplugin').getProcessId()";
327 const char* kGoogleURL = "http://www.google.com/"; 327 const char* kGoogleURL = "http://www.google.com/";
328 const char* kGoogleNewsURL = "http://news.google.com/"; 328 const char* kGoogleNewsURL = "http://news.google.com/";
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 partition_value = ExecuteScriptAndReturnString( 494 partition_value = ExecuteScriptAndReturnString(
495 "document.getElementById('browserplugin').partition"); 495 "document.getElementById('browserplugin').partition");
496 EXPECT_STREQ("storage", partition_value.c_str()); 496 EXPECT_STREQ("storage", partition_value.c_str());
497 } 497 }
498 498
499 // This test verifies that we can mutate the event listener vector 499 // This test verifies that we can mutate the event listener vector
500 // within an event listener. 500 // within an event listener.
501 TEST_F(BrowserPluginTest, RemoveEventListenerInEventListener) { 501 TEST_F(BrowserPluginTest, RemoveEventListenerInEventListener) {
502 const char* kAddEventListener = 502 const char* kAddEventListener =
503 "var url;" 503 "var url;"
504 "function nav(u) {" 504 "function nav(e) {"
505 " url = u.detail.url;" 505 " url = JSON.parse(e.detail).url;"
506 " document.getElementById('browserplugin')." 506 " document.getElementById('browserplugin')."
507 " removeEventListener('-internal-loadcommit', nav);" 507 " removeEventListener('-internal-loadcommit', nav);"
508 "}" 508 "}"
509 "document.getElementById('browserplugin')." 509 "document.getElementById('browserplugin')."
510 " addEventListener('-internal-loadcommit', nav);"; 510 " addEventListener('-internal-loadcommit', nav);";
511 const char* kGoogleURL = "http://www.google.com/"; 511 const char* kGoogleURL = "http://www.google.com/";
512 const char* kGoogleNewsURL = "http://news.google.com/"; 512 const char* kGoogleNewsURL = "http://news.google.com/";
513 const char* kGetProcessID = 513 const char* kGetProcessID =
514 "document.getElementById('browserplugin').getProcessId()"; 514 "document.getElementById('browserplugin').getProcessId()";
515 515
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 ASSERT_TRUE(IPC::ReadParam(msg, &iter, &resize_params)); 609 ASSERT_TRUE(IPC::ReadParam(msg, &iter, &resize_params));
610 int instance_id = resize_params.a; 610 int instance_id = resize_params.a;
611 611
612 MockBrowserPlugin* browser_plugin = 612 MockBrowserPlugin* browser_plugin =
613 static_cast<MockBrowserPlugin*>( 613 static_cast<MockBrowserPlugin*>(
614 browser_plugin_manager()->GetBrowserPlugin(instance_id)); 614 browser_plugin_manager()->GetBrowserPlugin(instance_id));
615 ASSERT_TRUE(browser_plugin); 615 ASSERT_TRUE(browser_plugin);
616 616
617 const char* kAddEventListener = 617 const char* kAddEventListener =
618 "function exitListener(e) {" 618 "function exitListener(e) {"
619 " if (e.detail.reason == 'killed') {" 619 " if (JSON.parse(e.detail).reason == 'killed') {"
620 " var bp = document.getElementById('browserplugin');" 620 " var bp = document.getElementById('browserplugin');"
621 " bp.parentNode.removeChild(bp);" 621 " bp.parentNode.removeChild(bp);"
622 " }" 622 " }"
623 "}" 623 "}"
624 "document.getElementById('browserplugin')." 624 "document.getElementById('browserplugin')."
625 " addEventListener('-internal-exit', exitListener);"; 625 " addEventListener('-internal-exit', exitListener);";
626 626
627 ExecuteJavaScript(kAddEventListener); 627 ExecuteJavaScript(kAddEventListener);
628 628
629 // Pretend that the guest has crashed. 629 // Pretend that the guest has crashed.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 &params); 690 &params);
691 EXPECT_FALSE(params.enable); 691 EXPECT_FALSE(params.enable);
692 EXPECT_EQ(42, params.min_width); 692 EXPECT_EQ(42, params.min_width);
693 EXPECT_EQ(43, params.min_height); 693 EXPECT_EQ(43, params.min_height);
694 EXPECT_EQ(1337, params.max_width); 694 EXPECT_EQ(1337, params.max_width);
695 EXPECT_EQ(1338, params.max_height); 695 EXPECT_EQ(1338, params.max_height);
696 } 696 }
697 } 697 }
698 698
699 } // namespace content 699 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.cc ('k') | content/test/data/browser_plugin_embedder.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698