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

Unified Diff: third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp

Issue 1371323003: Escape "--" in the page URL at page serialization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2015-09-30T19:11:33 Follow review comments Created 5 years, 3 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
Index: third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp b/third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp
index 3ab3b47b6c8698fb3c87ab0a97ff675e8fc9ff70..0c2821a8cfcdc0d54a4725388dc3fdaef386d99d 100644
--- a/third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp
@@ -40,6 +40,7 @@
#include "public/platform/WebUnitTestSupport.h"
#include "public/web/WebDocument.h"
#include "public/web/WebFrame.h"
+#include "public/web/WebPageSerializerClient.h"
#include "public/web/WebView.h"
#include "web/tests/FrameTestHelpers.h"
#include <gtest/gtest.h>
@@ -49,6 +50,22 @@ using blink::URLTestHelpers::toKURL;
namespace blink {
+namespace {
+class SimpleWebPageSerializerClient : public WebPageSerializerClient {
+public:
+ std::string toString() const { return m_string; }
+
+private:
+ void didSerializeDataForFrame(const WebURL&, const WebCString& data, PageSerializationStatus) final
+ {
+ m_string += data;
+ }
+
+ std::string m_string;
+};
+
+} // namespace
+
class WebPageSerializerTest : public testing::Test {
public:
WebPageSerializerTest() : m_supportedSchemes(static_cast<size_t>(3))
@@ -134,6 +151,20 @@ TEST_F(WebPageSerializerTest, HTMLNodes)
EXPECT_TRUE(webVectorContains(resources, "file://c/my_folder/file.gif"));
}
+TEST_F(WebPageSerializerTest, fromUrlWithMinusMinus)
+{
+ WebURL topFrameURL = toKURL("http://www.test.com?--x--");
+ registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("text_only_page.html"));
+ loadURLInTopFrame(topFrameURL);
+
+ SimpleWebPageSerializerClient serializerClient;
+ WebVector<WebURL> links(&topFrameURL, 1);
+ WebVector<WebString> localPaths(&"local", 1);
+ WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &serializerClient, links, localPaths, "");
+
+ EXPECT_EQ("<!-- saved from url=(0030)http://www.test.com/?-%2Dx-%2D -->", serializerClient.toString().substr(1, 60));
+}
+
TEST_F(WebPageSerializerTest, MultipleFrames)
{
// Register the mocked frames.

Powered by Google App Engine
This is Rietveld 408576698