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

Unified Diff: chrome/renderer/chrome_content_renderer_client_browsertest.cc

Issue 2646133003: Retrieve NTP thumbnail URLs from the right frame (Closed)
Patch Set: Created 3 years, 11 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 | « chrome/renderer/chrome_content_renderer_client.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/chrome_content_renderer_client_browsertest.cc
diff --git a/chrome/renderer/chrome_content_renderer_client_browsertest.cc b/chrome/renderer/chrome_content_renderer_client_browsertest.cc
index 31e3e055294529f9aa1cbaaa3a2d2c1e83e1e073..22bee6bbcae8ad97febaee0fe02436351340c1c2 100644
--- a/chrome/renderer/chrome_content_renderer_client_browsertest.cc
+++ b/chrome/renderer/chrome_content_renderer_client_browsertest.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
+#include "chrome/renderer/searchbox/searchbox.h"
#include "chrome/test/base/chrome_render_view_test.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
@@ -34,14 +35,14 @@
#include "third_party/WebKit/public/web/WebPluginParams.h"
#include "url/gurl.h"
-using testing::_;
-using testing::SetArgPointee;
-
-typedef ChromeRenderViewTest InstantProcessNavigationTest;
+using InstantProcessNavigationTest = ChromeRenderViewTest;
+using ChromeContentRendererClientSearchBoxTest = ChromeRenderViewTest;
const base::FilePath::CharType kDocRoot[] =
FILE_PATH_LITERAL("chrome/test/data");
+const char kHtmlWithIframe[] ="<iframe srcdoc=\"Nothing here\"></iframe>";
+
// Tests that renderer-initiated navigations from an Instant render process get
// bounced back to the browser to be rebucketed into a non-Instant renderer if
// necessary.
@@ -80,6 +81,38 @@ TEST_F(InstantProcessNavigationTest, ForkForNavigationsToSearchURLs) {
&unused));
}
+TEST_F(ChromeContentRendererClientSearchBoxTest, RewriteThumbnailURL) {
+ // Instantiate a SearchBox for the main render frame.
+ content::RenderFrame* render_frame =
+ content::RenderFrame::FromWebFrame(GetMainFrame());
+ new SearchBox(render_frame);
+
+ // Load a page that contains an iframe.
+ LoadHTML(kHtmlWithIframe);
+
+ ChromeContentRendererClient client;
+
+ // Create a thumbnail URL containing the correct render view ID and an
+ // arbitrary instant restricted ID.
+ GURL thumbnail_url(base::StringPrintf(
+ "chrome-search:/thumb/%i/1",
+ render_frame->GetRenderView()->GetRoutingID()));
+
+ GURL result;
+ // Make sure the SearchBox rewrites a thumbnail request from the main frame.
+ EXPECT_TRUE(client.WillSendRequest(GetMainFrame(), ui::PAGE_TRANSITION_LINK,
+ blink::WebURL(thumbnail_url), &result));
+
+ // Make sure the SearchBox rewrites a thumbnail request from the iframe.
+ blink::WebFrame* child_frame = GetMainFrame()->firstChild();
+ ASSERT_TRUE(child_frame);
+ ASSERT_TRUE(child_frame->isWebLocalFrame());
+ blink::WebLocalFrame* local_child =
+ static_cast<blink::WebLocalFrame*>(child_frame);
+ EXPECT_TRUE(client.WillSendRequest(local_child, ui::PAGE_TRANSITION_LINK,
+ blink::WebURL(thumbnail_url), &result));
+}
+
// The tests below examine Youtube requests that use the Flash API and ensure
// that the requests have been modified to instead use HTML5. The tests also
// check the MIME type of the request to ensure that it is "text/html".
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698