⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 203441 in webkit


Ignore:
Timestamp:
Jul 19, 2016, 6:45:51 PM (10 years ago)
Author:
Chris Dumez
Message:

Document.createElementNS() / createAttributeNS() parameters should be mandatory
https://bugs.webkit.org/show_bug.cgi?id=159938

Reviewed by Benjamin Poulain.

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-createElementNS-expected.txt:
  • web-platform-tests/html/dom/interfaces-expected.txt:

Source/WebCore:

Document.createElementNS() / createAttributeNS() parameters should be mandatory:

They were optional in WebKit. However, Firefox and Chrome both match the
specification.

No new tests, rebaselined existing tests.

  • dom/Document.idl:

LayoutTests:

Update / rebaseline existing tests to reflect the behavior change.

  • fast/dom/Document/createAttributeNS-namespace-err-expected.txt:
  • fast/dom/Document/createElementNS-namespace-err-expected.txt:
  • fast/dom/Document/script-tests/createAttributeNS-namespace-err.js:
  • fast/dom/Document/script-tests/createElementNS-namespace-err.js:
  • fast/dom/attribute-downcast-right.html:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r203439 r203441  
     12016-07-19  Chris Dumez  <cdumez@apple.com>
     2
     3        Document.createElementNS() / createAttributeNS() parameters should be mandatory
     4        https://bugs.webkit.org/show_bug.cgi?id=159938
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Update / rebaseline existing tests to reflect the behavior change.
     9
     10        * fast/dom/Document/createAttributeNS-namespace-err-expected.txt:
     11        * fast/dom/Document/createElementNS-namespace-err-expected.txt:
     12        * fast/dom/Document/script-tests/createAttributeNS-namespace-err.js:
     13        * fast/dom/Document/script-tests/createElementNS-namespace-err.js:
     14        * fast/dom/attribute-downcast-right.html:
     15
    1162016-07-19  Benjamin Poulain  <bpoulain@apple.com>
    217
  • trunk/LayoutTests/fast/dom/Document/createAttributeNS-namespace-err-expected.txt

    r105391 r203441  
    44
    55
    6 PASS document.createAttributeNS().toString() is "[object Attr]"
    7 PASS document.createAttributeNS("http://www.example.com").toString() is "[object Attr]"
     6PASS document.createAttributeNS() threw exception TypeError: Not enough arguments.
     7PASS document.createAttributeNS("http://www.example.com") threw exception TypeError: Not enough arguments.
    88PASS createAttributeNS(undefined, undefined)
    99PASS createAttributeNS(null, undefined)
    10 PASS createAttributeNS(undefined, null); threw INVALID_CHARACTER_ERR
    11 PASS createAttributeNS(null, null); threw INVALID_CHARACTER_ERR
     10PASS createAttributeNS(undefined, null)
     11PASS createAttributeNS(null, null)
    1212PASS createAttributeNS(null, ""); threw INVALID_CHARACTER_ERR
    13 PASS createAttributeNS("", null); threw INVALID_CHARACTER_ERR
     13PASS createAttributeNS("", null)
    1414PASS createAttributeNS("", ""); threw INVALID_CHARACTER_ERR
    1515PASS createAttributeNS(null, "<div>"); threw INVALID_CHARACTER_ERR
  • trunk/LayoutTests/fast/dom/Document/createElementNS-namespace-err-expected.txt

    r189842 r203441  
    44
    55
    6 PASS document.createElementNS().toString() is "[object Element]"
    7 PASS document.createElementNS("http://www.example.com").toString() is "[object Element]"
     6PASS document.createElementNS() threw exception TypeError: Not enough arguments.
     7PASS document.createElementNS("http://www.example.com") threw exception TypeError: Not enough arguments.
    88HTML tests:
    99PASS createElementNS(, )
    1010PASS createElementNS(null, )
    11 PASS createElementNS(, null); threw INVALID_CHARACTER_ERR
    12 PASS createElementNS(null, null); threw INVALID_CHARACTER_ERR
     11PASS createElementNS(, null)
     12PASS createElementNS(null, null)
    1313PASS createElementNS(null, ""); threw INVALID_CHARACTER_ERR
    14 PASS createElementNS("", null); threw INVALID_CHARACTER_ERR
     14PASS createElementNS("", null)
    1515PASS createElementNS("", ""); threw INVALID_CHARACTER_ERR
    1616PASS createElementNS(null, "<div>"); threw INVALID_CHARACTER_ERR
  • trunk/LayoutTests/fast/dom/Document/script-tests/createAttributeNS-namespace-err.js

    r105391 r203441  
    3838   { args: [undefined, undefined] },
    3939   { args: [null, undefined] },
    40    { args: [undefined, null], code: 5 },
    41    { args: [null, null], code: 5 },
     40   { args: [undefined, null] },
     41   { args: [null, null] },
    4242   { args: [null, ""], code: 5 },
    43    { args: ["", null], code: 5 },
     43   { args: ["", null] },
    4444   { args: ["", ""], code: 5 },
    4545   { args: [null, "<div>"], code: 5 },
     
    124124}
    125125
    126 // Moz throws a "Not enough arguments" exception in these, we don't:
    127 shouldBeEqualToString("document.createAttributeNS().toString()", "[object Attr]");
    128 shouldBeEqualToString("document.createAttributeNS(\"http://www.example.com\").toString()", "[object Attr]");
     126shouldThrow("document.createAttributeNS()", "'TypeError: Not enough arguments'");
     127shouldThrow("document.createAttributeNS(\"http://www.example.com\")", "'TypeError: Not enough arguments'");
    129128
    130129runNSTests();
  • trunk/LayoutTests/fast/dom/Document/script-tests/createElementNS-namespace-err.js

    r189842 r203441  
    3838   { args: [undefined, undefined] },
    3939   { args: [null, undefined] },
    40    { args: [undefined, null], code: 5 },
    41    { args: [null, null], code: 5 },
     40   { args: [undefined, null] },
     41   { args: [null, null] },
    4242   { args: [null, ""], code: 5 },
    43    { args: ["", null], code: 5 },
     43   { args: ["", null] },
    4444   { args: ["", ""], code: 5 },
    4545   { args: [null, "<div>"], code: 5 },
     
    158158}
    159159
    160 // Moz throws a "Not enough arguments" exception in these, we don't:
    161 shouldBeEqualToString("document.createElementNS().toString()", "[object Element]");
    162 shouldBeEqualToString("document.createElementNS(\"http://www.example.com\").toString()", "[object Element]");
     160shouldThrow("document.createElementNS()", "'TypeError: Not enough arguments'");
     161shouldThrow("document.createElementNS(\"http://www.example.com\")", "'TypeError: Not enough arguments'");
    163162
    164163debug("HTML tests:")
  • trunk/LayoutTests/fast/dom/attribute-downcast-right.html

    r120792 r203441  
    44
    55var oElement = document.createElement("s")
    6 var oElementNS = document.createElementNS();
     6var oElementNS = document.createElementNS(null, "test");
    77oElementNS.setAttributeNS();
    88var oAttributeNS = oElementNS.getAttributeNodeNS();
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r203428 r203441  
     12016-07-19  Chris Dumez  <cdumez@apple.com>
     2
     3        Document.createElementNS() / createAttributeNS() parameters should be mandatory
     4        https://bugs.webkit.org/show_bug.cgi?id=159938
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Rebaseline several W3C tests now that more checks are passing.
     9
     10        * web-platform-tests/dom/interfaces-expected.txt:
     11        * web-platform-tests/dom/nodes/Document-createElementNS-expected.txt:
     12        * web-platform-tests/html/dom/interfaces-expected.txt:
     13
    1142016-07-19  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt

    r203377 r203441  
    260260FAIL Document interface: operation getElementsByClassName(DOMString) assert_equals: property has wrong .length expected 1 but got 0
    261261PASS Document interface: operation createElement(DOMString,ElementCreationOptions)
    262 FAIL Document interface: operation createElementNS(DOMString,DOMString,ElementCreationOptions) assert_equals: property has wrong .length expected 2 but got 0
     262PASS Document interface: operation createElementNS(DOMString,DOMString,ElementCreationOptions)
    263263PASS Document interface: operation createDocumentFragment()
    264264FAIL Document interface: operation createTextNode(DOMString) assert_equals: property has wrong .length expected 1 but got 0
     
    268268PASS Document interface: operation adoptNode(Node)
    269269FAIL Document interface: operation createAttribute(DOMString) assert_equals: property has wrong .length expected 1 but got 0
    270 FAIL Document interface: operation createAttributeNS(DOMString,DOMString) assert_equals: property has wrong .length expected 2 but got 0
     270PASS Document interface: operation createAttributeNS(DOMString,DOMString)
    271271FAIL Document interface: operation createEvent(DOMString) assert_equals: property has wrong .length expected 1 but got 0
    272272PASS Document interface: operation createRange()
     
    310310PASS Document interface: calling createElement(DOMString,ElementCreationOptions) on new Document() with too few arguments must throw TypeError
    311311PASS Document interface: new Document() must inherit property "createElementNS" with the proper type (15)
    312 FAIL Document interface: calling createElementNS(DOMString,DOMString,ElementCreationOptions) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    313             fn.apply(obj, args);
    314         }" did not throw
     312PASS Document interface: calling createElementNS(DOMString,DOMString,ElementCreationOptions) on new Document() with too few arguments must throw TypeError
    315313PASS Document interface: new Document() must inherit property "createDocumentFragment" with the proper type (16)
    316314PASS Document interface: new Document() must inherit property "createTextNode" with the proper type (17)
     
    335333        }" did not throw
    336334PASS Document interface: new Document() must inherit property "createAttributeNS" with the proper type (23)
    337 FAIL Document interface: calling createAttributeNS(DOMString,DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    338             fn.apply(obj, args);
    339         }" did not throw
     335PASS Document interface: calling createAttributeNS(DOMString,DOMString) on new Document() with too few arguments must throw TypeError
    340336PASS Document interface: new Document() must inherit property "createEvent" with the proper type (24)
    341337FAIL Document interface: calling createEvent(DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
     
    476472PASS Document interface: calling createElement(DOMString,ElementCreationOptions) on xmlDoc with too few arguments must throw TypeError
    477473PASS Document interface: xmlDoc must inherit property "createElementNS" with the proper type (15)
    478 FAIL Document interface: calling createElementNS(DOMString,DOMString,ElementCreationOptions) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    479             fn.apply(obj, args);
    480         }" did not throw
     474PASS Document interface: calling createElementNS(DOMString,DOMString,ElementCreationOptions) on xmlDoc with too few arguments must throw TypeError
    481475PASS Document interface: xmlDoc must inherit property "createDocumentFragment" with the proper type (16)
    482476PASS Document interface: xmlDoc must inherit property "createTextNode" with the proper type (17)
     
    501495        }" did not throw
    502496PASS Document interface: xmlDoc must inherit property "createAttributeNS" with the proper type (23)
    503 FAIL Document interface: calling createAttributeNS(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    504             fn.apply(obj, args);
    505         }" did not throw
     497PASS Document interface: calling createAttributeNS(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError
    506498PASS Document interface: xmlDoc must inherit property "createEvent" with the proper type (24)
    507499FAIL Document interface: calling createEvent(DOMString) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createElementNS-expected.txt

    r203333 r203441  
    157157PASS createElementNS test 154: "foo:","xmlfoo:bar",null
    158158PASS createElementNS test 155: "","","INVALID_CHARACTER_ERR"
    159 FAIL createElementNS test 156: null,null,null The string contains invalid characters.
     159PASS createElementNS test 156: null,null,null
    160160PASS createElementNS test 157: null,"","INVALID_CHARACTER_ERR"
    161 FAIL createElementNS test 158: undefined,null,null The string contains invalid characters.
     161PASS createElementNS test 158: undefined,null,null
    162162PASS createElementNS test 159: undefined,undefined,null
    163163PASS createElementNS test 160: undefined,"","INVALID_CHARACTER_ERR"
    164 FAIL createElementNS test 161: "http://example.com/",null,null The string contains invalid characters.
     164PASS createElementNS test 161: "http://example.com/",null,null
    165165PASS createElementNS test 162: "http://example.com/","","INVALID_CHARACTER_ERR"
    166 FAIL createElementNS test 163: "/",null,null The string contains invalid characters.
     166PASS createElementNS test 163: "/",null,null
    167167PASS createElementNS test 164: "/","","INVALID_CHARACTER_ERR"
    168 FAIL createElementNS test 165: "http://www.w3.org/XML/1998/namespace",null,null The string contains invalid characters.
     168PASS createElementNS test 165: "http://www.w3.org/XML/1998/namespace",null,null
    169169PASS createElementNS test 166: "http://www.w3.org/XML/1998/namespace","","INVALID_CHARACTER_ERR"
    170 FAIL createElementNS test 167: "http://www.w3.org/2000/xmlns/",null,"NAMESPACE_ERR" assert_throws: function "function () { document.createElementNS(namespace, qualifi..." threw object "InvalidCharacterError (DOM Exception 5): The string conta..." that is not a DOMException NAMESPACE_ERR: property "code" is equal to 5, expected 14
     170PASS createElementNS test 167: "http://www.w3.org/2000/xmlns/",null,"NAMESPACE_ERR"
    171171PASS createElementNS test 168: "http://www.w3.org/2000/xmlns/","","INVALID_CHARACTER_ERR"
    172 FAIL createElementNS test 169: "foo:",null,null The string contains invalid characters.
     172PASS createElementNS test 169: "foo:",null,null
    173173PASS createElementNS test 170: "foo:","","INVALID_CHARACTER_ERR"
    174174PASS Lower-case HTML element without a prefix
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt

    r203377 r203441  
    150150PASS Document interface: calling createElement(DOMString) on iframe.contentDocument with too few arguments must throw TypeError
    151151PASS Document interface: iframe.contentDocument must inherit property "createElementNS" with the proper type (15)
    152 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 () {
    153             fn.apply(obj, args);
    154         }" did not throw
     152PASS Document interface: calling createElementNS(DOMString,DOMString) on iframe.contentDocument with too few arguments must throw TypeError
    155153PASS Document interface: iframe.contentDocument must inherit property "createDocumentFragment" with the proper type (16)
    156154PASS Document interface: iframe.contentDocument must inherit property "createTextNode" with the proper type (17)
     
    175173        }" did not throw
    176174PASS Document interface: iframe.contentDocument must inherit property "createAttributeNS" with the proper type (23)
    177 FAIL Document interface: calling createAttributeNS(DOMString,DOMString) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    178             fn.apply(obj, args);
    179         }" did not throw
     175PASS Document interface: calling createAttributeNS(DOMString,DOMString) on iframe.contentDocument with too few arguments must throw TypeError
    180176PASS Document interface: iframe.contentDocument must inherit property "createEvent" with the proper type (24)
    181177FAIL Document interface: calling createEvent(DOMString) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
     
    452448PASS Document interface: calling createElement(DOMString) on new Document() with too few arguments must throw TypeError
    453449PASS Document interface: new Document() must inherit property "createElementNS" with the proper type (15)
    454 FAIL Document interface: calling createElementNS(DOMString,DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    455             fn.apply(obj, args);
    456         }" did not throw
     450PASS Document interface: calling createElementNS(DOMString,DOMString) on new Document() with too few arguments must throw TypeError
    457451PASS Document interface: new Document() must inherit property "createDocumentFragment" with the proper type (16)
    458452PASS Document interface: new Document() must inherit property "createTextNode" with the proper type (17)
     
    477471        }" did not throw
    478472PASS Document interface: new Document() must inherit property "createAttributeNS" with the proper type (23)
    479 FAIL Document interface: calling createAttributeNS(DOMString,DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    480             fn.apply(obj, args);
    481         }" did not throw
     473PASS Document interface: calling createAttributeNS(DOMString,DOMString) on new Document() with too few arguments must throw TypeError
    482474PASS Document interface: new Document() must inherit property "createEvent" with the proper type (24)
    483475FAIL Document interface: calling createEvent(DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
     
    757749PASS Document interface: calling createElement(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError
    758750PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "createElementNS" with the proper type (15)
    759 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 () {
    760             fn.apply(obj, args);
    761         }" did not throw
     751PASS Document interface: calling createElementNS(DOMString,DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError
    762752PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "createDocumentFragment" with the proper type (16)
    763753PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "createTextNode" with the proper type (17)
     
    782772        }" did not throw
    783773PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "createAttributeNS" with the proper type (23)
    784 FAIL Document interface: calling createAttributeNS(DOMString,DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    785             fn.apply(obj, args);
    786         }" did not throw
     774PASS Document interface: calling createAttributeNS(DOMString,DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError
    787775PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "createEvent" with the proper type (24)
    788776FAIL Document interface: calling createEvent(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
  • trunk/LayoutTests/svg/dom/element-removed-while-inserting-parent-crash.html

    r185769 r203441  
    66    testRunner.dumpAsText();
    77
    8 var element = document.createElementNS('http://www.w3.org/2000/svg');
     8var element = document.createElementNS('http://www.w3.org/2000/svg', "test");
    99
    1010var script = document.createElementNS('http://www.w3.org/2000/svg', 'script');
  • trunk/Source/WebCore/ChangeLog

    r203439 r203441  
     12016-07-19  Chris Dumez  <cdumez@apple.com>
     2
     3        Document.createElementNS() / createAttributeNS() parameters should be mandatory
     4        https://bugs.webkit.org/show_bug.cgi?id=159938
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Document.createElementNS() / createAttributeNS() parameters should be mandatory:
     9        - https://dom.spec.whatwg.org/#document
     10
     11        They were optional in WebKit. However, Firefox and Chrome both match the
     12        specification.
     13
     14        No new tests, rebaselined existing tests.
     15
     16        * dom/Document.idl:
     17
    1182016-07-19  Benjamin Poulain  <bpoulain@apple.com>
    219
  • trunk/Source/WebCore/dom/Document.idl

    r203047 r203441  
    5959    [ObjCLegacyUnnamedParameters, NewObject, RaisesException] Node importNode(Node importedNode, optional boolean deep = false);
    6060
    61     // FIXME: 'qualifiedName' should not have [TreatNullAs=EmptyString].
    62     // FIXME: Using "undefined" as default parameter value is wrong.
    63     [ObjCLegacyUnnamedParameters, NewObject, RaisesException] Element createElementNS(optional DOMString? namespaceURI = null,
    64         [TreatNullAs=EmptyString] optional DOMString qualifiedName = "undefined");
    65 
    66     // FIXME: 'qualifiedName' should not have [TreatNullAs=EmptyString].
    67     // FIXME: Using "undefined" as default parameter value is wrong.
    68     [ObjCLegacyUnnamedParameters, NewObject, RaisesException] Attr createAttributeNS(optional DOMString? namespaceURI = null,
    69         [TreatNullAs=EmptyString] optional DOMString qualifiedName = "undefined");
     61    [ObjCLegacyUnnamedParameters, NewObject, RaisesException] Element createElementNS(DOMString? namespaceURI, DOMString qualifiedName);
     62    [ObjCLegacyUnnamedParameters, NewObject, RaisesException] Attr createAttributeNS(DOMString? namespaceURI, DOMString qualifiedName);
    7063
    7164#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
Note: See TracChangeset for help on using the changeset viewer.