content/renderer/browser_plugin/browser_plugin_browsertest.cc
// This test verifies that multiple event listeners fire that are registered
// on a single event type.
This test verifies that multiple event listeners fire that are registered
on a single event type.
This test verifies that multiple event listeners fire that are registered on a single event type .
TEST_F(BrowserPluginTest, MultipleEventListeners) {
  const char* kAddEventListener =
    "var count = 0;"
    "function nava(u) {"
    "  count++;"
    "}"
    "function navb(u) {"
    "  count++;"
    "}"
    "document.getElementById('browserplugin')."
    "    addEventListener('-internal-loadcommit', nava);"
    "document.getElementById('browserplugin')."
    "    addEventListener('-internal-loadcommit', navb);";
  const char* kGoogleURL = "http://www.google.com/";
  const char* kGetProcessID =
      "document.getElementById('browserplugin').getProcessId()";
  LoadHTML(GetHTMLForBrowserPluginObject().c_str());
  ExecuteJavaScript(kAddEventListener);
  const IPC::Message* msg =
      browser_plugin_manager()->sink().GetFirstMessageMatching(
          BrowserPluginHostMsg_ResizeGuest::ID);
  ASSERT_TRUE(msg);
  int instance_id = 0;
  BrowserPluginHostMsg_ResizeGuest_Params params;
  BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, &params);
  MockBrowserPlugin* browser_plugin =
      static_cast<MockBrowserPlugin*>(
          browser_plugin_manager()->GetBrowserPlugin(instance_id));
  ASSERT_TRUE(browser_plugin);
  {
    BrowserPluginMsg_LoadCommit_Params navigate_params;
    navigate_params.url = GURL(kGoogleURL);
    navigate_params.process_id = 1337;
    BrowserPluginMsg_LoadCommit msg(0, instance_id, navigate_params);
    browser_plugin->OnMessageReceived(msg);
    EXPECT_EQ(2, ExecuteScriptAndReturnInt("count"));
    EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID));
  }
}
TEST_F ( BrowserPluginTest , MultipleEventListeners ) { const char * kAddEventListener = " " " " " " " " " " " " " " " " " " " " " " ; const char * kGoogleURL = " " ; const char * kGetProcessID = " " ; LoadHTML ( GetHTMLForBrowserPluginObject ( ) . c_str ( ) ) ; ExecuteJavaScript ( kAddEventListener ) ; const IPC :: Message * msg = browser_plugin_manager ( ) -> sink ( ) . GetFirstMessageMatching ( BrowserPluginHostMsg_ResizeGuest :: ID ) ; ASSERT_TRUE ( msg ) ; int instance_id = 0 ; BrowserPluginHostMsg_ResizeGuest_Params params ; BrowserPluginHostMsg_ResizeGuest :: Read ( msg , & instance_id , & params ) ; MockBrowserPlugin * browser_plugin = static_cast < MockBrowserPlugin * > ( browser_plugin_manager ( ) -> GetBrowserPlugin ( instance_id ) ) ; ASSERT_TRUE ( browser_plugin ) ; { BrowserPluginMsg_LoadCommit_Params navigate_params ; navigate_params . url = GURL ( kGoogleURL ) ; navigate_params . process_id = 1337 ; BrowserPluginMsg_LoadCommit msg ( 0 , instance_id , navigate_params ) ; browser_plugin -> OnMessageReceived ( msg ) ; EXPECT_EQ ( 2 , ExecuteScriptAndReturnInt ( " " ) ) ; EXPECT_EQ ( 1337 , ExecuteScriptAndReturnInt ( kGetProcessID ) ) ; } }
This test verifies that multiple event listeners fire that are registered
on a single event type.
This test verifies that multiple event listeners fire that are registered on a single event type .
// Grab the BrowserPlugin's instance ID from its resize message.