Changeset 133944 in webkit
- Timestamp:
- Nov 8, 2012 1:52:15 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r133940 r133944 1 2012-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 1 17 2012-11-08 Joshua Bell <jsbell@chromium.org> 2 18 -
trunk/LayoutTests/fast/dom/Element/attr-param-typechecking-expected.txt
r30635 r133944 4 4 5 5 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. 6 PASS element.setAttributeNode(); threw exception TypeError: Not enough arguments. 7 PASS element.setAttributeNodeNS(); threw exception TypeError: Not enough arguments. 8 PASS element.removeAttributeNode(); threw exception TypeError: Not enough arguments. 9 PASS element.setAttributeNode("style"); threw exception TypeError: Type error. 10 PASS element.setAttributeNode(null); threw exception TypeError: Type error. 11 PASS element.setAttributeNode(undefined); threw exception TypeError: Type error. 12 PASS element.setAttributeNode(new Object); threw exception TypeError: Type error. 13 PASS element.removeAttributeNode("style"); threw exception TypeError: Type error. 14 PASS element.removeAttributeNode(null); threw exception TypeError: Type error. 15 PASS element.removeAttributeNode(undefined); threw exception TypeError: Type error. 16 PASS element.removeAttributeNode(new Object); threw exception TypeError: Type error. 17 PASS element.setAttributeNodeNS("style"); threw exception TypeError: Type error. 18 PASS element.setAttributeNodeNS(null); threw exception TypeError: Type error. 19 PASS element.setAttributeNodeNS(undefined); threw exception TypeError: Type error. 20 PASS element.setAttributeNodeNS(new Object); threw exception TypeError: Type error. 18 21 PASS successfullyParsed is true 19 22 -
trunk/LayoutTests/fast/dom/Element/script-tests/attr-param-typechecking.js
r98407 r133944 4 4 5 5 var element = document.createElement("input"); 6 7 shouldThrow('element.setAttributeNode();'); 8 shouldThrow('element.setAttributeNodeNS();'); 9 shouldThrow('element.removeAttributeNode();'); 6 10 7 11 shouldThrow('element.setAttributeNode("style");'); -
trunk/Source/WebCore/ChangeLog
r133940 r133944 1 2012-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 1 22 2012-11-08 Joshua Bell <jsbell@chromium.org> 2 23 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
r133932 r133944 1584 1584 if (!$raisesExceptions) { 1585 1585 foreach my $parameter (@{$function->parameters}) { 1586 if ( (!$parameter->extendedAttributes->{"Callback"} and TypeCanFailConversion($parameter)) or$parameter->extendedAttributes->{"IsIndex"}) {1586 if ($parameter->extendedAttributes->{"IsIndex"}) { 1587 1587 $raisesExceptions = 1; 1588 1588 } … … 1798 1798 $parameterCheckString .= " if (${parameterName}DidThrow)\n"; 1799 1799 $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";1807 1800 } elsif ($parameter->isVariadic) { 1808 1801 my $nativeElementType = GetNativeType($parameter->type); … … 1872 1865 if (!$raisesExceptions) { 1873 1866 foreach my $parameter (@{$function->parameters}) { 1874 if ( (!$parameter->extendedAttributes->{"Callback"} and TypeCanFailConversion($parameter)) or$parameter->extendedAttributes->{"IsIndex"}) {1867 if ($parameter->extendedAttributes->{"IsIndex"}) { 1875 1868 $raisesExceptions = 1; 1876 1869 } … … 2050 2043 if (!$raisesExceptions) { 2051 2044 foreach my $parameter (@{$function->parameters}) { 2052 if ( (!$parameter->extendedAttributes->{"Callback"} and TypeCanFailConversion($parameter)) or$parameter->extendedAttributes->{"IsIndex"}) {2045 if ($parameter->extendedAttributes->{"IsIndex"}) { 2053 2046 $raisesExceptions = 1; 2054 2047 } … … 3730 3723 $signature->type("DOMString"); 3731 3724 } 3732 }3733 3734 sub TypeCanFailConversion3735 {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;3743 3725 } 3744 3726 -
trunk/Source/WebCore/dom/Element.cpp
r133848 r133944 1522 1522 { 1523 1523 if (!attrNode) { 1524 ec = TYPE_MISMATCH_ERR;1524 ec = NATIVE_TYPE_ERR; 1525 1525 return 0; 1526 1526 } … … 1564 1564 { 1565 1565 if (!attr) { 1566 ec = TYPE_MISMATCH_ERR;1566 ec = NATIVE_TYPE_ERR; 1567 1567 return 0; 1568 1568 } -
trunk/Source/WebCore/dom/Element.idl
r133268 r133944 34 34 void removeAttribute(in [Optional=DefaultIsUndefined] DOMString name); 35 35 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) 39 39 raises(DOMException); 40 40 NodeList getElementsByTagName(in [Optional=DefaultIsUndefined] DOMString name); … … 54 54 [ObjCLegacyUnnamedParameters] Attr getAttributeNodeNS(in [TreatNullAs=NullString,Optional=DefaultIsUndefined] DOMString namespaceURI, 55 55 in [Optional=DefaultIsUndefined] DOMString localName); 56 Attr setAttributeNodeNS(in [Optional=DefaultIsUndefined]Attr newAttr)56 Attr setAttributeNodeNS(in Attr newAttr) 57 57 raises(DOMException); 58 58 boolean hasAttribute(in DOMString name);
Note: See TracChangeset
for help on using the changeset viewer.