-
Notifications
You must be signed in to change notification settings - Fork 71
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
Validate IDL against implementations #26
Comments
time@domenic Interested in this. Regarding I thought it was pretty weird that in Chrome and Firefox: obj = {};
obj[{ toString() {throw new Error('nooo')} }] = 10; throws while ...which shows that In Firefox this is different, as If Sorry if some of those examples are a little beyond the scope of this issue. Are the implementations expected to throw if conversion throws, as opposed to do some sneaky I'm learning more about specs & IDL so I checked out the DOMString section of the IDL spec and found that One more thing (sorry), in Firefox countIn Chrome, In Firefox, With all this being said, I'm guessing the spec is reasonable and the implementations need to be consistent and possible perform |
@domfarolino oh, thanks for the great investigation! The rules for DOMString that are most relevant are the conversion from a JavaScript value. That mostly delegates to the ECMAScript ToString algorithm, which will e.g. convert The current IDL, of
In particular, any exceptions should be rethrown, and any values returned from a It sounds like this is not the case for Chrome, and Firefox does some kind of error-swallowing (although maybe try adding a |
Thanks so much for the information. Quick question about some of the abstract operations. You indicated that the String constructor function closely simulates the time/timeEndDefault ParameterThis bin can be used to test the correctness of the default parameter currently defined in the IDL. The actual console/devtools will need to be opened in order to see the printing that
DOMString conversionAgain, it might help having DevTools open while running this to see the actual console output. Basic test case in jsbin designed to run
It seems clear that Safari's implementation most closely follows the spec, if you want to test Edge and whatever else I may be missing (opera?) that would be great! Also, should we standardize at all one what happens when we call |
The abstract operations are factored-out algorithms that are called from many different parts of the spec. In fact if you go to https://tc39.github.io/ecma262/#sec-tostring, hover your mouse over the heading, and click "References", you can find all the places in the spec that use it. I don't believe there is anything that directly exposes it to a JavaScript-callable function, but many JavaScript-callable functions use it as part of a larger algorithm (e.g. it is the first step in parseFloat/parseInt/decodeURI/... many others).
Great test! I ran it in Edge and it matches Safari. So that's great news. We have 2/4 browsers completely spec-complaint, with Chrome almost there. So in this respect I think we should work on filing a couple browser bugs.
Edge gives:
This seems kind of similar to Firefox except that it's warning about timeEnd on a non-existant timer, which is I guess a separate issue. I can't tell whether it started a timer, or what name it would use if it did. So this one's trickier. We have:
Of these, (3) seems very strange; let's not do that. Between (1) and (2) it's trickier. I tend to think that (2) is much nicer; it can be specified with Web IDL, and matches the rest of the platform better. I'm not sure if that outweighs the fact that it's outnumbered, but I think since it's only outnumbered 2-to-1 instead of 3-to-1, it probably does. So again I'd tend toward filing bugs on different implementations... In this particular case, we can also write web platform tests demanding that the exception be rethrown, which is great. |
Awesome, it's nice this stuff is getting cleaned up a bit. I agree (2) is much better. So we'll need to file the following bugs:
I can file these this week, mentioning you/this issue for clarification. You indicated that (2)'s behavior can be specified with Web IDL...is there something we can do in IDL (besides comments) that indicates this function may (re-)throw an exception, or is it all good how it is and the implementations just need to catch up? I'm definitely interested in the web platform tests. I've spent some time reading up on the |
This is a pretty standard consequence. Part of the issue is that not all implementations use Web IDL to implement their console, so this needs more careful testing than usual, as you've noticed.
Flat makes sense to me as there aren't many components, but I'll review over in that PR that I see you opened :D. In general, I wonder if we should split this issue into separate issues for each API? We've spent some good time on this thread working through time/timeEnd, and it might be nice to have a separate thread for finishing count, or for table, or similar. |
I agree with splitting this up. I'll make an issue for |
Oh, it's also worth noting that |
@domenic Before possibly breaking assert validation into its own thread I want to verify that it might not be needed? Checking out 3.2.3 boolean in Web IDL shows that it largely delegates to ToBoolean() which is actually the end of the chain as far as type coercion goes. This is nice because the table in ES states that just about every possible input has a corresponding primitive output (even objects!). This means This behavior is consistent on:
I've filed the last bug (edge) for the time/timeEnd() label conversion, so I assume we close this issue when all implementations catch up to the spec, namely when the filed issues are "closed" right? |
Oh, you're totally right; I forgot ToBoolean semantics! Great catch.
In general it's not the spec's job to track implementation compliance, as long as we've done our homework on filing bugs. However since this is a small spec it might be feasible to keep a tracking document of all bugs we file (similar to, or maybe inside of, NOTES.md) so that people can watch the progress on getting them fixed. So I think it's OK to close this (and split out table into a separate issue, or maybe use #21). |
For the
any...
methods, I assume they are probably valid. But for the ones that include type conversions, we need to check. For example:console.time({ toString() { throw new Error("boo"); } })
does not throw; in Chrome, it does. Chrome at least seems to followtime(DOMString label)
.console.count({ toString() { throw new Error("boo"); } })
does not throw in Chrome. Socount(optional DOMString label = "")
doesn't seem quite right.console.table({}, (function*() { yield "a"; throw new Error("b"); }()))
doesn't seem to throw. Sotable(any tabularData, optional sequence<DOMString> properties)
doesn't seem right. This is related to console.table algorithm #21.The text was updated successfully, but these errors were encountered: