Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check ignoreNamedProps before the named property visibility algorithm. #625

Merged
merged 1 commit into from Jan 31, 2019
Merged

Check ignoreNamedProps before the named property visibility algorithm. #625

merged 1 commit into from Jan 31, 2019

Conversation

Ms2ger
Copy link
Member

@Ms2ger Ms2ger commented Jan 17, 2019

Running the named property visibility algorithm is (or should be) observable
by inserting a proxy in the prototype chain. This changes the spec to match
Gecko's behavior.


Preview | Diff

@Ms2ger
Copy link
Member Author

Ms2ger commented Jan 17, 2019

This assumes that we all agree that "and" short-circuits; I'm not actually sure that's well-defined.

@bzbarsky
Copy link
Collaborator

Funtimes. I think it might be clearer to just nest:

  1. If O supports named properties and ignoreNamedProps is false, then:
    1. If the result of running the named property visibility algorithm with property name P and object O is true, then:

Either way, we should probably have tests.

@annevk
Copy link
Member

annevk commented Jan 17, 2019

I somewhat prefer @bzbarsky's phrasing. If there can be side effects when determining a particular thing, let's do it as a separate step.

cc @domenic

@Ms2ger
Copy link
Member Author

Ms2ger commented Jan 18, 2019

Fixed.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I guess we should wait with landing this until there's tests?

index.bs Outdated Show resolved Hide resolved
index.bs Outdated
1. Set |desc|.\[[Configurable]] to <emu-val>true</emu-val>.
1. Return |desc|.
1. If |O| [=support named properties|supports named properties=] and
|ignoreNamedProps| is false:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually if statements are followed by: ", then:". Or does IDL use a different style?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like this to be addressed, given that we do use then on the subsequent line. Perhaps some kind of editorial issue needs to be filed to make sure we're consistent.

(As far as I can tell this PR is otherwise okay.)

@littledan
Copy link
Collaborator

Can you test this in some non-Gecko browsers as well?

@bzbarsky
Copy link
Collaborator

@littledan It's worth testing in Safari. Testing in Chrome... given #607 (comment) Chrome is not even trying to follow the spec here, so I doubt testing in Chrome will tell us much, but we could try. Interpreting the results of black-box tests is pretty complicated when you have no idea what the underlying model might look like.

@Ms2ger
Copy link
Member Author

Ms2ger commented Jan 22, 2019

I haven't yet been able to observe the named property visibility algorithm in either Chrome or WebKit, which makes this change unobservable there.

Test case
<!DOCTYPE html>
<script>
sessionStorage.clear();
sessionStorage.__proto__ = new Proxy(Storage.prototype, {
  has(_, p) { w("has " + p); return true; },
  get(_, p) { w("get " + p); return "from proto" },
});
w("===========");
w(sessionStorage.x);
w("===========");
sessionStorage.x = "foo";
w("===========");
w(sessionStorage.x);
w("===========");
</script>

Chrome and WebKit:

log: ===========
log: get x
log: from proto
log: ===========
log: ===========
log: foo
log: ===========

Gecko:

log: ===========
log: has x
log: get x
log: from proto
log: ===========
log: has x
log: ===========
log: has x
log: get x
log: from proto
log: ===========

@bzbarsky
Copy link
Collaborator

I'm a little confused by that testcase, actually. Shouldn't it use a proxy for "localStorage" or "sessionStorage" or something, not "Storage.prototype"? There should be no named property visibility stuff involved with "Storage.prototype".

@Ms2ger
Copy link
Member Author

Ms2ger commented Jan 23, 2019

I'm more than a little confused by it myself now; looks like I somehow merged two different test cases. Should be better now, and still shows that the change isn't observable in Chrome/WebKit.

@annevk
Copy link
Member

annevk commented Jan 31, 2019

For clarity, #625 (comment) remains outstanding here.

Running the named property visibility algorithm is (or should be) observable
by inserting a proxy in the prototype chain. This changes the spec to match
Gecko's behavior.
@Ms2ger Ms2ger merged commit a9673c8 into whatwg:master Jan 31, 2019
@Ms2ger Ms2ger deleted the ignoreNamedProps-reorder branch January 31, 2019 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants