Title: [203701] trunk
Revision
203701
Author
[email protected]
Date
2016-07-25 14:53:33 -0700 (Mon, 25 Jul 2016)

Log Message

Parameters to DOMImplementation.createDocumentType() should be mandatory and non-nullable
https://bugs.webkit.org/show_bug.cgi?id=160167

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline a W3C test now that more checks are passing.

* web-platform-tests/dom/interfaces-expected.txt:

Source/WebCore:

Parameters to DOMImplementation.createDocumentType() should be mandatory
and non-nullable:
- https://dom.spec.whatwg.org/#domimplementation

Firefox and Chrome both agree with the specification. However, those
parameters were nullable and optional in WebKit.

Test: fast/dom/DOMImplementation/createDocumentType-parameters.html

* dom/DOMImplementation.idl:

LayoutTests:

* editing/selection/script-tests/DOMSelection-DocumentType.js:
* fast/dom/DOMImplementation/createDocumentType-err-expected.txt:
* fast/dom/DOMImplementation/script-tests/createDocumentType-err.js:
Update existing tests to reflect the behavior change.

* fast/dom/DOMImplementation/createDocumentType-parameters-expected.txt: Added.
* fast/dom/DOMImplementation/createDocumentType-parameters.html: Added.
Add layout test coverage. I have verified that this test passes on both
Firefox and Chrome.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203700 => 203701)


--- trunk/LayoutTests/ChangeLog	2016-07-25 21:38:42 UTC (rev 203700)
+++ trunk/LayoutTests/ChangeLog	2016-07-25 21:53:33 UTC (rev 203701)
@@ -1,3 +1,20 @@
+2016-07-25  Chris Dumez  <[email protected]>
+
+        Parameters to DOMImplementation.createDocumentType() should be mandatory and non-nullable
+        https://bugs.webkit.org/show_bug.cgi?id=160167
+
+        Reviewed by Ryosuke Niwa.
+
+        * editing/selection/script-tests/DOMSelection-DocumentType.js:
+        * fast/dom/DOMImplementation/createDocumentType-err-expected.txt:
+        * fast/dom/DOMImplementation/script-tests/createDocumentType-err.js:
+        Update existing tests to reflect the behavior change.
+
+        * fast/dom/DOMImplementation/createDocumentType-parameters-expected.txt: Added.
+        * fast/dom/DOMImplementation/createDocumentType-parameters.html: Added.
+        Add layout test coverage. I have verified that this test passes on both
+        Firefox and Chrome.
+
 2016-07-25  Jiewen Tan  <[email protected]>
 
         Rename SubtleCrypto to WebKitSubtleCrypto

Modified: trunk/LayoutTests/editing/selection/script-tests/DOMSelection-DocumentType.js (203700 => 203701)


--- trunk/LayoutTests/editing/selection/script-tests/DOMSelection-DocumentType.js	2016-07-25 21:38:42 UTC (rev 203700)
+++ trunk/LayoutTests/editing/selection/script-tests/DOMSelection-DocumentType.js	2016-07-25 21:53:33 UTC (rev 203701)
@@ -1,7 +1,7 @@
 description("Test to check if setBaseAndExtent guard node with null owner document (Bug 31680)");
 
 var sel = window.getSelection();
-var docType = document.implementation.createDocumentType('c');
+var docType = document.implementation.createDocumentType('c', '', '');
 
 sel.setBaseAndExtent(docType);
 shouldBeNull("sel.anchorNode");

Modified: trunk/LayoutTests/fast/dom/DOMImplementation/createDocumentType-err-expected.txt (203700 => 203701)


--- trunk/LayoutTests/fast/dom/DOMImplementation/createDocumentType-err-expected.txt	2016-07-25 21:38:42 UTC (rev 203700)
+++ trunk/LayoutTests/fast/dom/DOMImplementation/createDocumentType-err-expected.txt	2016-07-25 21:53:33 UTC (rev 203701)
@@ -3,17 +3,17 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS document.implementation.createDocumentType('foo').toString() is "[object DocumentType]"
-PASS document.implementation.createDocumentType('foo', null).toString() is "[object DocumentType]"
-PASS createDocumentType(, ); threw INVALID_CHARACTER_ERR
-PASS createDocumentType(null, ); threw INVALID_CHARACTER_ERR
-PASS createDocumentType(, null); threw INVALID_CHARACTER_ERR
-PASS createDocumentType(, , null); threw INVALID_CHARACTER_ERR
-PASS createDocumentType(null, null); threw INVALID_CHARACTER_ERR
-PASS createDocumentType(null, null, null); threw INVALID_CHARACTER_ERR
-PASS createDocumentType(null, ""); threw INVALID_CHARACTER_ERR
-PASS createDocumentType("", null); threw INVALID_CHARACTER_ERR
-PASS createDocumentType("", ""); threw INVALID_CHARACTER_ERR
+PASS document.implementation.createDocumentType('foo') threw exception TypeError: Not enough arguments.
+PASS document.implementation.createDocumentType('foo', null) threw exception TypeError: Not enough arguments.
+PASS exceptionThrown.name is "TypeError"
+PASS exceptionThrown.name is "TypeError"
+PASS exceptionThrown.name is "TypeError"
+PASS createDocumentType(, , null)
+PASS exceptionThrown.name is "TypeError"
+PASS createDocumentType(null, null, null)
+PASS exceptionThrown.name is "TypeError"
+PASS exceptionThrown.name is "TypeError"
+PASS exceptionThrown.name is "TypeError"
 PASS createDocumentType("a:", null, null); threw NAMESPACE_ERR
 PASS createDocumentType(":foo", null, null); threw NAMESPACE_ERR
 PASS createDocumentType(":", null, null); threw NAMESPACE_ERR

