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

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

Issue 10965017: Browser Plugin: Implement getProcessId (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
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 6d23e0cade9a60e29e69858877d2a91a49377dde..18b86500442dd0f624e40810dc3da29c17892e93 100644
--- a/content/renderer/browser_plugin/browser_plugin_browsertest.cc
+++ b/content/renderer/browser_plugin/browser_plugin_browsertest.cc
@@ -64,6 +64,16 @@ std::string BrowserPluginTest::ExecuteScriptAndReturnString(
return str.get();
}
+int BrowserPluginTest::ExecuteScriptAndReturnInt(
+ const std::string& script) {
+ v8::Handle<v8::Value> value = GetMainFrame()->executeScriptAndReturnValue(
+ WebKit::WebScriptSource(WebKit::WebString::fromUTF8(script.c_str())));
+ if (value.IsEmpty() || !value->IsInt32())
+ return 0;
+
+ return value->Int32Value();
+}
+
// This test verifies that an initial resize occurs when we instantiate the
// browser plugin. This test also verifies that the browser plugin is waiting
// for a BrowserPluginMsg_UpdateRect in response. We issue an UpdateRect, and
@@ -293,6 +303,9 @@ TEST_F(BrowserPluginTest, CustomEvents) {
const char* kRemoveEventListener =
"document.getElementById('browserplugin')."
" removeEventListener('navigation', nav);";
+ const char* kGetProcessID =
+ "document.getElementById('browserplugin')."
lazyboy 2012/09/20 19:47:04 nit: next line fits in this line
Fady Samuel 2012/09/20 21:58:05 Done.
+ " getProcessId()";
const char* kGoogleURL = "http://www.google.com/";
const char* kGoogleNewsURL = "http://news.google.com/";
@@ -313,14 +326,16 @@ TEST_F(BrowserPluginTest, CustomEvents) {
browser_plugin_manager()->GetBrowserPlugin(instance_id));
ASSERT_TRUE(browser_plugin);
- browser_plugin->DidNavigate(GURL(kGoogleURL));
lazyboy 2012/09/20 19:47:04 ASSERT browser_plugin->getProcessId() == 0 if we h
Fady Samuel 2012/09/20 21:58:05 I believe 0 is a valid RenderProcessHost ID. I thi
+ browser_plugin->DidNavigate(GURL(kGoogleURL), 1337);
EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
+ EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID));
ExecuteJavaScript(kRemoveEventListener);
- browser_plugin->DidNavigate(GURL(kGoogleNewsURL));
+ browser_plugin->DidNavigate(GURL(kGoogleNewsURL), 42);
// The URL variable should not change because we've removed the event
// listener.
EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
+ EXPECT_EQ(42, ExecuteScriptAndReturnInt(kGetProcessID));
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698