OLD | NEW |
---|---|
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/HTMLSelectElement.h" | 5 #include "core/html/HTMLSelectElement.h" |
6 | 6 |
7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
8 #include "core/html/HTMLDocument.h" | 8 #include "core/html/HTMLDocument.h" |
9 #include "core/html/HTMLFormElement.h" | 9 #include "core/html/HTMLFormElement.h" |
10 #include "core/html/forms/FormController.h" | 10 #include "core/html/forms/FormController.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 EXPECT_EQ(-1, select->activeSelectionEndListIndex()); | 303 EXPECT_EQ(-1, select->activeSelectionEndListIndex()); |
304 select->appendChild(option, ASSERT_NO_EXCEPTION); | 304 select->appendChild(option, ASSERT_NO_EXCEPTION); |
305 EXPECT_EQ(1, select->activeSelectionEndListIndex()); | 305 EXPECT_EQ(1, select->activeSelectionEndListIndex()); |
306 } | 306 } |
307 | 307 |
308 TEST_F(HTMLSelectElementTest, DefaultToolTip) | 308 TEST_F(HTMLSelectElementTest, DefaultToolTip) |
309 { | 309 { |
310 document().documentElement()->setInnerHTML("<select size=4><option value=""> Placeholder</option><optgroup><option>o2</option></optgroup></select>", ASSERT_N O_EXCEPTION); | 310 document().documentElement()->setInnerHTML("<select size=4><option value=""> Placeholder</option><optgroup><option>o2</option></optgroup></select>", ASSERT_N O_EXCEPTION); |
311 document().view()->updateAllLifecyclePhases(); | 311 document().view()->updateAllLifecyclePhases(); |
312 HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChil d()); | 312 HTMLSelectElement* select = toHTMLSelectElement(document().body()->firstChil d()); |
313 Element* option = toElement(select->firstChild()); | 313 RefPtrWillBeRawPtr<Element> option = toElement(select->firstChild()); |
314 Element* optgroup = toElement(option->nextSibling()); | 314 RefPtrWillBeRawPtr<Element> optgroup = toElement(option->nextSibling()); |
315 | 315 |
316 EXPECT_EQ(String(), select->defaultToolTip()) << "defaultToolTip for SELECT without FORM and without required attribute should return null string."; | 316 EXPECT_EQ(String(), select->defaultToolTip()) << "defaultToolTip for SELECT without FORM and without required attribute should return null string."; |
317 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); | 317 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); |
318 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); | 318 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); |
319 | 319 |
320 select->setBooleanAttribute(HTMLNames::requiredAttr, true); | 320 select->setBooleanAttribute(HTMLNames::requiredAttr, true); |
321 EXPECT_EQ("<<ValidationValueMissingForSelect>>", select->defaultToolTip()) < < "defaultToolTip for SELECT without FORM and with required attribute should ret urn a valueMissing message."; | 321 EXPECT_EQ("<<ValidationValueMissingForSelect>>", select->defaultToolTip()) < < "defaultToolTip for SELECT without FORM and with required attribute should ret urn a valueMissing message."; |
322 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); | 322 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); |
323 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); | 323 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); |
324 | 324 |
325 RefPtrWillBeRawPtr<HTMLFormElement> form = HTMLFormElement::create(document( )); | 325 RefPtrWillBeRawPtr<HTMLFormElement> form = HTMLFormElement::create(document( )); |
326 document().body()->appendChild(form.get()); | 326 document().body()->appendChild(form.get()); |
327 form->appendChild(select); | 327 form->appendChild(select); |
328 EXPECT_EQ("<<ValidationValueMissingForSelect>>", select->defaultToolTip()) < < "defaultToolTip for SELECT with FORM and required attribute should return a va lueMissing message."; | 328 EXPECT_EQ("<<ValidationValueMissingForSelect>>", select->defaultToolTip()) < < "defaultToolTip for SELECT with FORM and required attribute should return a va lueMissing message."; |
329 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); | 329 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); |
330 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); | 330 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); |
331 | 331 |
332 form->setBooleanAttribute(HTMLNames::novalidateAttr, true); | 332 form->setBooleanAttribute(HTMLNames::novalidateAttr, true); |
333 EXPECT_EQ(String(), select->defaultToolTip()) << "defaultToolTip for SELECT with FORM[novalidate] and required attribute should return null string."; | 333 EXPECT_EQ(String(), select->defaultToolTip()) << "defaultToolTip for SELECT with FORM[novalidate] and required attribute should return null string."; |
334 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); | 334 EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip()); |
335 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); | 335 EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip()); |
336 | 336 |
337 option->remove(); | 337 option->remove(); |
tkent
2016/02/29 23:21:24
I see. This clears the reference count.
| |
338 optgroup->remove(); | 338 optgroup->remove(); |
339 EXPECT_EQ(String(), option->defaultToolTip()); | 339 EXPECT_EQ(String(), option->defaultToolTip()); |
340 EXPECT_EQ(String(), optgroup->defaultToolTip()); | 340 EXPECT_EQ(String(), optgroup->defaultToolTip()); |
341 } | 341 } |
342 | 342 |
343 } // namespace blink | 343 } // namespace blink |
OLD | NEW |