Skip to content

"Cross-origin objects" are to have enumerable properties - #6538

Merged
annevk merged 1 commit into
masterfrom
annevk/cross-origin-objects-enumerable
Jul 17, 2017
Merged

annevk merged 1 commit into
masterfrom
annevk/cross-origin-objects-enumerable

Conversation

@annevk

@annevk annevk commented Jul 13, 2017 •

Copy link
Copy Markdown
Member

@domenic domenic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, although maybe the commit message should also mention that it's testing the change to [[OwnPropertyKeys]]()

@annevk
annevk merged commit e63fd9b into master Jul 17, 2017
@cdumez

cdumez commented Jul 17, 2017

Copy link
Copy Markdown
Contributor

Do we still want to keep those checks in the test?

/*

  • [[Enumerate]]
    */

addTest(function() {
for (var prop in C)
assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Window");
for (var prop in C.location)
assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Location");
}, "[[Enumerate]] should return an empty iterator");

@cdumez

cdumez commented Jul 17, 2017

Copy link
Copy Markdown
Contributor

Claiming the properties are enumerable but then not being able to see them when enumerating seems broken to me?

@annevk

annevk commented Jul 18, 2017

Copy link
Copy Markdown
Member Author

Sigh. I wish I had spotted that before. https://tc39.github.io/ecma262/#sec-enumerate-object-properties uses [[OwnPropertyKeys]] ([[Enumerate]] is no more it seems) so named properties will still be hidden, but generally everything else should indeed enumerate. I'll write a patch.

@annevk
annevk deleted the annevk/cross-origin-objects-enumerable branch July 18, 2017 07:32
annevk added a commit that referenced this pull request Jul 18, 2017
@annevk

annevk commented Jul 18, 2017

Copy link
Copy Markdown
Member Author

See #6571 for the follow-up.

domenic pushed a commit that referenced this pull request Jul 18, 2017
@bzbarsky

Copy link
Copy Markdown
Contributor

Shouldn't there be tests for the behavior on non-cross-origin objects too? Or are there already?

propName = String(propName);
assert_true(isObject(desc), "property descriptor for " + propName + " should exist");
assert_equals(desc.enumerable, false, "property descriptor for " + propName + " should be non-enumerable");
assert_equals(desc.enumerable, true, "property descriptor for " + propName + " should be enumerable");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change is wrong. It should be comparing desc.enumerable to !isSymbol, because per spec the symbols should still be non-enumerable.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or branch on isSymbol to have nicer messages...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Surprised @cdumez didn't find this. Created #6583.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(Thanks by the way!)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My initial WebKit patch was also wrong so it was passing all the checks :(

@annevk

annevk commented Jul 19, 2017

Copy link
Copy Markdown
Member Author

I think same-origin is tested by html/dom/interfaces.html already.

@bzbarsky

Copy link
Copy Markdown
Contributor

I think same-origin is tested by html/dom/interfaces.html already.

Does that test the indexed props?

@annevk

annevk commented Jul 19, 2017

Copy link
Copy Markdown
Member Author

Adding a test for that now in the other PR. It seems that named properties are still non-enumerable in the same-origin case due to the named properties object setup and Window having LegacyUnenumerableNamedProperties.

@annevk

annevk commented Jul 19, 2017

Copy link
Copy Markdown
Member Author

