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

Unified Diff: third_party/WebKit/Source/core/html/HTMLFormControlElementTest.cpp

Issue 2851123002: Merge "Form validation: Do not show validation bubble during printing." to M59. (Closed)
Patch Set: Created 3 years, 8 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 | « third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLFormControlElementTest.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLFormControlElementTest.cpp b/third_party/WebKit/Source/core/html/HTMLFormControlElementTest.cpp
index 4ee8c5b3bcd78793257dae64eb4ad5307ae1c641..45ee080c53e54ca6c58fe866c4d86f8cff0571be 100644
--- a/third_party/WebKit/Source/core/html/HTMLFormControlElementTest.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLFormControlElementTest.cpp
@@ -4,17 +4,55 @@
#include "core/html/HTMLFormControlElement.h"
+#include <memory>
#include "core/dom/Document.h"
#include "core/frame/FrameView.h"
#include "core/html/HTMLInputElement.h"
#include "core/layout/LayoutObject.h"
#include "core/loader/EmptyClients.h"
+#include "core/page/ValidationMessageClient.h"
#include "core/testing/DummyPageHolder.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <memory>
namespace blink {
+namespace {
+class MockValidationMessageClient
+ : public GarbageCollectedFinalized<MockValidationMessageClient>,
+ public ValidationMessageClient {
+ USING_GARBAGE_COLLECTED_MIXIN(MockValidationMessageClient);
+
+ public:
+ void ShowValidationMessage(const Element& anchor,
+ const String&,
+ TextDirection,
+ const String&,
+ TextDirection) override {
+ anchor_ = anchor;
+ }
+
+ void HideValidationMessage(const Element& anchor) override {
+ if (anchor_ == &anchor)
+ anchor_ = nullptr;
+ }
+
+ bool IsValidationMessageVisible(const Element& anchor) override {
+ return anchor_ == &anchor;
+ }
+
+ void WillUnloadDocument(const Document&) override {}
+ void DocumentDetached(const Document&) override {}
+ void WillBeDestroyed() override {}
+ DEFINE_INLINE_VIRTUAL_TRACE() {
+ visitor->Trace(anchor_);
+ ValidationMessageClient::Trace(visitor);
+ }
+
+ private:
+ Member<const Element> anchor_;
+};
+}
+
class HTMLFormControlElementTest : public ::testing::Test {
protected:
void SetUp() override;
@@ -84,4 +122,21 @@ TEST_F(HTMLFormControlElementTest, customValidationMessageTextDirection) {
EXPECT_EQ(TextDirection::kRtl, sub_message_dir);
}
+TEST_F(HTMLFormControlElementTest, UpdateValidationMessageSkippedIfPrinting) {
+ GetDocument().documentElement()->setInnerHTML(
+ "<body><input required id=input></body>");
+ GetDocument().View()->UpdateAllLifecyclePhases();
+ ValidationMessageClient* validation_message_client =
+ new MockValidationMessageClient();
+ GetDocument().GetPage()->SetValidationMessageClient(
+ validation_message_client);
+
+ HTMLInputElement* input =
+ toHTMLInputElement(GetDocument().getElementById("input"));
+ GetDocument().GetFrame()->SetPrinting(true, FloatSize(800, 600),
+ FloatSize(800, 600), 1);
+ input->reportValidity();
+ EXPECT_FALSE(validation_message_client->IsValidationMessageVisible(*input));
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698