summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-09 17:47:24 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-09 17:47:24 +0000
commit9f42b4c8a57547793c7c364764edcf2b2492a47c (patch)
treec1e944391747caca127d06346bc0166809179faf /chrome_frame
parentfa1651cf3257eb5db2ceb7fb6fa43fd3c853ae31 (diff)
downloadchromium_src-9f42b4c8a57547793c7c364764edcf2b2492a47c.zip
chromium_src-9f42b4c8a57547793c7c364764edcf2b2492a47c.tar.gz
chromium_src-9f42b4c8a57547793c7c364764edcf2b2492a47c.tar.bz2
Add a couple of new tests to verify that gcf: protocol
can not be used to navigate to http and https URLs. BUG=none TEST=NavigationTest.GcfProtocol2, NavigationTest.GcfProtocol3 Review URL: http://codereview.chromium.org/3307019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58959 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/test/navigation_test.cc76
1 files changed, 48 insertions, 28 deletions
diff --git a/chrome_frame/test/navigation_test.cc b/chrome_frame/test/navigation_test.cc
index 89a78e6..0701a30 100644
--- a/chrome_frame/test/navigation_test.cc
+++ b/chrome_frame/test/navigation_test.cc
@@ -550,44 +550,64 @@ TEST_P(NavigationTransitionTest, FollowLink) {
LaunchIEAndNavigate(GetLinkPageUrl());
}
+// gMock matcher which tests if a url is blank.
+MATCHER(BlankUrl, "is \"\" or NULL") {
+ return arg == NULL || wcslen(arg) == 0;
+}
+
// Basic navigation test fixture which uses the MockIEEventSink. These tests
// are not parameterized.
class NavigationTest : public MockIEEventSinkTest, public testing::Test {
public:
NavigationTest() {}
+
+ void TestDisAllowedUrl(const wchar_t* url) {
+ // If a navigation fails then IE issues a navigation to an interstitial
+ // page. Catch this to track navigation errors as the NavigateError
+ // notification does not seem to fire reliably.
+ EXPECT_CALL(ie_mock_, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
+ StrEq(url)),
+ _, _, _, _, _));
+ EXPECT_CALL(ie_mock_, OnLoad(IN_IE, BlankUrl()))
+ .Times(testing::AtMost(1));
+ EXPECT_CALL(ie_mock_, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
+ testing::StartsWith(L"res:")),
+ _, _, _, _, _));
+ EXPECT_CALL(ie_mock_, OnFileDownload(VARIANT_TRUE, _))
+ .Times(testing::AnyNumber())
+ .WillRepeatedly(testing::Return());
+ EXPECT_CALL(ie_mock_, OnNavigateComplete2(_,
+ testing::Field(&VARIANT::bstrVal,
+ StrEq(url))));
+ // Although we expect a load event for this, we should never receive a
+ // corresponding GET request.
+ EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(url)))
+ .WillOnce(CloseBrowserMock(&ie_mock_));
+
+ LaunchIEAndNavigate(url);
+ }
+
};
-// gMock matcher which tests if a url is blank.
-MATCHER(BlankUrl, "is \"\" or NULL") {
- return arg == NULL || wcslen(arg) == 0;
+// Test navigation to a disallowed gcf: url with file scheme.
+TEST_F(NavigationTest, GcfProtocol1) {
+ // Make sure that we are not accidently enabling gcf protocol.
+ SetConfigBool(kAllowUnsafeURLs, false);
+ TestDisAllowedUrl(L"gcf:file:///C:/");
}
-// Test navigation to a disallowed url.
-TEST_F(NavigationTest, DisallowedUrl) {
- // If a navigation fails then IE issues a navigation to an interstitial
- // page. Catch this to track navigation errors as the NavigateError
- // notification does not seem to fire reliably.
- const wchar_t disallowed_url[] = L"gcf:file:///C:/";
-
- EXPECT_CALL(ie_mock_, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
- StrEq(disallowed_url)),
- _, _, _, _, _));
- EXPECT_CALL(ie_mock_, OnLoad(IN_IE, BlankUrl()))
- .Times(testing::AtMost(1));
- EXPECT_CALL(ie_mock_, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
- testing::StartsWith(L"res:")),
- _, _, _, _, _));
- EXPECT_CALL(ie_mock_, OnFileDownload(VARIANT_TRUE, _))
- .Times(testing::AnyNumber())
- .WillRepeatedly(testing::Return());
- EXPECT_CALL(ie_mock_, OnNavigateComplete2(_, testing::Field(&VARIANT::bstrVal,
- StrEq(disallowed_url))));
- // Although we expect a load event for this, we should never receive a
- // corresponding GET request.
- EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(disallowed_url)))
- .WillOnce(CloseBrowserMock(&ie_mock_));
+// Test navigation to a disallowed gcf: url with http scheme.
+TEST_F(NavigationTest, GcfProtocol2) {
+ // Make sure that we are not accidently enabling gcf protocol.
+ SetConfigBool(kAllowUnsafeURLs, false);
+ TestDisAllowedUrl(L"gcf:http://www.google.com");
+}
- LaunchIEAndNavigate(disallowed_url);
+// Test navigation to a disallowed gcf: url with https scheme.
+TEST_F(NavigationTest, GcfProtocol3) {
+ // Make sure that we are not accidently enabling gcf protocol.
+ SetConfigBool(kAllowUnsafeURLs, false);
+ TestDisAllowedUrl(L"gcf:https://www.google.com");
}
// NOTE: This test is currently disabled as we haven't finished implementing