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

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

Issue 11412279: Browser Plugin: Only update src attribute on top-level navigations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated BrowserPluginTest.CustomEvents to cover this change Created 8 years 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/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 "function nav(e) {" 384 "function nav(e) {"
385 " url = JSON.parse(e.detail).url;" 385 " url = JSON.parse(e.detail).url;"
386 "}" 386 "}"
387 "document.getElementById('browserplugin')." 387 "document.getElementById('browserplugin')."
388 " addEventListener('-internal-loadcommit', nav);"; 388 " addEventListener('-internal-loadcommit', nav);";
389 const char* kRemoveEventListener = 389 const char* kRemoveEventListener =
390 "document.getElementById('browserplugin')." 390 "document.getElementById('browserplugin')."
391 " removeEventListener('-internal-loadcommit', nav);"; 391 " removeEventListener('-internal-loadcommit', nav);";
392 const char* kGetProcessID = 392 const char* kGetProcessID =
393 "document.getElementById('browserplugin').getProcessId()"; 393 "document.getElementById('browserplugin').getProcessId()";
394 const char* kGetSrc =
395 "document.getElementById('browserplugin').src";
394 const char* kGoogleURL = "http://www.google.com/"; 396 const char* kGoogleURL = "http://www.google.com/";
395 const char* kGoogleNewsURL = "http://news.google.com/"; 397 const char* kGoogleNewsURL = "http://news.google.com/";
396 398
397 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); 399 LoadHTML(GetHTMLForBrowserPluginObject().c_str());
398 ExecuteJavaScript(kAddEventListener); 400 ExecuteJavaScript(kAddEventListener);
399 // Grab the BrowserPlugin's instance ID from its resize message. 401 // Grab the BrowserPlugin's instance ID from its resize message.
400 const IPC::Message* msg = 402 const IPC::Message* msg =
401 browser_plugin_manager()->sink().GetFirstMessageMatching( 403 browser_plugin_manager()->sink().GetFirstMessageMatching(
402 BrowserPluginHostMsg_ResizeGuest::ID); 404 BrowserPluginHostMsg_ResizeGuest::ID);
403 ASSERT_TRUE(msg); 405 ASSERT_TRUE(msg);
404 int instance_id = -1; 406 int instance_id = -1;
405 BrowserPluginHostMsg_ResizeGuest_Params params; 407 BrowserPluginHostMsg_ResizeGuest_Params params;
406 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, &params); 408 BrowserPluginHostMsg_ResizeGuest::Read(msg, &instance_id, &params);
407 409
408 MockBrowserPlugin* browser_plugin = 410 MockBrowserPlugin* browser_plugin =
409 static_cast<MockBrowserPlugin*>( 411 static_cast<MockBrowserPlugin*>(
410 browser_plugin_manager()->GetBrowserPlugin(instance_id)); 412 browser_plugin_manager()->GetBrowserPlugin(instance_id));
411 ASSERT_TRUE(browser_plugin); 413 ASSERT_TRUE(browser_plugin);
412 414
413 { 415 {
414 BrowserPluginMsg_LoadCommit_Params navigate_params; 416 BrowserPluginMsg_LoadCommit_Params navigate_params;
417 navigate_params.is_top_level = true;
415 navigate_params.url = GURL(kGoogleURL); 418 navigate_params.url = GURL(kGoogleURL);
416 navigate_params.process_id = 1337; 419 navigate_params.process_id = 1337;
417 browser_plugin->LoadCommit(navigate_params); 420 browser_plugin->LoadCommit(navigate_params);
418 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); 421 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
422 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString(kGetSrc));
419 EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID)); 423 EXPECT_EQ(1337, ExecuteScriptAndReturnInt(kGetProcessID));
420 } 424 }
421 ExecuteJavaScript(kRemoveEventListener); 425 ExecuteJavaScript(kRemoveEventListener);
422 { 426 {
423 BrowserPluginMsg_LoadCommit_Params navigate_params; 427 BrowserPluginMsg_LoadCommit_Params navigate_params;
428 navigate_params.is_top_level = false;
424 navigate_params.url = GURL(kGoogleNewsURL); 429 navigate_params.url = GURL(kGoogleNewsURL);
425 navigate_params.process_id = 42; 430 navigate_params.process_id = 42;
426 browser_plugin->LoadCommit(navigate_params); 431 browser_plugin->LoadCommit(navigate_params);
427 // The URL variable should not change because we've removed the event 432 // The URL variable should not change because we've removed the event
428 // listener. 433 // listener.
429 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); 434 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
435 // The src attribute should not change if this is a top-level navigation.
436 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString(kGetSrc));
430 EXPECT_EQ(42, ExecuteScriptAndReturnInt(kGetProcessID)); 437 EXPECT_EQ(42, ExecuteScriptAndReturnInt(kGetProcessID));
431 } 438 }
432 } 439 }
433 440
434 TEST_F(BrowserPluginTest, StopMethod) { 441 TEST_F(BrowserPluginTest, StopMethod) {
435 const char* kCallStop = 442 const char* kCallStop =
436 "document.getElementById('browserplugin').stop();"; 443 "document.getElementById('browserplugin').stop();";
437 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); 444 LoadHTML(GetHTMLForBrowserPluginObject().c_str());
438 ExecuteJavaScript(kCallStop); 445 ExecuteJavaScript(kCallStop);
439 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( 446 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 &resize_params); 830 &resize_params);
824 EXPECT_FALSE(auto_size_params.enable); 831 EXPECT_FALSE(auto_size_params.enable);
825 EXPECT_EQ(42, auto_size_params.min_size.width()); 832 EXPECT_EQ(42, auto_size_params.min_size.width());
826 EXPECT_EQ(43, auto_size_params.min_size.height()); 833 EXPECT_EQ(43, auto_size_params.min_size.height());
827 EXPECT_EQ(1337, auto_size_params.max_size.width()); 834 EXPECT_EQ(1337, auto_size_params.max_size.width());
828 EXPECT_EQ(1338, auto_size_params.max_size.height()); 835 EXPECT_EQ(1338, auto_size_params.max_size.height());
829 } 836 }
830 } 837 }
831 838
832 } // namespace content 839 } // 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