(And FTR, that's tested already by html/browsers/the-window-object/window-named-properties.html.)

@domenic

domenic commented Jul 19, 2017

Copy link
Copy Markdown
Member

It seems that named properties are still non-enumerable in the same-origin case due to the named properties object setup and Window having LegacyUnenumerableNamedProperties.

Uhhh I see... Maybe the consistency argument is not so strong for switching "named properties" (i.e. those from the document-tree child browsing context name property set) to enumerable for cross-origin then? :-/.

@annevk

annevk commented Jul 19, 2017

Copy link
Copy Markdown
Member Author

@domenic given that cross-origin they're on a totally different object I think it's fine. We could maybe consider changing the same-origin setup, but maybe it's best to just leave it alone.

@domenic

domenic commented Jul 19, 2017

Copy link
Copy Markdown
Member

Well, but whatwg/html#2777 intent was

It makes all cross-origin properties that would normally be enumerable on same-origin objects, enumerable also on WindowProxy and Location objects (including when accessed same-origin).

Before that the spec had them as non-enumerable (i.e. same-origin WindowProxy and cross-origin WindowProxy both exposed them as non-enumerable). So maybe we should revert that part of the spec?

@annevk

annevk commented Jul 19, 2017

Copy link
Copy Markdown
Member Author

Well in one case they're on WindowProxy and in the other case they're on some prototype object (the named properties object). Looking at the Gecko patch it's probably easier if all cross-origin properties are enumerable consistently, though @bzbarsky can correct me.

@bzbarsky

Copy link
Copy Markdown
Contributor

In Gecko it's easy either way. The patch in Gecko just removes code that forced all cross-origin properties to be non-enumerable. The code that puts the named props on the cross-origin window is at http://searchfox.org/mozilla-central/rev/a83a4b68974aecaaacdf25145420e0fe97b7aa22/js/xpconnect/wrappers/XrayWrapper.cpp#2059-2076 and it would be quite simple to have it pass false for the optional fifth argument (enumerable) to FillPropertyDescriptor.

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Jul 19, 2017
…le. r=bholley

The list of exposed properties can be gotten via
Object.getOwnPropertyNames/Symbols already, so there's nothing to be won from
the non-enumerability.

The web platform test changes are backports of
web-platform-tests/wpt#6538 and
web-platform-tests/wpt#6571 and
web-platform-tests/wpt#6583

The js/xpconnect/tests/mochitest/*crossOriginObject* tests being removed are
just older versions of the web platfrom test.
@cdumez

cdumez commented Jul 19, 2017

Copy link
Copy Markdown
Contributor

I am a bit confused here. I understand we expose named properties on cross-origin windows (i.e. we allow looking up iframe by name). However, those frame names are NOT exposed cross-origin, are they? I believe doing so would leak cross-origin information and I thought this is why we had [[HideFromKeys]]: true for those crossOriginWindowProperties in the spec. If this is true, I don't think they should be enumerable either.

@bzbarsky

Copy link
Copy Markdown
Contributor

The set of frame names is not exposed cross-origin. That is, [[OwnPropertyKeys]] does not include them in its return value.

If you know a specific frame name, you can get the property.

Since the names are not returned by [[OwnPropertyKeys]], they're cannot be enumerated viaa for...in. So the only thing affected by whether they're enumerable is what getOwnPropertyDescriptor returns, afaict.

@annevk

annevk commented Jul 19, 2017

Copy link
Copy Markdown
Member Author

I'm happy with the specification as it stands now, but if folks feel strongly I can make more changes.

@cdumez

cdumez commented Jul 19, 2017

Copy link
Copy Markdown
Contributor

@bzbarsky Ok, this was my understanding. As a result, I don't think getOwnPropertyDescriptor() should lie and claim those properties are enumerable (as they are actually not).

@bzbarsky

Copy link
Copy Markdown
Contributor

It's not lying. It's just that "enumerable" in getOwnPropertyDescriptor is totally unrelated to whether for..in sees the property, if [[OwnPropertyKeys]] lies about whether the property exists at all...

Anyway, I don't have a very strong feeling about the named props issue, because it doesn't have any real practical impact; happy to implement whatever people decide on there.

@domenic

domenic commented Jul 19, 2017

Copy link
Copy Markdown
Member

I'm happy to stop churning on this and call it done.

@cdumez

cdumez commented Jul 19, 2017

Copy link
Copy Markdown
Contributor

Your call. I feel it would be cleaner for enumerable to be false but in the end, it does not really matter since there is no behavior difference.

JerryShih pushed a commit to JerryShih/gecko-dev that referenced this pull request Jul 20, 2017
…le. r=bholley

The list of exposed properties can be gotten via
Object.getOwnPropertyNames/Symbols already, so there's nothing to be won from
the non-enumerability.

The web platform test changes are backports of
web-platform-tests/wpt#6538 and
web-platform-tests/wpt#6571 and
web-platform-tests/wpt#6583

The js/xpconnect/tests/mochitest/*crossOriginObject* tests being removed are
just older versions of the web platfrom test.
leobalter pushed a commit to leobalter/gecko-dev that referenced this pull request Jul 20, 2017
…le. r=bholley

The list of exposed properties can be gotten via
Object.getOwnPropertyNames/Symbols already, so there's nothing to be won from
the non-enumerability.

The web platform test changes are backports of
web-platform-tests/wpt#6538 and
web-platform-tests/wpt#6571 and
web-platform-tests/wpt#6583

The js/xpconnect/tests/mochitest/*crossOriginObject* tests being removed are
just older versions of the web platfrom test.
aethanyc pushed a commit to aethanyc/gecko-dev that referenced this pull request Jul 24, 2017
…le. r=bholley

The list of exposed properties can be gotten via
Object.getOwnPropertyNames/Symbols already, so there's nothing to be won from
the non-enumerability.

The web platform test changes are backports of
web-platform-tests/wpt#6538 and
web-platform-tests/wpt#6571 and
web-platform-tests/wpt#6583

The js/xpconnect/tests/mochitest/*crossOriginObject* tests being removed are
just older versions of the web platfrom test.
jryans pushed a commit to jryans/gecko-dev that referenced this pull request Jul 25, 2017
…le. r=bholley

The list of exposed properties can be gotten via
Object.getOwnPropertyNames/Symbols already, so there's nothing to be won from
the non-enumerability.

The web platform test changes are backports of
web-platform-tests/wpt#6538 and
web-platform-tests/wpt#6571 and
web-platform-tests/wpt#6583

The js/xpconnect/tests/mochitest/*crossOriginObject* tests being removed are
just older versions of the web platfrom test.
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
…le. r=bholley

The list of exposed properties can be gotten via
Object.getOwnPropertyNames/Symbols already, so there's nothing to be won from
the non-enumerability.

The web platform test changes are backports of
web-platform-tests/wpt#6538 and
web-platform-tests/wpt#6571 and
web-platform-tests/wpt#6583

The js/xpconnect/tests/mochitest/*crossOriginObject* tests being removed are
just older versions of the web platfrom test.

UltraBlame original commit: be396a7cf55b4a3faebb5ac0f053cfca22199686
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 1, 2019
…le. r=bholley

The list of exposed properties can be gotten via
Object.getOwnPropertyNames/Symbols already, so there's nothing to be won from
the non-enumerability.

The web platform test changes are backports of
web-platform-tests/wpt#6538 and
web-platform-tests/wpt#6571 and
web-platform-tests/wpt#6583

The js/xpconnect/tests/mochitest/*crossOriginObject* tests being removed are
just older versions of the web platfrom test.

UltraBlame original commit: be396a7cf55b4a3faebb5ac0f053cfca22199686
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 1, 2019
…le. r=bholley

The list of exposed properties can be gotten via
Object.getOwnPropertyNames/Symbols already, so there's nothing to be won from
the non-enumerability.

The web platform test changes are backports of
web-platform-tests/wpt#6538 and
web-platform-tests/wpt#6571 and
web-platform-tests/wpt#6583

The js/xpconnect/tests/mochitest/*crossOriginObject* tests being removed are
just older versions of the web platfrom test.

UltraBlame original commit: be396a7cf55b4a3faebb5ac0f053cfca22199686
bhearsum pushed a commit to mozilla-releng/staging-firefox that referenced this pull request May 1, 2025
…le. r=bholley

The list of exposed properties can be gotten via
Object.getOwnPropertyNames/Symbols already, so there's nothing to be won from
the non-enumerability.

The web platform test changes are backports of
web-platform-tests/wpt#6538 and
web-platform-tests/wpt#6571 and
web-platform-tests/wpt#6583

The js/xpconnect/tests/mochitest/*crossOriginObject* tests being removed are
just older versions of the web platfrom test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants