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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLInputElementTest.cpp

Issue 2561043002: Clean-up after Form Association Refactoring (Closed)
Patch Set: Removed constructorNeedsFormElement from scripts and HTMLTagNames Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/html/HTMLInputElement.h" 5 #include "core/html/HTMLInputElement.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/FrameHost.h" 8 #include "core/frame/FrameHost.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/VisualViewport.h" 10 #include "core/frame/VisualViewport.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 "<datalist id=dl3>" 78 "<datalist id=dl3>"
79 "<option>keishi@chromium.org</option>" 79 "<option>keishi@chromium.org</option>"
80 "<option>tkent@chromium.org</option>" 80 "<option>tkent@chromium.org</option>"
81 "</datalist>"); 81 "</datalist>");
82 auto options = testElement().filteredDataListOptions(); 82 auto options = testElement().filteredDataListOptions();
83 EXPECT_EQ(1u, options.size()); 83 EXPECT_EQ(1u, options.size());
84 EXPECT_EQ("tkent@chromium.org", options[0]->value().utf8()); 84 EXPECT_EQ("tkent@chromium.org", options[0]->value().utf8());
85 } 85 }
86 86
87 TEST_F(HTMLInputElementTest, create) { 87 TEST_F(HTMLInputElementTest, create) {
88 HTMLInputElement* input = HTMLInputElement::create( 88 HTMLInputElement* input =
89 document(), nullptr, /* createdByParser */ false); 89 HTMLInputElement::create(document(), /* createdByParser */ false);
90 EXPECT_NE(nullptr, input->userAgentShadowRoot()); 90 EXPECT_NE(nullptr, input->userAgentShadowRoot());
91 91
92 input = 92 input = HTMLInputElement::create(document(), /* createdByParser */ true);
93 HTMLInputElement::create(document(), nullptr, /* createdByParser */ true);
94 EXPECT_EQ(nullptr, input->userAgentShadowRoot()); 93 EXPECT_EQ(nullptr, input->userAgentShadowRoot());
95 input->parserSetAttributes(Vector<Attribute>()); 94 input->parserSetAttributes(Vector<Attribute>());
96 EXPECT_NE(nullptr, input->userAgentShadowRoot()); 95 EXPECT_NE(nullptr, input->userAgentShadowRoot());
97 } 96 }
98 97
99 TEST_F(HTMLInputElementTest, NoAssertWhenMovedInNewDocument) { 98 TEST_F(HTMLInputElementTest, NoAssertWhenMovedInNewDocument) {
100 Document* documentWithoutFrame = Document::create(); 99 Document* documentWithoutFrame = Document::create();
101 EXPECT_EQ(nullptr, documentWithoutFrame->frameHost()); 100 EXPECT_EQ(nullptr, documentWithoutFrame->frameHost());
102 HTMLHtmlElement* html = HTMLHtmlElement::create(*documentWithoutFrame); 101 HTMLHtmlElement* html = HTMLHtmlElement::create(*documentWithoutFrame);
103 html->appendChild(HTMLBodyElement::create(*documentWithoutFrame)); 102 html->appendChild(HTMLBodyElement::create(*documentWithoutFrame));
(...skipping 11 matching lines...) Expand all
115 114
116 // Remove the input element and all refs to it so it gets deleted before the 115 // Remove the input element and all refs to it so it gets deleted before the
117 // document. 116 // document.
118 // The assert in |EventHandlerRegistry::updateEventHandlerTargets()| should 117 // The assert in |EventHandlerRegistry::updateEventHandlerTargets()| should
119 // not be triggered. 118 // not be triggered.
120 document.body()->removeChild(document.body()->firstChild()); 119 document.body()->removeChild(document.body()->firstChild());
121 } 120 }
122 121
123 TEST_F(HTMLInputElementTest, DefaultToolTip) { 122 TEST_F(HTMLInputElementTest, DefaultToolTip) {
124 HTMLInputElement* inputWithoutForm = 123 HTMLInputElement* inputWithoutForm =
125 HTMLInputElement::create(document(), nullptr, false); 124 HTMLInputElement::create(document(), false);
126 inputWithoutForm->setBooleanAttribute(HTMLNames::requiredAttr, true); 125 inputWithoutForm->setBooleanAttribute(HTMLNames::requiredAttr, true);
127 document().body()->appendChild(inputWithoutForm); 126 document().body()->appendChild(inputWithoutForm);
128 EXPECT_EQ("<<ValidationValueMissing>>", inputWithoutForm->defaultToolTip()); 127 EXPECT_EQ("<<ValidationValueMissing>>", inputWithoutForm->defaultToolTip());
129 128
130 HTMLFormElement* form = HTMLFormElement::create(document()); 129 HTMLFormElement* form = HTMLFormElement::create(document());
131 document().body()->appendChild(form); 130 document().body()->appendChild(form);
132 HTMLInputElement* inputWithForm = 131 HTMLInputElement* inputWithForm = HTMLInputElement::create(document(), false);
133 HTMLInputElement::create(document(), nullptr, false);
134 inputWithForm->setBooleanAttribute(HTMLNames::requiredAttr, true); 132 inputWithForm->setBooleanAttribute(HTMLNames::requiredAttr, true);
135 form->appendChild(inputWithForm); 133 form->appendChild(inputWithForm);
136 EXPECT_EQ("<<ValidationValueMissing>>", inputWithForm->defaultToolTip()); 134 EXPECT_EQ("<<ValidationValueMissing>>", inputWithForm->defaultToolTip());
137 135
138 form->setBooleanAttribute(HTMLNames::novalidateAttr, true); 136 form->setBooleanAttribute(HTMLNames::novalidateAttr, true);
139 EXPECT_EQ(String(), inputWithForm->defaultToolTip()); 137 EXPECT_EQ(String(), inputWithForm->defaultToolTip());
140 } 138 }
141 139
142 // crbug.com/589838 140 // crbug.com/589838
143 TEST_F(HTMLInputElementTest, ImageTypeCrash) { 141 TEST_F(HTMLInputElementTest, ImageTypeCrash) {
144 HTMLInputElement* input = 142 HTMLInputElement* input = HTMLInputElement::create(document(), false);
145 HTMLInputElement::create(document(), nullptr, false);
146 input->setAttribute(HTMLNames::typeAttr, "image"); 143 input->setAttribute(HTMLNames::typeAttr, "image");
147 input->ensureFallbackContent(); 144 input->ensureFallbackContent();
148 // Make sure ensurePrimaryContent() recreates UA shadow tree, and updating 145 // Make sure ensurePrimaryContent() recreates UA shadow tree, and updating
149 // |value| doesn't crash. 146 // |value| doesn't crash.
150 input->ensurePrimaryContent(); 147 input->ensurePrimaryContent();
151 input->setAttribute(HTMLNames::valueAttr, "aaa"); 148 input->setAttribute(HTMLNames::valueAttr, "aaa");
152 } 149 }
153 150
154 TEST_F(HTMLInputElementTest, DateTimeChooserSizeParamRespectsScale) { 151 TEST_F(HTMLInputElementTest, DateTimeChooserSizeParamRespectsScale) {
155 document().view()->frame().host()->visualViewport().setScale(2.f); 152 document().view()->frame().host()->visualViewport().setScale(2.f);
156 document().body()->setInnerHTML( 153 document().body()->setInnerHTML(
157 "<input type='date' style='width:200px;height:50px' />"); 154 "<input type='date' style='width:200px;height:50px' />");
158 document().view()->updateAllLifecyclePhases(); 155 document().view()->updateAllLifecyclePhases();
159 HTMLInputElement* input = toHTMLInputElement(document().body()->firstChild()); 156 HTMLInputElement* input = toHTMLInputElement(document().body()->firstChild());
160 157
161 DateTimeChooserParameters params; 158 DateTimeChooserParameters params;
162 bool success = input->setupDateTimeChooserParameters(params); 159 bool success = input->setupDateTimeChooserParameters(params);
163 EXPECT_TRUE(success); 160 EXPECT_TRUE(success);
164 EXPECT_EQ("date", params.type); 161 EXPECT_EQ("date", params.type);
165 EXPECT_EQ(IntRect(16, 16, 400, 100), params.anchorRectInScreen); 162 EXPECT_EQ(IntRect(16, 16, 400, 100), params.anchorRectInScreen);
166 } 163 }
167 164
168 } // namespace blink 165 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLInputElement.cpp ('k') | third_party/WebKit/Source/core/html/HTMLKeygenElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698