Changeset 133944 in webkit


Ignore:
Timestamp:
Nov 8, 2012 1:52:15 PM (11 years ago)
Author:
arv@chromium.org
Message:

setAttributeNode and friends should not have optional argument
https://bugs.webkit.org/show_bug.cgi?id=101631

Reviewed by Ojan Vafai.

Source/WebCore:

http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-887236154

Fix getAttributeNode, getAttributeNodeNS and removeAttributeNode to make the Attr
argument mandatory.

These used to throw DOMExceptions when an invalid type was passed instead of
TypeError which is also a spec violation.

Updated existing tests.

  • bindings/scripts/CodeGeneratorV8.pm:
  • dom/Element.cpp:
  • dom/Element.idl:

LayoutTests:

Fix getAttributeNode, getAttributeNodeNS and removeAttributeNode to make the Attr
argument mandatory.

These used to throw DOMExceptions when an invalid type was passed instead of
TypeError which is also a spec violation.

  • fast/dom/Element/attr-param-typechecking-expected.txt:
  • fast/dom/Element/script-tests/attr-param-typechecking.js:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r133940 r133944  
     12012-11-08  Erik Arvidsson  <arv@chromium.org>
     2
     3        setAttributeNode and friends should not have optional argument
     4        https://bugs.webkit.org/show_bug.cgi?id=101631
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Fix getAttributeNode, getAttributeNodeNS and removeAttributeNode to make the Attr
     9        argument mandatory.
     10
     11        These used to throw DOMExceptions when an invalid type was passed instead of
     12        TypeError which is also a spec violation.
     13
     14        * fast/dom/Element/attr-param-typechecking-expected.txt:
     15        * fast/dom/Element/script-tests/attr-param-typechecking.js:
     16
    1172012-11-08  Joshua Bell  <jsbell@chromium.org>
    218
  • trunk/LayoutTests/fast/dom/Element/attr-param-typechecking-expected.txt

    r30635 r133944  
    44
    55
    6 PASS element.setAttributeNode("style"); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    7 PASS element.setAttributeNode(null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    8 PASS element.setAttributeNode(undefined); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    9 PASS element.setAttributeNode(new Object); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    10 PASS element.removeAttributeNode("style"); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    11 PASS element.removeAttributeNode(null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    12 PASS element.removeAttributeNode(undefined); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    13 PASS element.removeAttributeNode(new Object); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    14 PASS element.setAttributeNodeNS("style"); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    15 PASS element.setAttributeNodeNS(null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    16 PASS element.setAttributeNodeNS(undefined); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
    17 PASS element.setAttributeNodeNS(new Object); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
     6PASS element.setAttributeNode(); threw exception TypeError: Not enough arguments.
     7PASS element.setAttributeNodeNS(); threw exception TypeError: Not enough arguments.
     8PASS element.removeAttributeNode(); threw exception TypeError: Not enough arguments.
     9PASS element.setAttributeNode("style"); threw exception TypeError: Type error.
     10PASS element.setAttributeNode(null); threw exception TypeError: Type error.
     11PASS element.setAttributeNode(undefined); threw exception TypeError: Type error.
     12PASS element.setAttributeNode(new Object); threw exception TypeError: Type error.
     13PASS element.removeAttributeNode("style"); threw exception TypeError: Type error.
     14PASS element.removeAttributeNode(null); threw exception TypeError: Type error.
     15PASS element.removeAttributeNode(undefined); threw exception TypeError: Type error.
     16PASS element.removeAttributeNode(new Object); threw exception TypeError: Type error.
     17PASS element.setAttributeNodeNS("style"); threw exception TypeError: Type error.
     18PASS element.setAttributeNodeNS(null); threw exception TypeError: Type error.
     19PASS element.setAttributeNodeNS(undefined); threw exception TypeError: Type error.
     20PASS element.setAttributeNodeNS(new Object); threw exception TypeError: Type error.
    1821PASS successfullyParsed is true
    1922
  • trunk/LayoutTests/fast/dom/Element/script-tests/attr-param-typechecking.js

    r98407 r133944  
    44
    55var element = document.createElement("input");
     6
     7shouldThrow('element.setAttributeNode();');
     8shouldThrow('element.setAttributeNodeNS();');
     9shouldThrow('element.removeAttributeNode();');
    610
    711shouldThrow('element.setAttributeNode("style");');
  • trunk/Source/WebCore/ChangeLog

    r133940 r133944  
     12012-11-08  Erik Arvidsson  <arv@chromium.org>
     2
     3        setAttributeNode and friends should not have optional argument
     4        https://bugs.webkit.org/show_bug.cgi?id=101631
     5
     6        Reviewed by Ojan Vafai.
     7
     8        http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-887236154
     9
     10        Fix getAttributeNode, getAttributeNodeNS and removeAttributeNode to make the Attr
     11        argument mandatory.
     12
     13        These used to throw DOMExceptions when an invalid type was passed instead of
     14        TypeError which is also a spec violation.
     15
     16        Updated existing tests.
     17
     18        * bindings/scripts/CodeGeneratorV8.pm:
     19        * dom/Element.cpp:
     20        * dom/Element.idl:
     21
    1222012-11-08  Joshua Bell  <jsbell@chromium.org>
    223
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r133932 r133944  
    15841584    if (!$raisesExceptions) {
    15851585        foreach my $parameter (@{$function->parameters}) {
    1586             if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailConversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) {
     1586            if ($parameter->extendedAttributes->{"IsIndex"}) {
    15871587                $raisesExceptions = 1;
    15881588            }
     
    17981798            $parameterCheckString .= "    if (${parameterName}DidThrow)\n";
    17991799            $parameterCheckString .= "        return v8Undefined();\n";
    1800         } elsif (TypeCanFailConversion($parameter)) {
    1801             $parameterCheckString .= "    $nativeType $parameterName = " .
    1802                  JSValueToNative($parameter, "args[$paramIndex]", "args.GetIsolate()") . ";\n";
    1803             $parameterCheckString .= "    if (UNLIKELY(!$parameterName)) {\n";
    1804             $parameterCheckString .= "        ec = TYPE_MISMATCH_ERR;\n";
    1805             $parameterCheckString .= "        goto fail;\n";
    1806             $parameterCheckString .= "    }\n";
    18071800        } elsif ($parameter->isVariadic) {
    18081801            my $nativeElementType = GetNativeType($parameter->type);
     
    18721865    if (!$raisesExceptions) {
    18731866        foreach my $parameter (@{$function->parameters}) {
    1874             if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailConversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) {
     1867            if ($parameter->extendedAttributes->{"IsIndex"}) {
    18751868                $raisesExceptions = 1;
    18761869            }
     
    20502043    if (!$raisesExceptions) {
    20512044        foreach my $parameter (@{$function->parameters}) {
    2052             if ((!$parameter->extendedAttributes->{"Callback"} and TypeCanFailConversion($parameter)) or $parameter->extendedAttributes->{"IsIndex"}) {
     2045            if ($parameter->extendedAttributes->{"IsIndex"}) {
    20532046                $raisesExceptions = 1;
    20542047            }
     
    37303723      $signature->type("DOMString");
    37313724    }
    3732 }
    3733 
    3734 sub TypeCanFailConversion
    3735 {
    3736     my $signature = shift;
    3737 
    3738     my $type = GetTypeFromSignature($signature);
    3739 
    3740     AddToImplIncludes("ExceptionCode.h") if $type eq "Attr";
    3741     return 1 if $type eq "Attr";
    3742     return 0;
    37433725}
    37443726
  • trunk/Source/WebCore/dom/Element.cpp

    r133848 r133944  
    15221522{
    15231523    if (!attrNode) {
    1524         ec = TYPE_MISMATCH_ERR;
     1524        ec = NATIVE_TYPE_ERR;
    15251525        return 0;
    15261526    }
     
    15641564{
    15651565    if (!attr) {
    1566         ec = TYPE_MISMATCH_ERR;
     1566        ec = NATIVE_TYPE_ERR;
    15671567        return 0;
    15681568    }
  • trunk/Source/WebCore/dom/Element.idl

    r133268 r133944  
    3434    void removeAttribute(in [Optional=DefaultIsUndefined] DOMString name);
    3535    Attr getAttributeNode(in [Optional=DefaultIsUndefined] DOMString name);
    36     Attr setAttributeNode(in [Optional=DefaultIsUndefined] Attr newAttr)
    37         raises(DOMException);
    38     Attr removeAttributeNode(in [Optional=DefaultIsUndefined] Attr oldAttr)
     36    Attr setAttributeNode(in Attr newAttr)
     37        raises(DOMException);
     38    Attr removeAttributeNode(in Attr oldAttr)
    3939        raises(DOMException);
    4040    NodeList getElementsByTagName(in [Optional=DefaultIsUndefined] DOMString name);
     
    5454    [ObjCLegacyUnnamedParameters] Attr getAttributeNodeNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI,
    5555                                           in [Optional=DefaultIsUndefined] DOMString localName);
    56     Attr setAttributeNodeNS(in [Optional=DefaultIsUndefined] Attr newAttr)
     56    Attr setAttributeNodeNS(in Attr newAttr)
    5757        raises(DOMException);
    5858    boolean hasAttribute(in DOMString name);
Note: See TracChangeset for help on using the changeset viewer.