Title: [191587] trunk
Revision
191587
Author
[email protected]
Date
2015-10-26 11:08:50 -0700 (Mon, 26 Oct 2015)

Log Message

Indexing an object with an integer that is not a supported property index should not call the named property getter
https://bugs.webkit.org/show_bug.cgi?id=148871
<rdar://problem/22589952>

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline W3C HTML test now that more checks are passing.

* web-platform-tests/html/semantics/forms/the-form-element/form-elements-matches-expected.txt:

Source/WebCore:

Indexing an object with an integer that is not a supported property
index should not call the named property getter, as per the Web IDL
specification:
https://heycam.github.io/webidl/#idl-indexed-properties (Note in blue)

Firefox and Chrome both already behave according to the specification
here so this patch aligns our behavior with other browsers as well.

No new tests, already covered by existing test.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateGetOwnPropertySlotBody):
(GenerateImplementation):
* bindings/scripts/test/JS/JSTestEventTarget.cpp:
(WebCore::JSTestEventTarget::getOwnPropertySlot):
(WebCore::JSTestEventTarget::getOwnPropertySlotByIndex): Deleted.
(WebCore::jsTestEventTargetConstructor): Deleted.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (191586 => 191587)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2015-10-26 16:44:54 UTC (rev 191586)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2015-10-26 18:08:50 UTC (rev 191587)
@@ -1,3 +1,15 @@
+2015-10-26  Chris Dumez  <[email protected]>
+
+        Indexing an object with an integer that is not a supported property index should not call the named property getter
+        https://bugs.webkit.org/show_bug.cgi?id=148871
+        <rdar://problem/22589952>
+
+        Reviewed by Darin Adler.
+
+        Rebaseline W3C HTML test now that more checks are passing.
+
+        * web-platform-tests/html/semantics/forms/the-form-element/form-elements-matches-expected.txt:
+
 2015-10-25  Youenn Fablet  <[email protected]>
 
         Import W3C XMLHttpRequest tests

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-elements-matches-expected.txt (191586 => 191587)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-elements-matches-expected.txt	2015-10-26 16:44:54 UTC (rev 191586)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-form-element/form-elements-matches-expected.txt	2015-10-26 18:08:50 UTC (rev 191587)
@@ -1,5 +1,5 @@
- 
 
+
 PASS input type=image should not be present in the form.elements collection 
-FAIL form.elements should include elements whose name starts with a number assert_equals: [2] expected (undefined) undefined but got (object) Element node <input name="2"></input>
+PASS form.elements should include elements whose name starts with a number 
 

Modified: trunk/Source/WebCore/ChangeLog (191586 => 191587)


--- trunk/Source/WebCore/ChangeLog	2015-10-26 16:44:54 UTC (rev 191586)
+++ trunk/Source/WebCore/ChangeLog	2015-10-26 18:08:50 UTC (rev 191587)
@@ -1,3 +1,29 @@
+2015-10-26  Chris Dumez  <[email protected]>
+
+        Indexing an object with an integer that is not a supported property index should not call the named property getter
+        https://bugs.webkit.org/show_bug.cgi?id=148871
+        <rdar://problem/22589952>
+
+        Reviewed by Darin Adler.
+
+        Indexing an object with an integer that is not a supported property
+        index should not call the named property getter, as per the Web IDL
+        specification:
+        https://heycam.github.io/webidl/#idl-indexed-properties (Note in blue)
+
+        Firefox and Chrome both already behave according to the specification
+        here so this patch aligns our behavior with other browsers as well.
+
+        No new tests, already covered by existing test.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateGetOwnPropertySlotBody):
+        (GenerateImplementation):
+        * bindings/scripts/test/JS/JSTestEventTarget.cpp:
+        (WebCore::JSTestEventTarget::getOwnPropertySlot):
+        (WebCore::JSTestEventTarget::getOwnPropertySlotByIndex): Deleted.
+        (WebCore::jsTestEventTargetConstructor): Deleted.
+
 2015-10-26  Xabier Rodriguez Calvar  <[email protected]>
 
         [Streams API] Implement abort method on writable streams

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (191586 => 191587)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-10-26 16:44:54 UTC (rev 191586)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-10-26 18:08:50 UTC (rev 191587)
@@ -442,8 +442,15 @@
             &$prototypeCheck();
         }
 
-        # This condition is to make sure we use the subclass' named getter instead of the base class one when possible.
-        push(@getOwnPropertySlotImpl, "    if (thisObject->classInfo() == info()) {\n");
+        # The "thisObject->classInfo() == info()" check is to make sure we use the subclass' named getter
+        # instead of the base class one when possible.
+        if ($indexedGetterFunction) {
+            # Indexing an object with an integer that is not a supported property index should not call the named property getter.
+            # https://heycam.github.io/webidl/#idl-indexed-properties
+            push(@getOwnPropertySlotImpl, "    if (!optionalIndex && thisObject->classInfo() == info()) {\n");
+        } else {
+            push(@getOwnPropertySlotImpl, "    if (thisObject->classInfo() == info()) {\n");
+        }
         push(@getOwnPropertySlotImpl, "        JSValue value;\n");
         push(@getOwnPropertySlotImpl, "        if (thisObject->nameGetter(state, propertyName, value)) {\n");
         push(@getOwnPropertySlotImpl, "            slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum, value);\n");
@@ -2234,7 +2241,9 @@
                 push(@implContent, "    }\n");
             }
 
-            if ($namedGetterFunction || $interface->extendedAttributes->{"CustomNamedGetter"}) {
+            # Indexing an object with an integer that is not a supported property index should not call the named property getter.
+            # https://heycam.github.io/webidl/#idl-indexed-properties
+            if (!$indexedGetterFunction && ($namedGetterFunction || $interface->extendedAttributes->{"CustomNamedGetter"})) {
                 &$propertyNameGeneration();
 
                 # This condition is to make sure we use the subclass' named getter instead of the base class one when possible.

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp (191586 => 191587)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp	2015-10-26 16:44:54 UTC (rev 191586)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp	2015-10-26 18:08:50 UTC (rev 191587)
@@ -157,7 +157,7 @@
     if (proto.isObject() && jsCast<JSObject*>(proto)->hasProperty(state, propertyName))
         return false;
 
-    if (thisObject->classInfo() == info()) {
+    if (!optionalIndex && thisObject->classInfo() == info()) {
         JSValue value;
         if (thisObject->nameGetter(state, propertyName, value)) {
             slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum, value);
@@ -176,14 +176,6 @@
         slot.setValue(thisObject, attributes, toJS(state, thisObject->globalObject(), thisObject->impl().item(index)));
         return true;
     }
-    Identifier propertyName = Identifier::from(state, index);
-    if (thisObject->classInfo() == info()) {
-        JSValue value;
-        if (thisObject->nameGetter(state, propertyName, value)) {
-            slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum, value);
-            return true;
-        }
-    }
     return Base::getOwnPropertySlotByIndex(thisObject, state, index, slot);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to