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

Unified Diff: content/browser/web_contents/web_contents_impl_unittest.cc

Issue 11801011: Also filter the URLs from incoming non-provisional navigation IPCs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 7 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 | « content/browser/web_contents/web_contents_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl_unittest.cc
diff --git a/content/browser/web_contents/web_contents_impl_unittest.cc b/content/browser/web_contents/web_contents_impl_unittest.cc
index a669c0331bd5066a02460e4575a04ed82958bca7..de6887d38190adfa804c29df0f655242cb21552a 100644
--- a/content/browser/web_contents/web_contents_impl_unittest.cc
+++ b/content/browser/web_contents/web_contents_impl_unittest.cc
@@ -17,6 +17,7 @@
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/render_widget_host_view.h"
+#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_controller_factory.h"
#include "content/public/common/bindings_policy.h"
@@ -292,6 +293,36 @@ class WebContentsImplTest : public RenderViewHostImplTestHarness {
TestBrowserThread io_thread_;
};
+class TestWebContentsObserver : public WebContentsObserver {
+ public:
+ TestWebContentsObserver(WebContents* contents)
+ : WebContentsObserver(contents) {
+ }
+ virtual ~TestWebContentsObserver() {}
+
+ virtual void DidFinishLoad(int64 frame_id,
+ const GURL& validated_url,
+ bool is_main_frame,
+ RenderViewHost* render_view_host) OVERRIDE {
+ last_url_ = validated_url;
+ }
+ virtual void DidFailLoad(int64 frame_id,
+ const GURL& validated_url,
+ bool is_main_frame,
+ int error_code,
+ const string16& error_description,
+ RenderViewHost* render_view_host) OVERRIDE {
+ last_url_ = validated_url;
+ }
+
+ const GURL& last_url() const { return last_url_; }
+
+ private:
+ GURL last_url_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWebContentsObserver);
+};
+
} // namespace
// Test to make sure that title updates get stripped of whitespace.
@@ -1949,4 +1980,37 @@ TEST_F(WebContentsImplTest, CopyStateFromAndPruneTargetInterstitial) {
other_contents->GetInterstitialPage())->reload_on_dont_proceed());
}
+// Regression test for http://crbug.com/168611 - the URLs passed by the
+// DidFinishLoad and DidFailLoadWithError IPCs should get filtered.
+TEST_F(WebContentsImplTest, FilterURLs) {
+ TestWebContentsObserver observer(contents());
+
+ // A navigation to about:whatever should always look like a navigation to
+ // about:blank
+ GURL url_normalized("about:blank");
+ GURL url_from_ipc("about:whatever");
+
+ // We navigate the test WebContents to about:blank, since NavigateAndCommit
+ // will use the given URL to create the NavigationEntry as well, and that
+ // entry should contain the filtered URL.
+ contents()->NavigateAndCommit(url_normalized);
+
+ // Check that an IPC with about:whatever is correctly normalized.
+ contents()->TestDidFinishLoad(1, url_from_ipc, true);
+
+ EXPECT_EQ(url_normalized, observer.last_url());
+
+ // Create and navigate another WebContents.
+ scoped_ptr<TestWebContents> other_contents(
+ static_cast<TestWebContents*>(CreateTestWebContents()));
+ TestWebContentsObserver other_observer(other_contents.get());
+ other_contents->NavigateAndCommit(url_normalized);
+
+ // Check that an IPC with about:whatever is correctly normalized.
+ other_contents->TestDidFailLoadWithError(
+ 1, url_from_ipc, true, 1, string16());
+ EXPECT_EQ(url_normalized, other_observer.last_url());
+}
+
+
} // namespace content
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698