Added: trunk/LayoutTests/fast/dom/DOMImplementation/createDocumentType-parameters-expected.txt (0 => 203701)


--- trunk/LayoutTests/fast/dom/DOMImplementation/createDocumentType-parameters-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/DOMImplementation/createDocumentType-parameters-expected.txt	2016-07-25 21:53:33 UTC (rev 203701)
@@ -0,0 +1,17 @@
+Test that the parameters to DOMImplementation.createDocumentType() are mandatory and non-nullable
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.implementation.createDocumentType() threw exception TypeError: Not enough arguments.
+PASS document.implementation.createDocumentType('a') threw exception TypeError: Not enough arguments.
+PASS document.implementation.createDocumentType('a', '') threw exception TypeError: Not enough arguments.
+PASS docType = document.implementation.createDocumentType(null, null, null) did not throw exception.
+PASS docType.name is "null"
+PASS docType.nodeName is "null"
+PASS docType.publicId is "null"
+PASS docType.systemId is "null"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/DOMImplementation/createDocumentType-parameters.html (0 => 203701)


--- trunk/LayoutTests/fast/dom/DOMImplementation/createDocumentType-parameters.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/DOMImplementation/createDocumentType-parameters.html	2016-07-25 21:53:33 UTC (rev 203701)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Test that the parameters to DOMImplementation.createDocumentType() are mandatory and non-nullable");
+
+// Parameters should be mandatory.
+shouldThrow("document.implementation.createDocumentType()");
+shouldThrow("document.implementation.createDocumentType('a')");
+shouldThrow("document.implementation.createDocumentType('a', '')");
+
+// Parameters should not be nullable.
+shouldNotThrow("docType = document.implementation.createDocumentType(null, null, null)");
+shouldBeEqualToString("docType.name", "null");
+shouldBeEqualToString("docType.nodeName", "null");
+shouldBeEqualToString("docType.publicId", "null");
+shouldBeEqualToString("docType.systemId", "null");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/fast/dom/DOMImplementation/script-tests/createDocumentType-err.js (203700 => 203701)


--- trunk/LayoutTests/fast/dom/DOMImplementation/script-tests/createDocumentType-err.js	2016-07-25 21:38:42 UTC (rev 203700)
+++ trunk/LayoutTests/fast/dom/DOMImplementation/script-tests/createDocumentType-err.js	2016-07-25 21:53:33 UTC (rev 203701)
@@ -27,15 +27,15 @@
 }
 
 var allTests = [
-   { args: [undefined, undefined], code: 5  },
-   { args: [null, undefined], code: 5  },
-   { args: [undefined, null], code: 5 },
-   { args: [undefined, undefined, null], code: 5 },
-   { args: [null, null], code: 5 },
-   { args: [null, null, null], code: 5 },
-   { args: [null, ""], code: 5 },
-   { args: ["", null], code: 5 },
-   { args: ["", ""], code: 5 },
+   { args: [undefined, undefined], name: "TypeError" },
+   { args: [null, undefined], name: "TypeError"  },
+   { args: [undefined, null], name: "TypeError" },
+   { args: [undefined, undefined, null] },
+   { args: [null, null], name: "TypeError" },
+   { args: [null, null, null] },
+   { args: [null, ""], name: "TypeError" },
+   { args: ["", null], name: "TypeError" },
+   { args: ["", ""], name: "TypeError" },
    { args: ["a:", null, null], code: 14 },
    { args: [":foo", null, null], code: 14 },
    { args: [":", null, null], code: 14 },
@@ -84,15 +84,20 @@
             document.implementation[createFunctionName].apply(document.implementation, test.args);
             if ('code' in test)
                 testFailed(msg + " expected exception: " + test.code);
+            else if ('name' in test)
+                testFailed(msg + " expected exception: " + test.name);
             else
                 testPassed(msg);
         } catch (e) {
-            assertEquals(e.code, test.code || "expected no exception", msg);
+            exceptionThrown = e;
+            if ('name' in test) {
+                shouldBeEqualToString("exceptionThrown.name", "" + test.name);
+            } else
+                assertEquals(e.code, test.code || "expected no exception", msg);
         }
     }
 }
 
-// Moz throws a "Not enough arguments" exception in these, we don't:
-shouldBeEqualToString("document.implementation.createDocumentType('foo').toString()", "[object DocumentType]");
-shouldBeEqualToString("document.implementation.createDocumentType('foo', null).toString()", "[object DocumentType]");
+shouldThrow("document.implementation.createDocumentType('foo')");
+shouldThrow("document.implementation.createDocumentType('foo', null)");
 runTests(allTests, "createDocumentType");

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (203700 => 203701)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-25 21:38:42 UTC (rev 203700)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-25 21:53:33 UTC (rev 203701)
@@ -1,3 +1,14 @@
+2016-07-25  Chris Dumez  <[email protected]>
+
+        Parameters to DOMImplementation.createDocumentType() should be mandatory and non-nullable
+        https://bugs.webkit.org/show_bug.cgi?id=160167
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline a W3C test now that more checks are passing.
+
+        * web-platform-tests/dom/interfaces-expected.txt:
+
 2016-07-24  Youenn Fablet  <[email protected]>
 
         [Fetch API] Request should be created with any HeadersInit data

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2016-07-25 21:38:42 UTC (rev 203700)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2016-07-25 21:53:33 UTC (rev 203701)
@@ -533,7 +533,7 @@
 PASS DOMImplementation interface object name 
 PASS DOMImplementation interface: existence and properties of interface prototype object 
 PASS DOMImplementation interface: existence and properties of interface prototype object's "constructor" property 
-FAIL DOMImplementation interface: operation createDocumentType(DOMString,DOMString,DOMString) assert_equals: property has wrong .length expected 3 but got 0
+PASS DOMImplementation interface: operation createDocumentType(DOMString,DOMString,DOMString) 
 PASS DOMImplementation interface: operation createDocument(DOMString,DOMString,DocumentType) 
 PASS DOMImplementation interface: operation createHTMLDocument(DOMString) 
 PASS DOMImplementation interface: operation hasFeature() 
@@ -540,9 +540,7 @@
 PASS DOMImplementation must be primary interface of document.implementation 
 PASS Stringification of document.implementation 
 PASS DOMImplementation interface: document.implementation must inherit property "createDocumentType" with the proper type (0) 
-FAIL DOMImplementation interface: calling createDocumentType(DOMString,DOMString,DOMString) on document.implementation with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" threw object "InvalidCharacterError (DOM Exception 5): The string conta..." ("InvalidCharacterError") expected object "TypeError" ("TypeError")
+PASS DOMImplementation interface: calling createDocumentType(DOMString,DOMString,DOMString) on document.implementation with too few arguments must throw TypeError 
 PASS DOMImplementation interface: document.implementation must inherit property "createDocument" with the proper type (1) 
 PASS DOMImplementation interface: calling createDocument(DOMString,DOMString,DocumentType) on document.implementation with too few arguments must throw TypeError 
 PASS DOMImplementation interface: document.implementation must inherit property "createHTMLDocument" with the proper type (2) 

Modified: trunk/Source/WebCore/ChangeLog (203700 => 203701)


--- trunk/Source/WebCore/ChangeLog	2016-07-25 21:38:42 UTC (rev 203700)
+++ trunk/Source/WebCore/ChangeLog	2016-07-25 21:53:33 UTC (rev 203701)
@@ -1,3 +1,21 @@
+2016-07-25  Chris Dumez  <[email protected]>
+
+        Parameters to DOMImplementation.createDocumentType() should be mandatory and non-nullable
+        https://bugs.webkit.org/show_bug.cgi?id=160167
+
+        Reviewed by Ryosuke Niwa.
+
+        Parameters to DOMImplementation.createDocumentType() should be mandatory
+        and non-nullable:
+        - https://dom.spec.whatwg.org/#domimplementation
+
+        Firefox and Chrome both agree with the specification. However, those
+        parameters were nullable and optional in WebKit.
+
+        Test: fast/dom/DOMImplementation/createDocumentType-parameters.html
+
+        * dom/DOMImplementation.idl:
+
 2016-07-25  Wenson Hsieh  <[email protected]>
 
         Media controls should not be displayed for a video until it starts playing

Modified: trunk/Source/WebCore/dom/DOMImplementation.idl (203700 => 203701)


--- trunk/Source/WebCore/dom/DOMImplementation.idl	2016-07-25 21:38:42 UTC (rev 203700)
+++ trunk/Source/WebCore/dom/DOMImplementation.idl	2016-07-25 21:53:33 UTC (rev 203701)
@@ -31,7 +31,7 @@
 
     // DOM Level 2
 
-    [ObjCLegacyUnnamedParameters, RaisesException, NewObject] DocumentType createDocumentType(optional DOMString? qualifiedName = null, optional DOMString? publicId = null, optional DOMString? systemId = null);
+    [ObjCLegacyUnnamedParameters, RaisesException, NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);
 
     [NewObject, ObjCLegacyUnnamedParameters, RaisesException]
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to