{"action":"created","issue":{"url":"https://api.github.com/repos/heycam/webidl/issues/254","repository_url":"https://api.github.com/repos/heycam/webidl","labels_url":"https://api.github.com/repos/heycam/webidl/issues/254/labels{/name}","comments_url":"https://api.github.com/repos/heycam/webidl/issues/254/comments","events_url":"https://api.github.com/repos/heycam/webidl/issues/254/events","html_url":"https://github.com/heycam/webidl/issues/254","id":195093358,"number":254,"title":"Are operations on the `[[BackingMap]]` and `[[BackingSet]]` page-hookable?  And if not, why not?","user":{"login":"bzbarsky","id":1457979,"avatar_url":"https://avatars.githubusercontent.com/u/1457979?v=3","gravatar_id":"","url":"https://api.github.com/users/bzbarsky","html_url":"https://github.com/bzbarsky","followers_url":"https://api.github.com/users/bzbarsky/followers","following_url":"https://api.github.com/users/bzbarsky/following{/other_user}","gists_url":"https://api.github.com/users/bzbarsky/gists{/gist_id}","starred_url":"https://api.github.com/users/bzbarsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bzbarsky/subscriptions","organizations_url":"https://api.github.com/users/bzbarsky/orgs","repos_url":"https://api.github.com/users/bzbarsky/repos","events_url":"https://api.github.com/users/bzbarsky/events{/privacy}","received_events_url":"https://api.github.com/users/bzbarsky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-12-12T21:40:28Z","updated_at":"2016-12-12T22:05:32Z","closed_at":null,"body":"I was sure I had filed this before, but I can't find it...\r\n\r\nConsider this testcase:\r\n\r\n    <script>\r\n    Object.defineProperty(Set.prototype, \"size\", { value: 42 });\r\n    var set = document.fonts;\r\n    alert(set.size);\r\n    </script>\r\n\r\nWhat should get alerted?  Per spec as currently written we end up at https://heycam.github.io/webidl/#es-set-size we end up (in step 5) doing:\r\n\r\n> Return the result of calling the [[Get]] internal method of _set_ passing “size” and _set_ as arguments.\r\n\r\nwhere _set_ is the `[[BackingSet]]` of the object.  And the `[[BackingSet]]` is defined like so:\r\n\r\n> Any object that implements an interface that has a setlike declaration must have a [[BackingSet]] internal slot, which is initially set to a newly created Set object.\r\n\r\nSo what should get alerted?  Browsers alert 0 if there are no font-face rules.  As an implementor, I would prefer to alert 0 in general.  But if the `[[BackingSet]]` is created in the same Realm as the object itself, then you ought to get 42, right?\r\n\r\nWe should specify how this actually works.  I see three possible options:\r\n\r\n1.  Specify that the `[[BackingSet]]` is created in the global of the IDL object, leave everything as is.  Then this testcase should alert 42, which doesn't match browsers.\r\n2.  Specify that the `[[BackingSet]]` is created in a separate global, leave everything as is.  Then this testcase should alert 0.\r\n3.  Specify that the `size` getter invokes the original value of the `Set.prototype.size` getter.  Then this testcase should alert 0.  Same with the various other forwarding getters.\r\n\r\nOptions 2 and 3 are _not_ black-box identical.  The reason is that `entries` will return you an iterator, and you can tell which global the `Set`'s internal `entries` function comes from by looking at the prototype of that iterator.  In fact, you can distinguish not only options 2 and 3 from each other but also different variants of option 2 (e.g. a single separate global for all interfaces, one separate global per interface, one separate global per object, etc).\r\n\r\nMy personal feeling is that we should go with option 3, with the `[[BackingSet]]` created in the IDL object's global.  That's certainly how maplike/setlike are implemented in Gecko.  Note that FontFaceSet is NOT implemented as a setlike in Gecko for the moment, though.  It looks like we ship no actual setlikes so far, and only one maplike: RTCStatsReport.  Unfortunately, I have yet to figure out how to get my hands on an RTCStatsReport to see how it behaves in other browsers...\r\n\r\nDoing black-box testing of FontFaceSet in Blink, it looks like the iterator it returns from `entries()` doesn't have `%SetIteratorPrototype%` (from any global) as its prototype.  So Blink is not following the spec for this part either so far.  Grepping Blink's idl, this is the only setlike, and the only maplikes are the MIDIInput/OutputMaps.  Those don't use an object with `%MapIteratorPrototype%` as its proto either.  That makes it hard to tell whether Blink is doing option 2 or option 3, of course, since at least for `entries` it's not doing either one.\r\n\r\n@tobie @domenic @heycam @annevk "},"comment":{"url":"https://api.github.com/repos/heycam/webidl/issues/comments/266567822","html_url":"https://github.com/heycam/webidl/issues/254#issuecomment-266567822","issue_url":"https://api.github.com/repos/heycam/webidl/issues/254","id":266567822,"user":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"created_at":"2016-12-12T22:05:32Z","updated_at":"2016-12-12T22:05:32Z","body":"I assume engines would still keep supporting them as abstractions, e.g. as C++ ordered maps. Both Web IDL maplikes and JS engine Maps could keep C++ ordered maps, and you'd create a MapIterator from such C++ ordered maps."}}
{"actor":{"display_login":"domenic"}}