Touch properties should be on the prototype
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jul 2016 02:24:20 +0000 (02:24 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jul 2016 02:24:20 +0000 (02:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160174

Reviewed by Ryosuke Niwa.

Source/WebCore:

Touch properties should be on the prototype:
- https://w3c.github.io/touch-events/#idl-def-touch

Chrome agrees with the specification.

Test: platform/ios-simulator/ios/touch/Touch-attributes-prototype.html

* bindings/scripts/CodeGeneratorJS.pm:
(InterfaceRequiresAttributesOnInstanceForCompatibility): Deleted.

LayoutTests:

Add layout test coverage.

* platform/ios-simulator/ios/touch/Touch-attributes-prototype-expected.txt: Added.
* platform/ios-simulator/ios/touch/Touch-attributes-prototype.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203707 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/ios-simulator/ios/touch/Touch-attributes-prototype-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-simulator/ios/touch/Touch-attributes-prototype.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

index 651720d..0d5cae5 100644 (file)
@@ -1,5 +1,17 @@
 2016-07-25  Chris Dumez  <cdumez@apple.com>
 
+        Touch properties should be on the prototype
+        https://bugs.webkit.org/show_bug.cgi?id=160174
+
+        Reviewed by Ryosuke Niwa.
+
+        Add layout test coverage.
+
+        * platform/ios-simulator/ios/touch/Touch-attributes-prototype-expected.txt: Added.
+        * platform/ios-simulator/ios/touch/Touch-attributes-prototype.html: Added.
+
+2016-07-25  Chris Dumez  <cdumez@apple.com>
+
         ClientRect properties should be on the prototype
         https://bugs.webkit.org/show_bug.cgi?id=160165
 
diff --git a/LayoutTests/platform/ios-simulator/ios/touch/Touch-attributes-prototype-expected.txt b/LayoutTests/platform/ios-simulator/ios/touch/Touch-attributes-prototype-expected.txt
new file mode 100644 (file)
index 0000000..8e8af96
--- /dev/null
@@ -0,0 +1,101 @@
+Checks that Touch attributes are on the prototype.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS touch.__proto__ is Touch.prototype
+PASS Object.getOwnPropertyNames(touch).length is 0
+
+* touch.__proto__.identifier
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* Touch.prototype.identifier
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* touch.__proto__.target
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* Touch.prototype.target
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* touch.__proto__.screenX
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* Touch.prototype.screenX
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* touch.__proto__.screenY
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* Touch.prototype.screenY
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* touch.__proto__.clientX
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* Touch.prototype.clientX
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* touch.__proto__.clientY
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* Touch.prototype.clientY
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* touch.__proto__.pageX
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* Touch.prototype.pageX
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* touch.__proto__.pageY
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* Touch.prototype.pageY
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* touch.__proto__.force
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+
+* Touch.prototype.force
+PASS descriptor.get is an instance of Function
+PASS descriptor.enumerable is true
+PASS descriptor.configurable is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/ios-simulator/ios/touch/Touch-attributes-prototype.html b/LayoutTests/platform/ios-simulator/ios/touch/Touch-attributes-prototype.html
new file mode 100644 (file)
index 0000000..bb0b458
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../../../resources/js-test-pre.js"></script>
+<script>
+description("Checks that Touch attributes are on the prototype.");
+
+var touch = new Touch({ identifier: 1, target: document.body });
+shouldBe("touch.__proto__", "Touch.prototype");
+shouldBe("Object.getOwnPropertyNames(touch).length", "0");
+
+function checkAttributeGetter(prototype, propertyName)
+{
+    descriptor = Object.getOwnPropertyDescriptor(prototype, propertyName);
+    shouldBeType("descriptor.get", "Function");
+    shouldBeTrue("descriptor.enumerable");
+    shouldBeTrue("descriptor.configurable");
+}
+
+for (var propertyName of ["identifier", "target", "screenX", "screenY", "clientX", "clientY", "pageX", "pageY", "force"]) {
+    debug("");
+    debug("* touch.__proto__." + propertyName);
+    checkAttributeGetter(touch.__proto__, propertyName);
+
+    debug("");
+    debug("* Touch.prototype." + propertyName);
+    checkAttributeGetter(Touch.prototype, propertyName);
+}
+</script>
+<script src="../../../../resources/js-test-post.js"></script>
+</body>
+</html>
index b70b552..3a75ca1 100644 (file)
@@ -1,3 +1,20 @@
+2016-07-25  Chris Dumez  <cdumez@apple.com>
+
+        Touch properties should be on the prototype
+        https://bugs.webkit.org/show_bug.cgi?id=160174
+
+        Reviewed by Ryosuke Niwa.
+
+        Touch properties should be on the prototype:
+        - https://w3c.github.io/touch-events/#idl-def-touch
+
+        Chrome agrees with the specification.
+
+        Test: platform/ios-simulator/ios/touch/Touch-attributes-prototype.html
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (InterfaceRequiresAttributesOnInstanceForCompatibility): Deleted.
+
 2016-07-25  Jeremy Jones  <jeremyj@apple.com>
 
         Set MediaRemote playback state based on MediaSession playback state.
index a00ae95..25beddc 100644 (file)
@@ -533,18 +533,6 @@ sub HasComplexGetOwnProperty
     return 0;
 }
 
-
-sub InterfaceRequiresAttributesOnInstanceForCompatibility
-{
-    my $interface = shift;
-    my $interfaceName = $interface->name;
-
-    # Needed for compatibility with existing content
-    return 1 if $interfaceName =~ "Touch";
-
-    return 0;
-}
-
 sub InterfaceRequiresAttributesOnInstance
 {
     my $interface = shift;
@@ -560,8 +548,6 @@ sub InterfaceRequiresAttributesOnInstance
     # FIXME: Add support for [PrimaryGlobal] / [Global].
     return 1 if IsDOMGlobalObject($interface) && $interface->name ne "WorkerGlobalScope";
 
-    return 1 if InterfaceRequiresAttributesOnInstanceForCompatibility($interface);
-
     return 0;
 }
 
@@ -2573,16 +2559,6 @@ sub GenerateImplementation
                 push(@implContent, "    if (UNLIKELY(!castedThis)) {\n");
                 if ($attribute->signature->extendedAttributes->{"LenientThis"}) {
                     push(@implContent, "        return JSValue::encode(jsUndefined());\n");
-                } elsif (InterfaceRequiresAttributesOnInstanceForCompatibility($interface)) {
-                    # Fallback to trying to searching the prototype chain for compatibility reasons.
-                    push(@implContent, "        JSObject* thisObject = JSValue::decode(thisValue).getObject();\n");
-                    push(@implContent, "        for (thisObject = thisObject ? thisObject->getPrototypeDirect().getObject() : nullptr; thisObject; thisObject = thisObject->getPrototypeDirect().getObject()) {\n");
-                    push(@implContent, "            if ((castedThis = " . GetCastingHelperForThisObject($interface) . "(thisObject)))\n");
-                    push(@implContent, "                break;\n");
-                    push(@implContent, "        }\n");
-                    push(@implContent, "        if (!castedThis)\n");
-                    push(@implContent, "            return throwGetterTypeError(*state, \"$interfaceName\", \"$name\");\n");
-                    push(@implContent, "        reportDeprecatedGetterError(*state, \"$interfaceName\", \"$name\");\n");
                 } else {
                     push(@implContent, "        return throwGetterTypeError(*state, \"$interfaceName\", \"$name\");\n");
                 }
@@ -2874,16 +2850,6 @@ sub GenerateImplementation
                 push(@implContent, "    if (UNLIKELY(!castedThis)) {\n");
                 if ($attribute->signature->extendedAttributes->{"LenientThis"}) {
                     push(@implContent, "        return false;\n");
-                } elsif (InterfaceRequiresAttributesOnInstanceForCompatibility($interface)) {
-                    # Fallback to trying to searching the prototype chain for compatibility reasons.
-                    push(@implContent, "        JSObject* thisObject = JSValue::decode(thisValue).getObject();\n");
-                    push(@implContent, "        for (thisObject = thisObject ? thisObject->getPrototypeDirect().getObject() : nullptr; thisObject; thisObject = thisObject->getPrototypeDirect().getObject()) {\n");
-                    push(@implContent, "            if ((castedThis = " . GetCastingHelperForThisObject($interface) . "(thisObject)))\n");
-                    push(@implContent, "                break;\n");
-                    push(@implContent, "        }\n");
-                    push(@implContent, "        if (!castedThis)\n");
-                    push(@implContent, "            return throwSetterTypeError(*state, \"$interfaceName\", \"$name\");\n");
-                    push(@implContent, "        reportDeprecatedSetterError(*state, \"$interfaceName\", \"$name\");\n");
                 } else {
                     push(@implContent, "        return throwSetterTypeError(*state, \"$interfaceName\", \"$name\");\n");
                 }