Commit 6da4c2a3 authored by ch.dumez@samsung.com's avatar ch.dumez@samsung.com

Make HTMLAnchorElement.text getter behave according to specification

Make HTMLAnchorElement.text getter behave according to specification:
http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#dom-a-text

According to the specification, the 'text' IDL attribute, on getting, must
return the same value as the textContent IDL attribute on the element. However,
Chromium was returning 'innerText' instead. Upon setting, Chromium was
correctly updating the 'textContent' attribute though.

The new behavior is consistent with Firefox 29 and IE11.

This CL is based on arv's comment at:
https://codereview.chromium.org/263353004/#msg2

R=arv@chromium.org, tkent@chromium.org
BUG=369950
TEST=fast/dom/HTMLAnchorElement/get-text.html

Review URL: https://codereview.chromium.org/272693002

git-svn-id: svn://svn.chromium.org/blink/trunk@173579 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2e808a77
Tests that HTMLAnchorElement.text returns the same value as the textContent attribute.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS a.__proto__ is HTMLAnchorElement.prototype
PASS a.text is "ab"
PASS a.textContent is "ab"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#dom-a-text">
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<script>
description("Tests that HTMLAnchorElement.text returns the same value as the textContent attribute.");
var div = document.createElement('div');
div.innerHTML = '<a>a<br>b</a>';
var a = div.firstChild;
shouldBe("a.__proto__", "HTMLAnchorElement.prototype");
shouldBeEqualToString('a.text', 'ab');
shouldBeEqualToString('a.textContent', 'ab');
</script>
</body>
</html>
......@@ -337,16 +337,6 @@ AtomicString HTMLAnchorElement::target() const
return getAttribute(targetAttr);
}
void HTMLAnchorElement::setText(const String& text)
{
setTextContent(text);
}
String HTMLAnchorElement::text()
{
return innerText();
}
bool HTMLAnchorElement::isLiveLink() const
{
return isLink() && !rendererIsEditable();
......
......@@ -71,9 +71,6 @@ public:
virtual String input() const OVERRIDE FINAL;
virtual void setInput(const String&) OVERRIDE FINAL;
String text();
void setText(const String&);
bool isLiveLink() const;
virtual bool willRespondToMouseClickEvents() OVERRIDE FINAL;
......
......@@ -31,7 +31,7 @@ interface HTMLAnchorElement : HTMLElement {
[Reflect] attribute DOMString target;
[Reflect] attribute DOMString type;
attribute DOMString text;
[ImplementedAs=textContent] attribute DOMString text;
[Reflect, RuntimeEnabled=SubresourceIntegrity] attribute DOMString integrity;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment