Commit d8e1571c authored by sgurun's avatar sgurun Committed by Commit bot

Add a unit test for viewsource reverse writer handler

The reverse writer for viewsource had an incorrect assumption about the path component of URL which was causing a duplication of query and fragment parameters. This change is to unit test the fix that  went in
https://codereview.chromium.org/655023002/

BUG=336846

Review URL: https://codereview.chromium.org/659153003

Cr-Commit-Position: refs/heads/master@{#300281}
parent 5c1f219c
...@@ -46,6 +46,7 @@ class CONTENT_EXPORT BrowserURLHandlerImpl : public BrowserURLHandler { ...@@ -46,6 +46,7 @@ class CONTENT_EXPORT BrowserURLHandlerImpl : public BrowserURLHandler {
FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, BasicRewriteAndReverse); FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, BasicRewriteAndReverse);
FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, NullHandlerReverse); FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, NullHandlerReverse);
FRIEND_TEST_ALL_PREFIXES(BrowserURLHandlerImplTest, ViewSourceReverse);
DISALLOW_COPY_AND_ASSIGN(BrowserURLHandlerImpl); DISALLOW_COPY_AND_ASSIGN(BrowserURLHandlerImpl);
}; };
......
...@@ -79,4 +79,19 @@ TEST_F(BrowserURLHandlerImplTest, NullHandlerReverse) { ...@@ -79,4 +79,19 @@ TEST_F(BrowserURLHandlerImplTest, NullHandlerReverse) {
ASSERT_EQ("foo://foo", url.spec()); ASSERT_EQ("foo://foo", url.spec());
} }
// Verify that the reverse handler for view-source does not duplicate query
// parameters.
TEST_F(BrowserURLHandlerImplTest, ViewSourceReverse) {
TestBrowserContext browser_context;
BrowserURLHandlerImpl handler;
GURL url("http://foo/?a=1");
GURL original_url("view-source:http://some_url");
bool reversed = handler.ReverseURLRewrite(&url,
original_url,
&browser_context);
ASSERT_TRUE(reversed);
ASSERT_EQ("view-source:http://foo/?a=1", url.spec());
}
} // namespace content } // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment