Title: [189842] trunk
Revision
189842
Author
cdu...@apple.com
Date
2015-09-15 20:36:55 -0700 (Tue, 15 Sep 2015)

Log Message

Document.createElement(localName) does not handle correctly missing or null parameter
https://bugs.webkit.org/show_bug.cgi?id=149184
<rdar://problem/22565070>

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline several W3C tests now that more checks are passing.

* web-platform-tests/dom/interfaces-expected.txt:
* web-platform-tests/dom/nodes/Document-createElement-expected.txt:
* web-platform-tests/html/dom/interfaces-expected.txt:

Source/WebCore:

Document.createElement(localName) does not handle correct missing or
null parameter:
- https://dom.spec.whatwg.org/#interface-document

As per the specification, the parameter is a non-nullable DOMString and
is mandatory. Therefore, as per Web IDL, we should have the following
behavior:
1. If the parameter is missing, we should throw an exception
2. If the parameter is null, we should convert it to the "null" string
   and create a <null> element.

Chrome and Firefox behave according to the specification. However,
WebKit was doing:
1. Create a <undefined> element
2. Throw an InvalidCharacterError

This patch aligns WebKit's behavior with the specification and other
major browsers.

No new tests, already covered by existing tests.

* dom/Document.idl:

LayoutTests:

Update / rebaseline existing tests now that our behavior has changed.

* fast/dom/Document/createElementNS-namespace-err-expected.txt:
* fast/dom/Document/script-tests/createElementNS-namespace-err.js:
* fast/dom/dom-method-document-change.html:
* fast/dom/element-removed-while-inserting-parent-crash.html:
* fast/inspector-support/uncaught-dom3-exception-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (189841 => 189842)


--- trunk/LayoutTests/ChangeLog	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/ChangeLog	2015-09-16 03:36:55 UTC (rev 189842)
@@ -1,3 +1,19 @@
+2015-09-15  Chris Dumez  <cdu...@apple.com>
+
+        Document.createElement(localName) does not handle correctly missing or null parameter
+        https://bugs.webkit.org/show_bug.cgi?id=149184
+        <rdar://problem/22565070>
+
+        Reviewed by Ryosuke Niwa.
+
+        Update / rebaseline existing tests now that our behavior has changed.
+
+        * fast/dom/Document/createElementNS-namespace-err-expected.txt:
+        * fast/dom/Document/script-tests/createElementNS-namespace-err.js:
+        * fast/dom/dom-method-document-change.html:
+        * fast/dom/element-removed-while-inserting-parent-crash.html:
+        * fast/inspector-support/uncaught-dom3-exception-expected.txt:
+
 2015-09-15  Ryosuke Niwa  <rn...@webkit.org>
 
         Add ShadowRoot interface and Element.prototype.attachShadow

Modified: trunk/LayoutTests/fast/dom/Document/createElementNS-namespace-err-expected.txt (189841 => 189842)


--- trunk/LayoutTests/fast/dom/Document/createElementNS-namespace-err-expected.txt	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/fast/dom/Document/createElementNS-namespace-err-expected.txt	2015-09-16 03:36:55 UTC (rev 189842)
@@ -47,7 +47,7 @@
 PASS createElementNS("http://www.w3.org/XML/1998/namespace", "xml:test")
 PASS createElementNS("http://www.w3.org/XML/1998/namespace", "x:test")
 PASS createElement()
-PASS createElement(null); threw INVALID_CHARACTER_ERR
+PASS createElement(null)
 PASS createElement(""); threw INVALID_CHARACTER_ERR
 PASS createElement("<div>"); threw INVALID_CHARACTER_ERR
 PASS createElement("0div"); threw INVALID_CHARACTER_ERR
@@ -76,7 +76,7 @@
 PASS createElement("SOAP-ENV:Body")
 XHTML createElement tests:
 PASS createElement()
-PASS createElement(null); threw INVALID_CHARACTER_ERR
+PASS createElement(null)
 PASS createElement(""); threw INVALID_CHARACTER_ERR
 PASS createElement("<div>"); threw INVALID_CHARACTER_ERR
 PASS createElement("0div"); threw INVALID_CHARACTER_ERR
@@ -105,7 +105,7 @@
 PASS createElement("SOAP-ENV:Body")
 XML createElement tests:
 PASS createElement()
-PASS createElement(null); threw INVALID_CHARACTER_ERR
+PASS createElement(null)
 PASS createElement(""); threw INVALID_CHARACTER_ERR
 PASS createElement("<div>"); threw INVALID_CHARACTER_ERR
 PASS createElement("0div"); threw INVALID_CHARACTER_ERR

Modified: trunk/LayoutTests/fast/dom/Document/script-tests/createElementNS-namespace-err.js (189841 => 189842)


