Title: [217895] trunk
Revision
217895
Author
[email protected]
Date
2017-06-07 11:57:26 -0700 (Wed, 07 Jun 2017)

Log Message

[WebIDL] PutForwards is not implemented to spec as illustrated by the WPT WebIDL/ecmascript-binding/put-forwards.html
https://bugs.webkit.org/show_bug.cgi?id=172956

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Update results to show we now implement [PutForwards] correctly.

* web-platform-tests/WebIDL/ecmascript-binding/put-forwards-expected.txt:

Source/WebCore:

Implements step 3.5.9 of https://heycam.github.io/webidl/#dfn-attribute-setter.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateAttributeSetterDefinition):
Implement [PutForwards] to spec, which involves using JSC get/set rather than calling
directly into the implementation.

* bindings/scripts/test/JS/JSTestCEReactions.cpp:
* bindings/scripts/test/JS/JSTestObj.cpp:
Update test results.

LayoutTests:

* http/tests/security/xss-DENIED-contentWindow-eval-expected.txt:
Update results to show that we now throw a type error, because the action now requires
an explicit get of the location object, which does not work in the context.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (217894 => 217895)


--- trunk/LayoutTests/ChangeLog	2017-06-07 18:41:09 UTC (rev 217894)
+++ trunk/LayoutTests/ChangeLog	2017-06-07 18:57:26 UTC (rev 217895)
@@ -1,3 +1,14 @@
+2017-06-07  Sam Weinig  <[email protected]>
+
+        [WebIDL] PutForwards is not implemented to spec as illustrated by the WPT WebIDL/ecmascript-binding/put-forwards.html
+        https://bugs.webkit.org/show_bug.cgi?id=172956
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/security/xss-DENIED-contentWindow-eval-expected.txt:
+        Update results to show that we now throw a type error, because the action now requires
+        an explicit get of the location object, which does not work in the context.
+
 2017-06-07  Antoine Quint  <[email protected]>
 
         Rebaseline and enable media/modern-media-controls/controls-visibility-support

Modified: trunk/LayoutTests/http/tests/security/xss-DENIED-contentWindow-eval-expected.txt (217894 => 217895)


--- trunk/LayoutTests/http/tests/security/xss-DENIED-contentWindow-eval-expected.txt	2017-06-07 18:41:09 UTC (rev 217894)
+++ trunk/LayoutTests/http/tests/security/xss-DENIED-contentWindow-eval-expected.txt	2017-06-07 18:57:26 UTC (rev 217895)
@@ -1 +1,2 @@
+CONSOLE MESSAGE: line 1: TypeError: Type error
 This test passes if alert() is not called. 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (217894 => 217895)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-06-07 18:41:09 UTC (rev 217894)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-06-07 18:57:26 UTC (rev 217895)
@@ -1,3 +1,14 @@
+2017-06-05  Sam Weinig  <[email protected]>
+
+        [WebIDL] PutForwards is not implemented to spec as illustrated by the WPT WebIDL/ecmascript-binding/put-forwards.html
+        https://bugs.webkit.org/show_bug.cgi?id=172956
+
+        Reviewed by Chris Dumez.
+
+        Update results to show we now implement [PutForwards] correctly.
+
+        * web-platform-tests/WebIDL/ecmascript-binding/put-forwards-expected.txt:
+
 2017-06-06  Darin Adler  <[email protected]>
 
         Update to slightly stricter rules for custom element names from more recent standard draft

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/put-forwards-expected.txt (217894 => 217895)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/put-forwards-expected.txt	2017-06-07 18:41:09 UTC (rev 217894)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebIDL/ecmascript-binding/put-forwards-expected.txt	2017-06-07 18:57:26 UTC (rev 217895)
@@ -1,14 +1,8 @@
 
-FAIL Overriding getter of [PutForwards] attribute assert_true: Overridden getter should be called expected true got false
-FAIL Overriding setter of [PutForwards] target attribute assert_true: Overridden setter should be called expected true got false
-FAIL Overriding target of [PutForwards] attribute assert_equals: Original value intact expected "" but got "color: green;"
-FAIL Exception propagation from getter of [PutForwards] attribute assert_throws: function "() => {
-    element.style = "color: green";
-  }" did not throw
-FAIL Exception propagation from setter of [PutForwards] target attribute assert_throws: function "() => {
-    element.style = "color: green";
-  }" did not throw
-FAIL TypeError when getter of [PutForwards] attribute returns non-object assert_throws: function "() => {
-    element.style = "color: green";
-  }" did not throw
+PASS Overriding getter of [PutForwards] attribute 
+PASS Overriding setter of [PutForwards] target attribute 
+PASS Overriding target of [PutForwards] attribute 
+PASS Exception propagation from getter of [PutForwards] attribute 
+PASS Exception propagation from setter of [PutForwards] target attribute 
+PASS TypeError when getter of [PutForwards] attribute returns non-object 
 

Modified: trunk/Source/WebCore/ChangeLog (217894 => 217895)


--- trunk/Source/WebCore/ChangeLog	2017-06-07 18:41:09 UTC (rev 217894)
+++ trunk/Source/WebCore/ChangeLog	2017-06-07 18:57:26 UTC (rev 217895)
@@ -1,3 +1,21 @@
+2017-06-07  Sam Weinig  <[email protected]>
+
+        [WebIDL] PutForwards is not implemented to spec as illustrated by the WPT WebIDL/ecmascript-binding/put-forwards.html
+        https://bugs.webkit.org/show_bug.cgi?id=172956
+
+        Reviewed by Chris Dumez.
+
+        Implements step 3.5.9 of https://heycam.github.io/webidl/#dfn-attribute-setter.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateAttributeSetterDefinition):
+        Implement [PutForwards] to spec, which involves using JSC get/set rather than calling
+        directly into the implementation.
+
+        * bindings/scripts/test/JS/JSTestCEReactions.cpp:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        Update test results.
+
 2017-06-07  Jer Noble  <[email protected]>
 
         Clean-up: RenderElement.h includes headers it doesn't use

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (217894 => 217895)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2017-06-07 18:41:09 UTC (rev 217894)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2017-06-07 18:57:26 UTC (rev 217895)
@@ -4573,35 +4573,36 @@
         } else {
             push(@implContent, "    return thisObject.putDirect(state.vm(), Identifier::fromString(&state, \"$name\"), value);\n");
         }
