Skip to content

Setting a [PutForwards] attribute when the getter has been overridden doesn't seem to call the new getter  #25038

Closed

Description

@pshaughn

These are cases "Exception propagation from getter of [PutForwards] attribute" and "TypeError when getter of [PutForwards] attribute returns non-object" in WebIDL/ecmascript-binding/put-forwards.html.

In these, Element.style is overridden with a custom getter while keeping its setter the same, and then an element's style gets with a string. Because style is [PutForwards], this needs to put the set value forwards into .cssText, and WPT expects that process to call the getter; instead the getter is not being called.

Step 4.5.8 of the attribute setter in https://heycam.github.io/webidl/#es-attributes says to use Get here. I would guess Servo is instead looking under the hood directly at the original idl-defined Element.style slot in the Rust code, regardless of getter overrides.

Activity

  1. pshaughn commented on Dec 3, 2019

    @pshaughn
    ContributorAuthor

    Note distinction between overriding something on the "[PutForwards] attribute" (style here) and the "[PutForwards target attribute" (cssText here); this is not the same error as #25037 although the code fixes for the two might be adjacent.

  2. jdm commented on Dec 3, 2019

    @jdm
    Member

    Curiously, the generated code look like it it does a get operation:

    class CGSpecializedForwardingSetter(CGSpecializedSetter):
    """
    A class for generating the code for an IDL attribute forwarding setter.
    """
    def __init__(self, descriptor, attr):
    CGSpecializedSetter.__init__(self, descriptor, attr)
    def definition_body(self):
    attrName = self.attr.identifier.name
    forwardToAttrName = self.attr.getExtendedAttribute("PutForwards")[0]
    # JS_GetProperty and JS_SetProperty can only deal with ASCII
    assert all(ord(c) < 128 for c in attrName)
    assert all(ord(c) < 128 for c in forwardToAttrName)
    return CGGeneric("""\
    rooted!(in(*cx) let mut v = UndefinedValue());
    if !JS_GetProperty(*cx, obj, %s as *const u8 as *const libc::c_char, v.handle_mut()) {
    return false;
    }
    if !v.is_object() {
    throw_type_error(*cx, "Value.%s is not an object.");
    return false;
    }
    rooted!(in(*cx) let target_obj = v.to_object());
    JS_SetProperty(*cx, target_obj.handle(), %s as *const u8 as *const libc::c_char, HandleValue::from_raw(args.get(0)))
    """ % (str_to_const_array(attrName), attrName, str_to_const_array(forwardToAttrName)))

    I wonder if this is particular to the style attribute, or if it's a more general problem with other PutForwards attributes.

    Reference code for Firefox: https://searchfox.org/mozilla-central/rev/04d8e7629354bab9e6a285183e763410860c5006/dom/bindings/Codegen.py#9557-9587

  3. pshaughn commented on Dec 3, 2019

    @pshaughn
    ContributorAuthor

    The test isn't directly checking for the performance of the get operation itself; what would happen if the generated code's getter threw an exception or returned null? I was reading the lack of an exception in the test as an indication that the getter wasn't happening.

  4. pshaughn commented on Dec 3, 2019

    @pshaughn
    ContributorAuthor

    to do here: write a simpler test that proxies the getter with a counter to see if it's being called with bad output ignored vs. not called at all

  5. pshaughn commented on Dec 12, 2019

    @pshaughn
    ContributorAuthor

    PutForwards is actually commented out entirely in the relevant IDL and I hadn't noticed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/bindings

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions