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

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

Issue 2656713002: Merge to M57: Remove popup overlay from MHTML when requested (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
Index: third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp
index 23af6acacf4a5155960e845504c330af7c40fa2b..6b586cfee7b83e01aeb25cc0596a5796cff7f6be 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp
@@ -63,6 +63,13 @@ class SimpleWebFrameSerializerClient final : public WebFrameSerializerClient {
class SimpleMHTMLPartsGenerationDelegate
: public WebFrameSerializer::MHTMLPartsGenerationDelegate {
+ public:
+ SimpleMHTMLPartsGenerationDelegate() : m_removePopupOverlay(false) {}
+
+ void setRemovePopupOverlay(bool removePopupOverlay) {
+ m_removePopupOverlay = removePopupOverlay;
+ }
+
private:
bool shouldSkipResource(const WebURL&) final { return false; }
@@ -73,6 +80,9 @@ class SimpleMHTMLPartsGenerationDelegate
}
bool useBinaryEncoding() final { return false; }
+ bool removePopupOverlay() final { return m_removePopupOverlay; }
+
+ bool m_removePopupOverlay;
};
// Returns the count of match for substring |pattern| in string |str|.
@@ -212,6 +222,10 @@ class WebFrameSerializerSanitizationTest : public WebFrameSerializerTest {
return String(result.data(), result.size());
}
+ void setRemovePopupOverlay(bool removePopupOverlay) {
+ m_mhtmlDelegate.setRemovePopupOverlay(removePopupOverlay);
+ }
+
private:
SimpleMHTMLPartsGenerationDelegate m_mhtmlDelegate;
};
@@ -331,4 +345,20 @@ TEST_F(WebFrameSerializerSanitizationTest, ImageLoadedFromSrcForNormalDPI) {
EXPECT_NE(WTF::kNotFound, mhtml.find("id=3D\"i2\" width=3D\"8\">"));
}
+TEST_F(WebFrameSerializerSanitizationTest, RemovePopupOverlayIfRequested) {
+ webView()->resize(WebSize(500, 500));
+ setRemovePopupOverlay(true);
+ String mhtml = generateMHTMLParts("http://www.test.com", "popup.html");
+ EXPECT_EQ(WTF::kNotFound, mhtml.find("class=3D\"overlay"));
+ EXPECT_EQ(WTF::kNotFound, mhtml.find("class=3D\"modal"));
+}
+
+TEST_F(WebFrameSerializerSanitizationTest, KeepPopupOverlayIfNotRequested) {
+ webView()->resize(WebSize(500, 500));
+ setRemovePopupOverlay(false);
+ String mhtml = generateMHTMLParts("http://www.test.com", "popup.html");
+ EXPECT_NE(WTF::kNotFound, mhtml.find("class=3D\"overlay"));
+ EXPECT_NE(WTF::kNotFound, mhtml.find("class=3D\"modal"));
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698