+    } elsif ($attribute->extendedAttributes->{PutForwards}) {
+        assert("[PutForwards] is not compatible with static attributes") if $attribute->isStatic;
+        
+        # 3.5.9.1. Let Q be ? Get(O, id).
+        my $id = $attribute->name;
+        push(@implContent, "    auto id = Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>(\"${id}\"), strlen(\"${id}\"));\n");
+        push(@implContent, "    auto valueToForwardTo = thisObject.get(&state, id);\n");
+        push(@implContent, "    RETURN_IF_EXCEPTION(throwScope, false);\n");
+        
+        # 3.5.9.2. If Type(Q) is not Object, then throw a TypeError.
+        push(@implContent, "    if (UNLIKELY(!valueToForwardTo.isObject())) {\n");
+        push(@implContent, "        throwTypeError(&state, throwScope);\n");
+        push(@implContent, "        return false;\n");
+        push(@implContent, "    }\n");
+        
+        # 3.5.9.3. Let forwardId be the identifier argument of the [PutForwards] extended attribute.
+        my $forwardId = $attribute->extendedAttributes->{PutForwards};
+        push(@implContent, "    auto forwardId = Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>(\"${forwardId}\"), strlen(\"${forwardId}\"));\n");
+        
+        # 3.5.9.4. Perform ? Set(Q, forwardId, V).
+        # FIXME: What should the second value to the PutPropertySlot be?
+        # (https://github.com/heycam/webidl/issues/368)
+        push(@implContent, "    PutPropertySlot slot(valueToForwardTo, false);\n");
+        push(@implContent, "    asObject(valueToForwardTo)->methodTable(state.vm())->put(asObject(valueToForwardTo), &state, forwardId, value, slot);\n");
+        push(@implContent, "    RETURN_IF_EXCEPTION(throwScope, false);\n");
+        
+        push(@implContent, "    return true;\n");
     } else {
-        if (!$attribute->isStatic) {
-            my $putForwards = $attribute->extendedAttributes->{PutForwards};
-            if ($putForwards) {
-                my $implGetterFunctionName = $codeGenerator->WK_lcfirst($attribute->extendedAttributes->{ImplementedAs} || $name);
-                my $forwardedAttribute = $codeGenerator->GetAttributeFromInterface($interface, $type->name, $putForwards);
-
-                if ($forwardedAttribute->extendedAttributes->{CEReactions}) {
-                    push(@implContent, "    CustomElementReactionStack customElementReactionStack;\n");
-                    AddToImplIncludes("CustomElementReactionQueue.h", $conditional);
-                }
-
-                if ($type->isNullable) {
-                    push(@implContent, "    RefPtr<" . $type->name . "> forwardedImpl = thisObject.wrapped().${implGetterFunctionName}();\n");
-                    push(@implContent, "    if (!forwardedImpl)\n");
-                    push(@implContent, "        return false;\n");
-                    push(@implContent, "    auto& impl = *forwardedImpl;\n");
-                } else {
-                    # Attribute is not nullable, the implementation is expected to return a reference.
-                    push(@implContent, "    Ref<" . $type->name . "> forwardedImpl = thisObject.wrapped().${implGetterFunctionName}();\n");
-                    push(@implContent, "    auto& impl = forwardedImpl.get();\n");
-                }
-                $attribute = $forwardedAttribute;
-                $type = $attribute->type;
-            } else {
-                push(@implContent, "    auto& impl = thisObject.wrapped();\n");
-            }
-        }
-
+        push(@implContent, "    auto& impl = thisObject.wrapped();\n") if !$attribute->isStatic;
+       
         if ($codeGenerator->IsEnumType($type)) {
             # As per section 3.5.6 of https://heycam.github.io/webidl/#dfn-attribute-setter, enumerations do not use
             # the standard conversion, but rather silently fail on invalid enumeration values.

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCEReactions.cpp (217894 => 217895)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCEReactions.cpp	2017-06-07 18:41:09 UTC (rev 217894)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCEReactions.cpp	2017-06-07 18:57:26 UTC (rev 217895)
@@ -262,12 +262,17 @@
 {
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
-    CustomElementReactionStack customElementReactionStack;
-    Ref<TestCEReactionsStringifier> forwardedImpl = thisObject.wrapped().stringifierAttribute();
-    auto& impl = forwardedImpl.get();
-    auto nativeValue = convert<IDLDOMString>(state, value);
+    auto id = Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("stringifierAttribute"), strlen("stringifierAttribute"));
+    auto valueToForwardTo = thisObject.get(&state, id);
     RETURN_IF_EXCEPTION(throwScope, false);
-    impl.setValue(WTFMove(nativeValue));
+    if (UNLIKELY(!valueToForwardTo.isObject())) {
+        throwTypeError(&state, throwScope);
+        return false;
+    }
+    auto forwardId = Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("value"), strlen("value"));
+    PutPropertySlot slot(valueToForwardTo, false);
+    asObject(valueToForwardTo)->methodTable(state.vm())->put(asObject(valueToForwardTo), &state, forwardId, value, slot);
+    RETURN_IF_EXCEPTION(throwScope, false);
     return true;
 }
 

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2017-06-07 18:41:09 UTC (rev 217894)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2017-06-07 18:57:26 UTC (rev 217895)
@@ -4760,11 +4760,17 @@
 {
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
-    Ref<TestNode> forwardedImpl = thisObject.wrapped().putForwardsAttribute();
-    auto& impl = forwardedImpl.get();
-    auto nativeValue = convert<IDLDOMString>(state, value);
+    auto id = Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("putForwardsAttribute"), strlen("putForwardsAttribute"));
+    auto valueToForwardTo = thisObject.get(&state, id);
     RETURN_IF_EXCEPTION(throwScope, false);
-    impl.setName(WTFMove(nativeValue));
+    if (UNLIKELY(!valueToForwardTo.isObject())) {
+        throwTypeError(&state, throwScope);
+        return false;
+    }
+    auto forwardId = Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("name"), strlen("name"));
+    PutPropertySlot slot(valueToForwardTo, false);
+    asObject(valueToForwardTo)->methodTable(state.vm())->put(asObject(valueToForwardTo), &state, forwardId, value, slot);
+    RETURN_IF_EXCEPTION(throwScope, false);
     return true;
 }
 
@@ -4791,13 +4797,17 @@
 {
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
-    RefPtr<TestNode> forwardedImpl = thisObject.wrapped().putForwardsNullableAttribute();
-    if (!forwardedImpl)
+    auto id = Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("putForwardsNullableAttribute"), strlen("putForwardsNullableAttribute"));
+    auto valueToForwardTo = thisObject.get(&state, id);
+    RETURN_IF_EXCEPTION(throwScope, false);
+    if (UNLIKELY(!valueToForwardTo.isObject())) {
+        throwTypeError(&state, throwScope);
         return false;
-    auto& impl = *forwardedImpl;
-    auto nativeValue = convert<IDLDOMString>(state, value);
+    }
+    auto forwardId = Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("name"), strlen("name"));
+    PutPropertySlot slot(valueToForwardTo, false);
+    asObject(valueToForwardTo)->methodTable(state.vm())->put(asObject(valueToForwardTo), &state, forwardId, value, slot);
     RETURN_IF_EXCEPTION(throwScope, false);
-    impl.setName(WTFMove(nativeValue));
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to