Align HTMLKeygenElement.keytype with the specification
https://bugs.webkit.org/show_bug.cgi?id=155214

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline now that more checks are passing.

* web-platform-tests/html/dom/reflection-forms-expected.txt:

Source/WebCore:

Align HTMLKeygenElement.keytype with the specification:
- https://html.spec.whatwg.org/#dom-keygen-keytype
- https://html.spec.whatwg.org/#attr-keygen-keytype

In particular, the following changes were made:
1. Return "rsa" by default (i.e. when the corresponding content attribute is missing)
2. Only return known values

Test: fast/dom/HTMLKeygenElement/keygen-keytype.html

* html/HTMLKeygenElement.cpp:
(WebCore::HTMLKeygenElement::setKeytype):
(WebCore::HTMLKeygenElement::keytype):
(WebCore::HTMLKeygenElement::appendFormData):
* html/HTMLKeygenElement.h:
* html/HTMLKeygenElement.idl:

LayoutTests:

Add test coverage for HTMLKeygenElement.keytype.

* fast/dom/HTMLKeygenElement/keygen-keytype-expected.txt: Added.
* fast/dom/HTMLKeygenElement/keygen-keytype.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@197864 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/html/HTMLKeygenElement.cpp b/Source/WebCore/html/HTMLKeygenElement.cpp
index 4828dc2..f61c99b 100644
--- a/Source/WebCore/html/HTMLKeygenElement.cpp
+++ b/Source/WebCore/html/HTMLKeygenElement.cpp
@@ -98,11 +98,26 @@
     HTMLFormControlElement::parseAttribute(name, value);
 }
 
+bool HTMLKeygenElement::isKeytypeRSA() const
+{
+    const auto& keyType = fastGetAttribute(keytypeAttr);
+    return keyType.isNull() || equalLettersIgnoringASCIICase(keyType, "rsa");
+}
+
+void HTMLKeygenElement::setKeytype(const AtomicString& value)
+{
+    setAttributeWithoutSynchronization(keytypeAttr, value);
+}
+
+String HTMLKeygenElement::keytype() const
+{
+    return isKeytypeRSA() ? ASCIILiteral("rsa") : emptyString();
+}
+
 bool HTMLKeygenElement::appendFormData(FormDataList& encoded_values, bool)
 {
     // Only RSA is supported at this time.
-    const AtomicString& keyType = fastGetAttribute(keytypeAttr);
-    if (!keyType.isNull() && !equalLettersIgnoringASCIICase(keyType, "rsa"))
+    if (!isKeytypeRSA())
         return false;
     String value = signedPublicKeyAndChallengeString(shadowSelect()->selectedIndex(), fastGetAttribute(challengeAttr), document().baseURL());
     if (value.isNull())