--- trunk/LayoutTests/fast/dom/Document/script-tests/createElementNS-namespace-err.js	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/fast/dom/Document/script-tests/createElementNS-namespace-err.js	2015-09-16 03:36:55 UTC (rev 189842)
@@ -86,7 +86,7 @@
 
 var allNoNSTests = [
    { args: [undefined] },
-   { args: [null], code: 5 },
+   { args: [null] },
    { args: [""], code: 5 },
    { args: ["<div>"], code: 5 },
    { args: ["0div"], code: 5 },

Modified: trunk/LayoutTests/fast/dom/dom-method-document-change.html (189841 => 189842)


--- trunk/LayoutTests/fast/dom/dom-method-document-change.html	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/fast/dom/dom-method-document-change.html	2015-09-16 03:36:55 UTC (rev 189842)
@@ -17,11 +17,11 @@
 
 window._onload_ = function()
 {
-    element1 = document.createElement();
-    element2 = document.createElement();
-    element3 = document.createElement();
-    parent   = document.createElement();
-    dummy    = document.createElement();
+    element1 = document.createElement(undefined);
+    element2 = document.createElement(undefined);
+    element3 = document.createElement(undefined);
+    parent   = document.createElement(undefined);
+    dummy    = document.createElement(undefined);
     
     doc = document.implementation.createHTMLDocument();
     

Modified: trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html (189841 => 189842)


--- trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/fast/dom/element-removed-while-inserting-parent-crash.html	2015-09-16 03:36:55 UTC (rev 189842)
@@ -5,7 +5,7 @@
 if (window.testRunner)
     testRunner.dumpAsText();
 
-var element = document.createElement();
+var element = document.createElement('p');
 
 var script = document.createElement('script');
 script.textContent = 'document.currentScript.nextSibling.remove()';

Modified: trunk/LayoutTests/fast/dom/node-iterator-reference-node-moved-crash.html (189841 => 189842)


--- trunk/LayoutTests/fast/dom/node-iterator-reference-node-moved-crash.html	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/fast/dom/node-iterator-reference-node-moved-crash.html	2015-09-16 03:36:55 UTC (rev 189842)
@@ -18,9 +18,9 @@
             
             function runTest()
             {
-                iteratorRoot = document.createElement();
-                element = iteratorRoot.appendChild(document.createElement());
-                element.appendChild(document.createElement());
+                iteratorRoot = document.createElement('p');
+                element = iteratorRoot.appendChild(document.createElement('p'));
+                element.appendChild(document.createElement('p'));
   
                 iterator = document.createNodeIterator(iteratorRoot, -1);
                 iterator.nextNode(); iterator.nextNode(); iterator.nextNode();

Modified: trunk/LayoutTests/fast/inspector-support/uncaught-dom3-exception.html (189841 => 189842)


--- trunk/LayoutTests/fast/inspector-support/uncaught-dom3-exception.html	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/fast/inspector-support/uncaught-dom3-exception.html	2015-09-16 03:36:55 UTC (rev 189842)
@@ -6,7 +6,7 @@
 {
     if (window.testRunner)
         testRunner.dumpAsText();
-    document.appendChild(document.createElement());
+    document.appendChild(document.createElement("p"));
 }
 
 </script>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (189841 => 189842)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2015-09-16 03:36:55 UTC (rev 189842)
@@ -1,5 +1,19 @@
 2015-09-15  Chris Dumez  <cdu...@apple.com>
 
+        Document.createElement(localName) does not handle correctly missing or null parameter
+        https://bugs.webkit.org/show_bug.cgi?id=149184
+        <rdar://problem/22565070>
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline several W3C tests now that more checks are passing.
+
+        * web-platform-tests/dom/interfaces-expected.txt:
+        * web-platform-tests/dom/nodes/Document-createElement-expected.txt:
+        * web-platform-tests/html/dom/interfaces-expected.txt:
+
+2015-09-15  Chris Dumez  <cdu...@apple.com>
+
         new Event() without parameter should throw
         https://bugs.webkit.org/show_bug.cgi?id=149146
         <rdar://problem/22565070>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt (189841 => 189842)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2015-09-16 03:36:55 UTC (rev 189842)
@@ -443,7 +443,7 @@
 FAIL Document interface: operation getElementsByTagName(DOMString) assert_equals: property has wrong .length expected 1 but got 0
 FAIL Document interface: operation getElementsByTagNameNS(DOMString,DOMString) assert_equals: property has wrong .length expected 2 but got 0
 FAIL Document interface: operation getElementsByClassName(DOMString) assert_equals: property has wrong .length expected 1 but got 0
-FAIL Document interface: operation createElement(DOMString) assert_equals: property has wrong .length expected 1 but got 0
+PASS Document interface: operation createElement(DOMString) 
 FAIL Document interface: operation createElementNS(DOMString,DOMString) assert_equals: property has wrong .length expected 2 but got 0
 PASS Document interface: operation createDocumentFragment() 
 FAIL Document interface: operation createTextNode(DOMString) assert_equals: property has wrong .length expected 1 but got 0
@@ -507,9 +507,7 @@
     [native code]
 }" did not throw
 PASS Document interface: xmlDoc must inherit property "createElement" with the proper type (13) 
-FAIL Document interface: calling createElement(DOMString) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-    [native code]
-}" did not throw
+PASS Document interface: calling createElement(DOMString) on xmlDoc with too few arguments must throw TypeError 
 PASS Document interface: xmlDoc must inherit property "createElementNS" with the proper type (14) 
 FAIL Document interface: calling createElementNS(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
     [native code]

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-expected.txt (189841 => 189842)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-expected.txt	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElement-expected.txt	2015-09-16 03:36:55 UTC (rev 189842)
@@ -1,7 +1,7 @@
 
 PASS Document.createElement 
 PASS createElement(undefined) 
-FAIL createElement(null) InvalidCharacterError: DOM Exception 5
+PASS createElement(null) 
 PASS createElement("foo") 
 PASS createElement("f1oo") 
 PASS createElement("foo1") 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt (189841 => 189842)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2015-09-16 03:36:55 UTC (rev 189842)
@@ -949,9 +949,7 @@
     [native code]
 }" did not throw
 PASS Document interface: iframe.contentDocument must inherit property "createElement" with the proper type (13) 
-FAIL Document interface: calling createElement(DOMString) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-    [native code]
-}" did not throw
+PASS Document interface: calling createElement(DOMString) on iframe.contentDocument with too few arguments must throw TypeError 
 PASS Document interface: iframe.contentDocument must inherit property "createElementNS" with the proper type (14) 
 FAIL Document interface: calling createElementNS(DOMString,DOMString) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
     [native code]
@@ -1273,9 +1271,7 @@
     [native code]
 }" did not throw
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "createElement" with the proper type (13) 
-FAIL Document interface: calling createElement(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-    [native code]
-}" did not throw
+PASS Document interface: calling createElement(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError 
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "createElementNS" with the proper type (14) 
 FAIL Document interface: calling createElementNS(DOMString,DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
     [native code]

Modified: trunk/LayoutTests/svg/dom/vkern-element-crash.html (189841 => 189842)


--- trunk/LayoutTests/svg/dom/vkern-element-crash.html	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/LayoutTests/svg/dom/vkern-element-crash.html	2015-09-16 03:36:55 UTC (rev 189842)
@@ -17,15 +17,15 @@
 
 window._onload_ = function()
 {   
-    element1 = document.body.appendChild(document.createElement());
+    element1 = document.body.appendChild(document.createElement(undefined));
     element1.id = "foo";
     
     parent = document.createElementNS("http://www.w3.org/2000/svg", "vkern");
-    element2 = parent.appendChild(document.createElement());
+    element2 = parent.appendChild(document.createElement(undefined));
     element2.id = "foo";
     document.body.appendChild(parent);
     
-    element3 = document.body.appendChild(document.createElement());
+    element3 = document.body.appendChild(document.createElement(undefined));
     element3.id = "foo";
     
     document.body.removeChild(element1);

Modified: trunk/Source/WebCore/ChangeLog (189841 => 189842)


--- trunk/Source/WebCore/ChangeLog	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/Source/WebCore/ChangeLog	2015-09-16 03:36:55 UTC (rev 189842)
@@ -1,3 +1,34 @@
+2015-09-15  Chris Dumez  <cdu...@apple.com>
+
+        Document.createElement(localName) does not handle correctly missing or null parameter
+        https://bugs.webkit.org/show_bug.cgi?id=149184
+        <rdar://problem/22565070>
+
+        Reviewed by Ryosuke Niwa.
+
+        Document.createElement(localName) does not handle correct missing or
+        null parameter:
+        - https://dom.spec.whatwg.org/#interface-document
+
+        As per the specification, the parameter is a non-nullable DOMString and
+        is mandatory. Therefore, as per Web IDL, we should have the following
+        behavior:
+        1. If the parameter is missing, we should throw an exception
+        2. If the parameter is null, we should convert it to the "null" string
+           and create a <null> element.
+
+        Chrome and Firefox behave according to the specification. However,
+        WebKit was doing:
+        1. Create a <undefined> element
+        2. Throw an InvalidCharacterError
+
+        This patch aligns WebKit's behavior with the specification and other
+        major browsers.
+
+        No new tests, already covered by existing tests.
+
+        * dom/Document.idl:
+
 2015-09-15  Ryosuke Niwa  <rn...@webkit.org>
 
         Add ShadowRoot interface and Element.prototype.attachShadow

Modified: trunk/Source/WebCore/dom/Document.idl (189841 => 189842)


--- trunk/Source/WebCore/dom/Document.idl	2015-09-16 02:40:53 UTC (rev 189841)
+++ trunk/Source/WebCore/dom/Document.idl	2015-09-16 03:36:55 UTC (rev 189842)
@@ -31,7 +31,7 @@
     readonly attribute DOMImplementation implementation;
     readonly attribute Element documentElement;
 
-    [ReturnNewObject, RaisesException] Element createElement([TreatNullAs=NullString,Default=Undefined] optional DOMString tagName);
+    [ReturnNewObject, RaisesException] Element createElement(DOMString tagName);
     DocumentFragment   createDocumentFragment();
     [ReturnNewObject] Text createTextNode([Default=Undefined] optional DOMString data);
     [ReturnNewObject] Comment createComment([Default=Undefined] optional DOMString data);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to