Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Panos Astithas
On Thu, May 14, 2015 at 11:22 PM, Gijs Kruitbosch wrote: > My point is there will be just as many "unexpected" issues when you use > "===" on opaque variables, because you didn't expect that that code in that > other file set this thing to null instead of deleting the property (causing > it to no

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Jan-Ivar Bruaroey
On 5/14/15 4:22 PM, Gijs Kruitbosch wrote: On 14/05/2015 19:08, Martin Thomson wrote: If you intend to support false and null and undefined and NaN and attribute the same semantics, _say so_. Make it explicit. Don't make me (the person reading your code years later) that this is your intent.

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Gijs Kruitbosch
On 14/05/2015 23:15, Adam Roach wrote: On 5/14/15 16:33, Gijs Kruitbosch wrote: Can you give a concrete example where you had to change a contributor's patch in frontend gaia code to prefer === to prevent real bugs? From what I've seen, it's typically a matter of making the results unsurpri

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Gavin Sharp
> How many of these can you correctly predict the result of? Knowing Gijs, I know the answer is "all of them" :) This is certainly a factor in this discussion - how familiar you are with JS, and how much you use it every day, certainly affects your perspective. Gijs' (and my) experience is that u

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Adam Roach
On 5/14/15 16:33, Gijs Kruitbosch wrote: Can you give a concrete example where you had to change a contributor's patch in frontend gaia code to prefer === to prevent real bugs? From what I've seen, it's typically a matter of making the results unsurprising for subsequent code maintainers, be

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Gijs Kruitbosch
On 14/05/2015 22:55, Eric Rescorla wrote: On Thu, May 14, 2015 at 1:22 PM, Gijs Kruitbosch mailto:gijskruitbo...@gmail.com>> wrote: Maybe there is a difference with firefox browser JS and platform JS here (on which you seem to be working), in terms of which kinds of type confusion

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Gijs Kruitbosch
On 14/05/2015 21:45, Andrew Sutherland wrote: On 05/14/2015 04:22 PM, Gijs Kruitbosch wrote: "==" is not any less explicit than "===". Both versions have an exact, specified meaning. They both have exact meanings. But people, especially new contributors new to JS, frequently use "==" without

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Andrew Sutherland
On 05/14/2015 04:22 PM, Gijs Kruitbosch wrote: "==" is not any less explicit than "===". Both versions have an exact, specified meaning. They both have exact meanings. But people, especially new contributors new to JS, frequently use "==" without understanding the nuances and footguns involv

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Gijs Kruitbosch
On 14/05/2015 19:08, Martin Thomson wrote: On Thu, May 14, 2015 at 10:35 AM, Gijs Kruitbosch wrote: I mean, obviously the example is simplified. You seem to think that "===" means "I'm sure this will be the right type". In the same way you imply that == indicates uncertainty about type (or acce

Re: Question: How to spawn ServiceWorkers in the correct child on e10s and b2g?

2015-05-14 Thread Bobby Holley
On Thu, May 14, 2015 at 12:18 PM, wrote: > 1. What information do dependent APIs need to store? I can think of: > a) appID > b) inBrowserElement > c) origin > d) scope > e) (optional) manifestURL when appID is not UNKNOWN? > Can any or all of these be replaced by a nsIPrincipal and something else

Question: How to spawn ServiceWorkers in the correct child on e10s and b2g?

2015-05-14 Thread nsm . nikhil
Hello, As part of allowing various APIs (Push notifications, Notifications, BackgroundSync etc.) to use ServiceWorkers, we need some way to start them in the child process. I'm trying to figure out how to do this properly in e10s and on b2g. Here is an outline, I'm hoping someone with more know

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Boris Zbarsky
On 5/14/15 1:35 PM, Gijs Kruitbosch wrote: var foo = [1,2,3]; window.open('bar.html', '_blank', '', foo); in bar.html, checking the type of foo using instanceof with Array fails. For builtin Arrays we now have isArray, but this does not work for custom JS classes or DOM elements. Actually, DOM

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Martin Thomson
On Thu, May 14, 2015 at 10:35 AM, Gijs Kruitbosch wrote: > I mean, obviously the example is simplified. You seem to think that "===" > means "I'm sure this will be the right type". In the same way you imply that > == indicates uncertainty about type (or acceptance of multiple types), I > would arg

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Gijs Kruitbosch
On 14/05/2015 18:12, Martin Thomson wrote: On Thu, May 14, 2015 at 9:40 AM, Gijs Kruitbosch wrote: Crockford offers plenty of reasons in his book. I've not read Crockford's book and have no plans to, but there are plenty of reasons against, too. :-) Do you want me to send you a copy? No,

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Martin Thomson
On Thu, May 14, 2015 at 9:40 AM, Gijs Kruitbosch wrote: > Do you think the people that wrote the style guide (not me, so I'm not > trying to be defensive over the document, to be clear) did not understand > what they wrote? :-) No, but I do think that they were wrong. >> Crockford offers plenty

Re: Changing the style guide's preference for loose over strict equality checks in non-test code (was: Re: PSA: The mochitest ise() function is dead, please use is() instead)

2015-05-14 Thread Eric Rescorla
On Thu, May 14, 2015 at 9:14 AM, Martin Thomson wrote: > On Thu, May 14, 2015 at 5:17 AM, Gijs Kruitbosch > wrote: > > On 14/05/2015 01:21, Martin Thomson wrote: > >> > >> On Wed, May 13, 2015 at 4:54 PM, Matthew N. > >> wrote: > >>> > >>> "In JavaScript, == is preferred to ===." from > >>> > >

Re: Changing the style guide's preference for loose over strict equality checks in non-test code

2015-05-14 Thread Gijs Kruitbosch
On 14/05/2015 17:14, Martin Thomson wrote: On Thu, May 14, 2015 at 5:17 AM, Gijs Kruitbosch wrote: On 14/05/2015 01:21, Martin Thomson wrote: On Wed, May 13, 2015 at 4:54 PM, Matthew N. wrote: "In JavaScript, == is preferred to ===." from https://developer.mozilla.org/en-US/docs/Mozilla/D

Re: Changing the style guide's preference for loose over strict equality checks in non-test code (was: Re: PSA: The mochitest ise() function is dead, please use is() instead)

2015-05-14 Thread Martin Thomson
On Thu, May 14, 2015 at 5:17 AM, Gijs Kruitbosch wrote: > On 14/05/2015 01:21, Martin Thomson wrote: >> >> On Wed, May 13, 2015 at 4:54 PM, Matthew N. >> wrote: >>> >>> "In JavaScript, == is preferred to ===." from >>> >>> https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_St

Re: PSA: The mochitest ise() function is dead, please use is() instead

2015-05-14 Thread Ehsan Akhgari
On 2015-05-14 8:03 AM, Mike de Boer wrote: On 14 May 2015, at 03:15, Boris Zbarsky wrote: On 5/13/15 7:35 PM, Gregory Szorc wrote: I would steer people in the direction of Assert.jsm, specifically Assert.deepEqual This should be used very very carefully. As a very simple example, using th

Re: PSA: The mochitest ise() function is dead, please use is() instead

2015-05-14 Thread Boris Zbarsky
On 5/14/15 8:03 AM, Mike de Boer wrote: Same goes for Gecko wrapper objects, like `window`. When you want to use `deepEqual` with those, anyone should feel free to add support for it! Here's the thing. When comparing window objects, in what sense would anything other than === be useful? An

Re: Intent to remove: mochitest- mach commands

2015-05-14 Thread Andrew Halberstadt
On 13/05/15 06:29 PM, Gregory Szorc wrote: On Wed, May 13, 2015 at 2:03 PM, Ms2ger wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 05/13/2015 09:54 PM, Andrew Halberstadt wrote: As mentioned previously in another post, work is under way to remove the flavor specific mochitest command

Changing the style guide's preference for loose over strict equality checks in non-test code (was: Re: PSA: The mochitest ise() function is dead, please use is() instead)

2015-05-14 Thread Gijs Kruitbosch
On 14/05/2015 01:21, Martin Thomson wrote: On Wed, May 13, 2015 at 4:54 PM, Matthew N. wrote: "In JavaScript, == is preferred to ===." from https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Operators Ahh, that's where it was hiding. Can we reverse that statement

Re: PSA: The mochitest ise() function is dead, please use is() instead

2015-05-14 Thread James Graham
On 14/05/15 00:35, Gregory Szorc wrote: I would steer people in the direction of Assert.jsm, specifically Assert.deepEqual, which uses ObjectUtils.jsm goodness for type aware comparisons so things like Date, RegExp, and Object comparisons have sane behavior. (deepEqual falls back to === for non-s

Re: PSA: The mochitest ise() function is dead, please use is() instead

2015-05-14 Thread Mike de Boer
> On 14 May 2015, at 03:15, Boris Zbarsky wrote: > > On 5/13/15 7:35 PM, Gregory Szorc wrote: >> I would steer people in the direction of Assert.jsm, specifically >> Assert.deepEqual > > This should be used very very carefully. > > As a very simple example, using this (or worse yet notDeepEqua