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

Unified Diff: content/renderer/browser_plugin/browser_plugin_browsertest.cc

Issue 17165004: <webview>: Partially migrate loadcommit event from content to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with ToT Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/browser_plugin/browser_plugin_browsertest.cc
diff --git a/content/renderer/browser_plugin/browser_plugin_browsertest.cc b/content/renderer/browser_plugin/browser_plugin_browsertest.cc
index dd12f18cc7570789ae48d94453d469aea471ccac..0bdcf6f03985e74bd3b9f5985f701329584ea48c 100644
--- a/content/renderer/browser_plugin/browser_plugin_browsertest.cc
+++ b/content/renderer/browser_plugin/browser_plugin_browsertest.cc
@@ -453,53 +453,6 @@ TEST_F(BrowserPluginTest, RemovePluginBeforeNavigation) {
BrowserPluginHostMsg_PluginDestroyed::ID));
}
-TEST_F(BrowserPluginTest, CustomEvents) {
- const char* kAddEventListener =
- "var url;"
- "function nav(e) {"
- " url = JSON.parse(e.detail).url;"
- "}"
- "document.getElementById('browserplugin')."
- " addEventListener('-internal-loadcommit', nav);";
- const char* kRemoveEventListener =
- "document.getElementById('browserplugin')."
- " removeEventListener('-internal-loadcommit', nav);";
- const char* kGetSrc =
- "document.getElementById('browserplugin').src";
- const char* kGoogleURL = "http://www.google.com/";
- const char* kGoogleNewsURL = "http://news.google.com/";
-
- LoadHTML(GetHTMLForBrowserPluginObject().c_str());
- ExecuteJavaScript(kAddEventListener);
-
- MockBrowserPlugin* browser_plugin = GetCurrentPlugin();
- ASSERT_TRUE(browser_plugin);
- int instance_id = browser_plugin->instance_id();
-
- {
- BrowserPluginMsg_LoadCommit_Params navigate_params;
- navigate_params.is_top_level = true;
- navigate_params.url = GURL(kGoogleURL);
- BrowserPluginMsg_LoadCommit msg(instance_id, navigate_params);
- browser_plugin->OnMessageReceived(msg);
- EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
- EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString(kGetSrc));
- }
- ExecuteJavaScript(kRemoveEventListener);
- {
- BrowserPluginMsg_LoadCommit_Params navigate_params;
- navigate_params.is_top_level = false;
- navigate_params.url = GURL(kGoogleNewsURL);
- BrowserPluginMsg_LoadCommit msg(instance_id, navigate_params);
- browser_plugin->OnMessageReceived(msg);
- // The URL variable should not change because we've removed the event
- // listener.
- EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
- // The src attribute should not change if this is a top-level navigation.
- EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString(kGetSrc));
- }
-}
-
TEST_F(BrowserPluginTest, StopMethod) {
const char* kCallStop =
"document.getElementById('browserplugin').stop();";
@@ -657,79 +610,6 @@ TEST_F(BrowserPluginTest, ImmutableAttributesAfterNavigation) {
EXPECT_STREQ("storage", partition_value.c_str());
}
-// This test verifies that we can mutate the event listener vector
-// within an event listener.
-TEST_F(BrowserPluginTest, RemoveEventListenerInEventListener) {
- const char* kAddEventListener =
- "var url;"
- "function nav(e) {"
- " url = JSON.parse(e.detail).url;"
- " document.getElementById('browserplugin')."
- " removeEventListener('-internal-loadcommit', nav);"
- "}"
- "document.getElementById('browserplugin')."
- " addEventListener('-internal-loadcommit', nav);";
- const char* kGoogleURL = "http://www.google.com/";
- const char* kGoogleNewsURL = "http://news.google.com/";
-
- LoadHTML(GetHTMLForBrowserPluginObject().c_str());
- ExecuteJavaScript(kAddEventListener);
-
- MockBrowserPlugin* browser_plugin = GetCurrentPlugin();
- ASSERT_TRUE(browser_plugin);
- int instance_id = browser_plugin->instance_id();
-
- {
- BrowserPluginMsg_LoadCommit_Params navigate_params;
- navigate_params.url = GURL(kGoogleURL);
- BrowserPluginMsg_LoadCommit msg(instance_id, navigate_params);
- browser_plugin->OnMessageReceived(msg);
- EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
- }
- {
- BrowserPluginMsg_LoadCommit_Params navigate_params;
- navigate_params.url = GURL(kGoogleNewsURL);
- BrowserPluginMsg_LoadCommit msg(instance_id, navigate_params);
- browser_plugin->OnMessageReceived(msg);
- // The URL variable should not change because we've removed the event
- // listener.
- EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
- }
-}
-
-// 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/";
-
- LoadHTML(GetHTMLForBrowserPluginObject().c_str());
- ExecuteJavaScript(kAddEventListener);
-
- MockBrowserPlugin* browser_plugin = GetCurrentPlugin();
- ASSERT_TRUE(browser_plugin);
- int instance_id = browser_plugin->instance_id();
-
- {
- BrowserPluginMsg_LoadCommit_Params navigate_params;
- navigate_params.url = GURL(kGoogleURL);
- BrowserPluginMsg_LoadCommit msg(instance_id, navigate_params);
- browser_plugin->OnMessageReceived(msg);
- EXPECT_EQ(2, ExecuteScriptAndReturnInt("count"));
- }
-}
-
TEST_F(BrowserPluginTest, RemoveBrowserPluginOnExit) {
LoadHTML(GetHTMLForBrowserPluginObject().c_str());
« 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