Fix message of NotSupportedError exception thrown during custom element creation
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jul 2018 10:19:29 +0000 (10:19 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jul 2018 10:19:29 +0000 (10:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187757

Patch by Frederic Wang <fwang@igalia.com> on 2018-07-19
Reviewed by Yusuke Suzuki.

Source/WebCore:

In bug 161528, some new exceptions were introduced for custom element creation [1] but the
actual text has some issues. This patch fixes one typo and one wrong message.

[1] https://dom.spec.whatwg.org/#concept-create-element

Test: fast/custom-elements/exceptions-for-synchronous-custom-element-creation.html

* bindings/js/JSCustomElementInterface.cpp:
(WebCore::constructCustomElementSynchronously):

LayoutTests:

* fast/custom-elements/exceptions-for-synchronous-custom-element-creation-expected.txt: Added.
* fast/custom-elements/exceptions-for-synchronous-custom-element-creation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233980 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/custom-elements/exceptions-for-synchronous-custom-element-creation-expected.txt [new file with mode: 0644]
LayoutTests/fast/custom-elements/exceptions-for-synchronous-custom-element-creation.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSCustomElementInterface.cpp

index bb5d52e..0d1c7b8 100644 (file)
@@ -1,3 +1,13 @@
+2018-07-19  Frederic Wang  <fwang@igalia.com>
+
+        Fix message of NotSupportedError exception thrown during custom element creation
+        https://bugs.webkit.org/show_bug.cgi?id=187757
+
+        Reviewed by Yusuke Suzuki.
+
+        * fast/custom-elements/exceptions-for-synchronous-custom-element-creation-expected.txt: Added.
+        * fast/custom-elements/exceptions-for-synchronous-custom-element-creation.html: Added.
+
 2018-07-18  Ryan Haddad  <ryanhaddad@apple.com>
 
         Rebaseline fast/css/apple-system-colors.html.
diff --git a/LayoutTests/fast/custom-elements/exceptions-for-synchronous-custom-element-creation-expected.txt b/LayoutTests/fast/custom-elements/exceptions-for-synchronous-custom-element-creation-expected.txt
new file mode 100644 (file)
index 0000000..d7e3587
--- /dev/null
@@ -0,0 +1,7 @@
+CONSOLE MESSAGE: line 18: TypeError: The result of constructing a custom element must be a HTMLElement
+CONSOLE MESSAGE: line 28: NotSupportedError: A newly constructed custom element must not have attributes
+CONSOLE MESSAGE: line 38: NotSupportedError: A newly constructed custom element must not have child nodes
+CONSOLE MESSAGE: line 48: NotSupportedError: A newly constructed custom element must not have a parent node
+CONSOLE MESSAGE: line 59: NotSupportedError: A newly constructed custom element belongs to a wrong document
+CONSOLE MESSAGE: line 69: NotSupportedError: A newly constructed custom element has incorrect local name
+
diff --git a/LayoutTests/fast/custom-elements/exceptions-for-synchronous-custom-element-creation.html b/LayoutTests/fast/custom-elements/exceptions-for-synchronous-custom-element-creation.html
new file mode 100644 (file)
index 0000000..e69fa5b
--- /dev/null
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Exceptions for synchronous custom element creation</title>
+  </head>
+  <body>
+    <script>
+      if (testRunner)
+        testRunner.dumpAsText();
+
+      class ObjectCustomElement extends HTMLElement {
+        constructor()
+        {
+          return {foo: 'bar'};
+        }
+      };
+      customElements.define('object-custom-element', ObjectCustomElement);
+      document.createElement('object-custom-element');
+
+      class ElementWithAttribute extends HTMLElement {
+        constructor()
+        {
+          super();
+          this.setAttribute('id', 'foo');
+        }
+      };
+      customElements.define('element-with-attribute', ElementWithAttribute);
+      document.createElement('element-with-attribute');
+
+      class ElementWithChildText extends HTMLElement {
+        constructor()
+        {
+          super();
+          this.appendChild(document.createTextNode('hello'));
+        }
+      };
+      customElements.define('element-with-child-text', ElementWithChildText);
+      document.createElement('element-with-child-text');
+
+      class ElementWithParent extends HTMLElement {
+        constructor()
+        {
+          super();
+          document.createElement('div').appendChild(this);
+        }
+      };
+      customElements.define('element-with-parent', ElementWithParent);
+      document.createElement('element-with-parent');
+
+      var otherDoc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
+      class ElementWithAdoptCall extends HTMLElement {
+      constructor()
+        {
+          super();
+          otherDoc.adoptNode(this);
+        }
+      };
+      customElements.define('element-with-adopt-call', ElementWithAdoptCall);
+      document.createElement('element-with-adopt-call');
+
+      class DivCustomElement extends HTMLElement {
+        constructor()
+        {
+          super();
+          return document.createElement('div');
+        }
+      };
+      customElements.define('div-custom-element', DivCustomElement);
+      document.createElement('div-custom-element');
+    </script>
+  </body>
+</html>
index 4aba988..bf1b08d 100644 (file)
@@ -1,3 +1,20 @@
+2018-07-19  Frederic Wang  <fwang@igalia.com>
+
+        Fix message of NotSupportedError exception thrown during custom element creation
+        https://bugs.webkit.org/show_bug.cgi?id=187757
+
+        Reviewed by Yusuke Suzuki.
+
+        In bug 161528, some new exceptions were introduced for custom element creation [1] but the
+        actual text has some issues. This patch fixes one typo and one wrong message.
+
+        [1] https://dom.spec.whatwg.org/#concept-create-element
+
+        Test: fast/custom-elements/exceptions-for-synchronous-custom-element-creation.html
+
+        * bindings/js/JSCustomElementInterface.cpp:
+        (WebCore::constructCustomElementSynchronously):
+
 2018-07-18  Jer Noble  <jer.noble@apple.com>
 
         Unreviewed API Test fix; restored a line inadventantly removed in r233926.
index 4beffad..f10815f 100644 (file)
@@ -151,12 +151,12 @@ static RefPtr<Element> constructCustomElementSynchronously(Document& document, V
         return nullptr;
     }
     if (&wrappedElement->document() != &document) {
-        throwNotSupportedError(state, scope, "A newly constructed custom element belongs to a wrong docuemnt"_s);
+        throwNotSupportedError(state, scope, "A newly constructed custom element belongs to a wrong document"_s);
         return nullptr;
     }
     ASSERT(wrappedElement->namespaceURI() == HTMLNames::xhtmlNamespaceURI);
     if (wrappedElement->localName() != localName) {
-        throwNotSupportedError(state, scope, "A newly constructed custom element belongs to a wrong docuemnt"_s);
+        throwNotSupportedError(state, scope, "A newly constructed custom element has incorrect local name"_s);
         return nullptr;
     }