Title: [190621] trunk
Revision
190621
Author
cdu...@apple.com
Date
2015-10-06 10:20:23 -0700 (Tue, 06 Oct 2015)

Log Message

[Web IDL] 'length' property is wrong for variadic operations
https://bugs.webkit.org/show_bug.cgi?id=149714

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline W3C DOM test as our behavior changed. The new failures are
temporary and are due to the test being wrong. The test will be fixed
via Bug 149645 and we will pass those checks again.

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

Source/WebCore:

The value of the 'length' property was wrong for variadic operations:
- https://heycam.github.io/webidl/#dfn-optional-argument

The final argument of a variadic operation is considered to be an
optional argument. Therefore, we should not account for it when
computing the value of the 'length' property. This patch fixes WebKit's
behavior to match the specification.

Test: fast/dom/variadic-operations-length.html

* bindings/scripts/CodeGeneratorJS.pm:
(GetFunctionLength):
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
(WebCore::JSTestOverloadedConstructorsConstructor::finishCreation):

LayoutTests:

Add a layout test to check that the value for the 'length' property of
variadic operations is correct.

* fast/dom/variadic-operations-length-expected.txt: Added.
* fast/dom/variadic-operations-length.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (190620 => 190621)


--- trunk/LayoutTests/ChangeLog	2015-10-06 16:50:22 UTC (rev 190620)
+++ trunk/LayoutTests/ChangeLog	2015-10-06 17:20:23 UTC (rev 190621)
@@ -1,3 +1,16 @@
+2015-10-06  Chris Dumez  <cdu...@apple.com>
+
+        [Web IDL] 'length' property is wrong for variadic operations
+        https://bugs.webkit.org/show_bug.cgi?id=149714
+
+        Reviewed by Darin Adler.
+
+        Add a layout test to check that the value for the 'length' property of
+        variadic operations is correct.
+
+        * fast/dom/variadic-operations-length-expected.txt: Added.
+        * fast/dom/variadic-operations-length.html: Added.
+
 2015-10-06  Hunseop Jeong  <hs85.je...@samsung.com>
 
         [Cairo] fast/canvas/canvas-imageSmoothingFoo tests failed after r190383.

Added: trunk/LayoutTests/fast/dom/variadic-operations-length-expected.txt (0 => 190621)


--- trunk/LayoutTests/fast/dom/variadic-operations-length-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/variadic-operations-length-expected.txt	2015-10-06 17:20:23 UTC (rev 190621)
@@ -0,0 +1,16 @@
+Tests that the value of the 'length' property is correct for variadic operations.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.body.before.length is 0
+PASS document.body.after.length is 0
+PASS document.body.replaceWith.length is 0
+PASS document.body.prepend.length is 0
+PASS document.body.append.length is 0
+PASS document.body.classList.add.length is 0
+PASS document.body.classList.remove.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/variadic-operations-length.html (0 => 190621)


--- trunk/LayoutTests/fast/dom/variadic-operations-length.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/variadic-operations-length.html	2015-10-06 17:20:23 UTC (rev 190621)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that the value of the 'length' property is correct for variadic operations.");
+
+// void before((Node or DOMString)... nodes);
+shouldBe("document.body.before.length", "0");
+
+// void after((Node or DOMString)... nodes);
+shouldBe("document.body.after.length", "0");
+
+// void replaceWith((Node or DOMString)... nodes);
+shouldBe("document.body.replaceWith.length", "0");
+
+//void prepend((Node or DOMString)... nodes);
+shouldBe("document.body.prepend.length", "0");
+
+// void append((Node or DOMString)... nodes);
+shouldBe("document.body.append.length", "0");
+
+// void add(DOMString... tokens);
+shouldBe("document.body.classList.add.length", "0");
+
+// void remove(DOMString... tokens);
+shouldBe("document.body.classList.remove.length", "0");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (190620 => 190621)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2015-10-06 16:50:22 UTC (rev 190620)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2015-10-06 17:20:23 UTC (rev 190621)
@@ -1,3 +1,16 @@
+2015-10-06  Chris Dumez  <cdu...@apple.com>
+
+        [Web IDL] 'length' property is wrong for variadic operations
+        https://bugs.webkit.org/show_bug.cgi?id=149714
+
+        Reviewed by Darin Adler.
+
+        Rebaseline W3C DOM test as our behavior changed. The new failures are
+        temporary and are due to the test being wrong. The test will be fixed
+        via Bug 149645 and we will pass those checks again.
+
+        * web-platform-tests/dom/interfaces-expected.txt:
+
 2015-09-29  Chris Dumez  <cdu...@apple.com>
 
         sectionRowIndex must return -1 when its parent is not a table, tbody, thead, or tfoot

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2015-10-06 16:50:22 UTC (rev 190620)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt	2015-10-06 17:20:23 UTC (rev 190621)
@@ -470,8 +470,8 @@
 FAIL Document interface: attribute childElementCount assert_throws: getting property on prototype object must throw TypeError function "function () {
     [native code]
 }" did not throw
-PASS Document interface: operation prepend([object Object],[object Object]) 
-PASS Document interface: operation append([object Object],[object Object]) 
+FAIL Document interface: operation prepend([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
+FAIL Document interface: operation append([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
 FAIL Document interface: operation query(DOMString) assert_own_property: interface prototype object missing non-static operation expected property "query" missing
 FAIL Document interface: operation queryAll(DOMString) assert_own_property: interface prototype object missing non-static operation expected property "queryAll" missing
 PASS Document interface: operation querySelector(DOMString) 
@@ -695,8 +695,8 @@
 FAIL DocumentFragment interface: attribute childElementCount assert_throws: getting property on prototype object must throw TypeError function "function () {
     [native code]
 }" did not throw
-PASS DocumentFragment interface: operation prepend([object Object],[object Object]) 
-PASS DocumentFragment interface: operation append([object Object],[object Object]) 
+FAIL DocumentFragment interface: operation prepend([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
+FAIL DocumentFragment interface: operation append([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
 FAIL DocumentFragment interface: operation query(DOMString) assert_own_property: interface prototype object missing non-static operation expected property "query" missing
 FAIL DocumentFragment interface: operation queryAll(DOMString) assert_own_property: interface prototype object missing non-static operation expected property "queryAll" missing
 PASS DocumentFragment interface: operation querySelector(DOMString) 
@@ -821,9 +821,9 @@
 FAIL DocumentType interface: attribute systemId assert_throws: getting property on prototype object must throw TypeError function "function () {
     [native code]
 }" did not throw
-PASS DocumentType interface: operation before([object Object],[object Object]) 
-PASS DocumentType interface: operation after([object Object],[object Object]) 
-PASS DocumentType interface: operation replaceWith([object Object],[object Object]) 
+FAIL DocumentType interface: operation before([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
+FAIL DocumentType interface: operation after([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
+FAIL DocumentType interface: operation replaceWith([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
 PASS DocumentType interface: operation remove() 
 PASS DocumentType must be primary interface of document.doctype 
 PASS Stringification of document.doctype 
@@ -983,8 +983,8 @@
 FAIL Element interface: attribute childElementCount assert_throws: getting property on prototype object must throw TypeError function "function () {
     [native code]
 }" did not throw
-PASS Element interface: operation prepend([object Object],[object Object]) 
-PASS Element interface: operation append([object Object],[object Object]) 
+FAIL Element interface: operation prepend([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
+FAIL Element interface: operation append([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
 FAIL Element interface: operation query(DOMString) assert_own_property: interface prototype object missing non-static operation expected property "query" missing
 FAIL Element interface: operation queryAll(DOMString) assert_own_property: interface prototype object missing non-static operation expected property "queryAll" missing
 PASS Element interface: operation querySelector(DOMString) 
@@ -995,9 +995,9 @@
 FAIL Element interface: attribute nextElementSibling assert_throws: getting property on prototype object must throw TypeError function "function () {
     [native code]
 }" did not throw
-PASS Element interface: operation before([object Object],[object Object]) 
-PASS Element interface: operation after([object Object],[object Object]) 
-PASS Element interface: operation replaceWith([object Object],[object Object]) 
+FAIL Element interface: operation before([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
+FAIL Element interface: operation after([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
+FAIL Element interface: operation replaceWith([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
 PASS Element interface: operation remove() 
 PASS Element must be primary interface of element 
 PASS Stringification of element 
@@ -1269,9 +1269,9 @@
 FAIL CharacterData interface: attribute nextElementSibling assert_throws: getting property on prototype object must throw TypeError function "function () {
     [native code]
 }" did not throw
-PASS CharacterData interface: operation before([object Object],[object Object]) 
-PASS CharacterData interface: operation after([object Object],[object Object]) 
-PASS CharacterData interface: operation replaceWith([object Object],[object Object]) 
+FAIL CharacterData interface: operation before([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
+FAIL CharacterData interface: operation after([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
+FAIL CharacterData interface: operation replaceWith([object Object],[object Object]) assert_equals: property has wrong .length expected 1 but got 0
 PASS CharacterData interface: operation remove() 
 FAIL Text interface: existence and properties of interface object assert_equals: prototype of self's property "Text" is not Function.prototype expected (function) function "function () {
     [native code]
@@ -1870,8 +1870,8 @@
 FAIL DOMTokenList interface: attribute length assert_true: The prototype object must have a property "length" expected true got false
 PASS DOMTokenList interface: operation item(unsigned long) 
 PASS DOMTokenList interface: operation contains(DOMString) 
-PASS DOMTokenList interface: operation add(DOMString) 
-PASS DOMTokenList interface: operation remove(DOMString) 
+FAIL DOMTokenList interface: operation add(DOMString) assert_equals: property has wrong .length expected 1 but got 0
+FAIL DOMTokenList interface: operation remove(DOMString) assert_equals: property has wrong .length expected 1 but got 0
 PASS DOMTokenList interface: operation toggle(DOMString,boolean) 
 FAIL DOMTokenList interface: stringifier assert_true: property is not enumerable expected true got false
 PASS DOMTokenList must be primary interface of document.body.classList 

Modified: trunk/Source/WebCore/ChangeLog (190620 => 190621)


--- trunk/Source/WebCore/ChangeLog	2015-10-06 16:50:22 UTC (rev 190620)
+++ trunk/Source/WebCore/ChangeLog	2015-10-06 17:20:23 UTC (rev 190621)
@@ -1,3 +1,26 @@
+2015-10-06  Chris Dumez  <cdu...@apple.com>
+
+        [Web IDL] 'length' property is wrong for variadic operations
+        https://bugs.webkit.org/show_bug.cgi?id=149714
+
+        Reviewed by Darin Adler.
+
+        The value of the 'length' property was wrong for variadic operations:
+        - https://heycam.github.io/webidl/#dfn-optional-argument
+
+        The final argument of a variadic operation is considered to be an
+        optional argument. Therefore, we should not account for it when
+        computing the value of the 'length' property. This patch fixes WebKit's
+        behavior to match the specification.
+
+        Test: fast/dom/variadic-operations-length.html
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GetFunctionLength):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
+        (WebCore::JSTestOverloadedConstructorsConstructor::finishCreation):
+
 2015-10-06  Youenn Fablet  <youenn.fab...@crf.canon.fr>
 
         Binding generator should add builtin header for JSBuiltin attributes

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (190620 => 190621)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-10-06 16:50:22 UTC (rev 190620)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-10-06 17:20:23 UTC (rev 190621)
@@ -1487,7 +1487,7 @@
   foreach my $parameter (@{$function->parameters}) {
     # Abort as soon as we find the first optional parameter as no mandatory
     # parameter can follow an optional one.
-    last if $parameter->isOptional;
+    last if $parameter->isOptional || $parameter->isVariadic;
     $numMandatoryParams++;
   }
   return $numMandatoryParams;

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (190620 => 190621)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2015-10-06 16:50:22 UTC (rev 190620)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2015-10-06 17:20:23 UTC (rev 190621)
@@ -705,9 +705,9 @@
     { "strictFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionStrictFunction), (intptr_t) (3) } },
     { "strictFunctionWithSequence", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionStrictFunctionWithSequence), (intptr_t) (2) } },
     { "strictFunctionWithArray", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionStrictFunctionWithArray), (intptr_t) (2) } },
-    { "variadicStringMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicStringMethod), (intptr_t) (2) } },
-    { "variadicDoubleMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicDoubleMethod), (intptr_t) (2) } },
-    { "variadicNodeMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicNodeMethod), (intptr_t) (2) } },
+    { "variadicStringMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicStringMethod), (intptr_t) (1) } },
+    { "variadicDoubleMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicDoubleMethod), (intptr_t) (1) } },
+    { "variadicNodeMethod", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVariadicNodeMethod), (intptr_t) (1) } },
     { "any", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAny), (intptr_t) (2) } },
     { "testPromiseFunction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseFunction), (intptr_t) (0) } },
     { "testPromiseFunctionWithFloatArgument", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgument), (intptr_t) (1) } },

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp (190620 => 190621)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp	2015-10-06 16:50:22 UTC (rev 190620)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp	2015-10-06 17:20:23 UTC (rev 190621)
@@ -179,7 +179,7 @@
     ASSERT(inherits(info()));
     putDirect(vm, vm.propertyNames->prototype, JSTestOverloadedConstructors::getPrototype(vm, globalObject), DontDelete | ReadOnly | DontEnum);
     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestOverloadedConstructors"))), ReadOnly | DontEnum);
-    putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum);
+    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
 }
 
 ConstructType JSTestOverloadedConstructorsConstructor::getConstructData(JSCell*, ConstructData& constructData)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to