My JavaScript book is out! Don't miss the opportunity to upgrade your beginner or average dev skills.

Wednesday, January 22, 2014

testardo - A Browser Agnostic JS Web Driver

you might think there are already so many solutions out there for testing browsers on real domains or real network interactions ... well, let me tell you why this is unfortunately not the reality until the point I show you ./testardo in action, bear with me please!

Selenium Ain't Portable

Despite being a wonderful project, Selenium WebDriver is great for Desktop but its Mobile Browser Version counter part is limited in terms of both supported platforms and supported browsers per platform.
In few words, Selenium is not suitable for all Mobile, Tablets, and Desktop browsers plus it requires knowledge of more than just JavaScript which is luckily, or unfortunately for others, the only programming language every browser understands today or did understand yesterday as well as the main one learned by Web Developers.

Simulators Are Liars

If you still trust simulators through your debugging tool, I've got a bad news for you: these are simply unreliable!
Starting from the real way events are dispatched and devices behaves compared with the browser engine you are testing on your Desktop, simulators might not be even able to give you a close scenario.
Look at this Chrome Bug to start with, for example, then realize also code behind your mobile browser is far from close to the one you are likely running on Desktop.
Not only unreliable then, simulators also give you a very fake idea of how performance will be, once landed on a real device.

Pay For Browser Testing ... No Thanks!

If testing is already something many companies and developers do not even invest some time that will inevitably pay back in both the short and the long term, imagine them investing time and money to have some test that will inevitably suffer cross browser and platform compatibility ... basically all available options I've considered and dropped these days.

Thanks Addy Anyway!

Addy Osmani has written excellent articles about testing, provided slides, examples, videos, but still there's not a complete solution.
While I really appreciate the work Addy is doing for the whole community about this field and for both client and server side world, I am pretty sure he would agree with me there's still not a simple to configure, simple to use, zero-stress config, and zero-spent money, testing solutions that satisfy the Web in its integrity, and for every old or modern device.

Episode IV - A New Hope

Considering Addy slides on Mobile Web Development Workflow, I will use same comparison points he used for those tools ... still talking about what testardo is, and what it can do at this stage.
  • [+] Free!
  • [+] Cross Platform
  • [+] Supports live reload
  • [+] Remote Inspect where supported
  • [+] Easily see how each change you save looks across devices
  • [+] Work with any modern AND not so modern Desktop and Mobile browser
  • [+] Does NOT Require you to install a package or extension
  • [+] Allows to match up scrolling and input
  • [+] Change urls and domain without needing to do that on devices
  • [-] Loads page into iframe
Long story short, almost every "plus" in Addy slides was actually a goal to reach with ./testardo, plus more:
  • [+] Loads external pages within a specific domain session
  • [+] Works and notifies even remotely
  • [+] If specified, it sends emails to the specified address and only once in order to not bother much if you are far away from "your free-time project" over the week end.
  • [+] It's entirely written in JavaScript and JavaScript is the only thing you need to know
  • [+] It allows you to inject before each test one or more external library as dependency (jQuery or others)
  • [+] It simulates as much as possible real DOM events triggered by users (note: at this time only the writing has been tested properly)
  • [+] It gives you an instant feedback with a green, yellow, or red with the eventual Error message notifying success, waiting for, or failure and the reason
  • [+] ... MOAR COMING ...
not convinced yet? Still no clue what is all this about?

testardo Live Demo

OK, the warning here is: take this video as a quick demo with a crappy setup as my home Wi-Fi router is, and considering testardo is at version 0.1.0 at the time I write this, thank you for your understanding :-)
So, here the video!

testardo - a browser and OS agnostic JS driver from Andrea Giammarchi on Vimeo.

Where, What, and How

So, everything is Open Source in Github and you are very welcome to contribute and help any way you can.
The single file you need is the built one but if you have node.js and npm installed, this is al you need to use testardo:
npm install -g testardo
After this, you should be able to run cross platform any test you want, where each test should be a module exports, similar to the one showed in this example.
I am trying to write a much better and complete documentation, right now you can find basically all you want to know and all you need inside the file itself, or simply running testardo without arguments.

Thank You All for your patience and Happy Testing!

Friday, January 10, 2014

[Webadamus] The Second Profecy

For who's not remembering, in 2009 I wrote a post about the future and it was actually quite accurate in its predictions:
  1. the blacktwit idea materialized via blocking action and anti spam features
  2. the twitcode materialized through a community called
  3. the twitter private service didn't land as I was expecting, but targeted and advanced ads are now part of the service
  4. Internet Explorer 9 has been the new direction, advanced browser, we were all waiting for, the one that marked the end of JScript, the one that for the first time claimed W3C standards with its engine
  5. Google OS still hasn't flied
  6. Apple introduced the fingerprints as password, others introduced 2 steps authentication to improve security
Basically all points became reality so I've decided to repeat the experiment .. I mean, what could be a better way to start the new year?
This time, due changes in the industry, it won't be strictly related to an online service or web development, this time is about tech in all its fields.
Bear in mind these are not necessarily related to this year, rather the following years of hi-tech ... ready?

The Microsoft Ongoing Decline

I have a sort of love/hate situation with this company but I am trying to be objective here:
  • wearable, embedded, Internet of Things, flying droids, watches, you name it ... there is not a bloody single new/innovative device in modern era that puts a Windows name or logo in its container: Linux, and Wrt, Android, iOS, Intel, ARM, these are the daily buzzwords in the industry since about 2 years ... no Microsoft, no Windows, it seems to me there is no space for MS software anywhere if not in good-old PCs that are selling everyday less than before
  • even if the beagleboard black has a version of Windows CE with amazing HW Acceleration capabilities ... nobody ever talked about it since it costs a fortune compared with any dev board or Android based device or TV dongle
  • Surface might sell but Microsoft is not an HW Company and the fact Windows should run in so many devices cannot make the OS easily updatable as iOS or OS X and their little circle of machines is
Dear Microsoft, I suggest you stop ignoring all developers boards, all ARM oriented projects, inevitably on Linux, and all Arduino or Raspberry PI things happening out there ... here a hint: everyone with a developer board would love to have decent drivers to use the tiny GPU at its best ... you go out with a lightweight OS that runs on Raspberry PI or any Allwinner based SoC and I assure you that will sell and put you closer to this revolution you keep seem missing.
If you'll ever listen to this post, at the same time, please never stop improving the HTML5 part that is making you one of my favorites companies when it comes to Web Development, thanks!

The Windows Phone Ongoing Rise

Not because I've worked there, simply because I know the quality behind, having NOKIA manufacturing Windows Phones, and considering improvements I could spot from 7 to 8+, cannot be anything but a Win!
WP8 is a great product many keeps ignoring or looking only at the Market side of the deal, I actually adore my relatively cheap Lumia 620 and what it's able to do daily for me.
Europe is apparently aware of the quality of these phones and the WP8 OS and I think it will keep improving in 2014 too. If only WP brand would change to a more generic Windows Mobile and be compatible with most known developers board and the underlying hardware, now that could be a nice challenge facing the Android domain in the field!

Update: Something Needs To Be Fixed!

Specially when it comes to the amount of apps and what's in the WP market, here a chat with other developers on the fact you cannot create even HTML5 for WP8 without owning a Windows 8 OS / PC.
I think Microsoft should detach WP or WinRT targets from its main Win 8 OS, MS is not Apple, and it should probably not try to be. I'd rather port Visual Studio for OS X same as Office has been available for years.

Parrots Will Stop "Free Flights"

OK, this is a very pessimistic view but I think it's inevitable. Under some silly "preserving streets security and privacy" flag different governments will make free flying parrots illegal or somehow strictly coupled to some paying service that monitors them every departing, every flying, and every landing.

So Will Wireless Devices

Did you know in some country you cannot buy a developer board with an enabled WiFi device on it?
The wearable and tiny-mobile era is also the era where digital sharing could finally get out the internet, reaching amazing transfer speed and the ease of just walking through a crowd.
The first version of bit torrent for embedded linux able to communicate with your watch and let you chose from people around you without even knowing them and without any need to log-in somewhere since no data provider is controlling the whole operation will be as successful as Napster has been at its time: you go to a party, you end up with movies, music, books, pictures, and everything else while you are dancing and totally anonymous ... now that's scary for the controlling system!

JavaScript Will "Fail"

You might read this as highly subjective point of view ... the time will tell though and I am talking about a counter direction from the success of these years.
The run for the chaos already started and it won't get any better. JavaScript development is proceeding in a way that who codes for node.js or a V8 target might be happy but who codes for the Web will be inevitably pissed off.
What makes JavaScript unique is a cross platform and engine problem no other language has: it's the only one that has fragmentation within the same version of the language ... that's where all fun is!
You chose Python 2.6, you gonna have bloody python 2.6 everywhere Python 2.6 is available. Same is for Python 3.X or whatever ... there are really few things in core that might not perfectly work as expected but the language version matters.
With JavaScript, a part from the fact "everyone makes slightly different JS engines these days", you might have major milestones like ES6 or ES7 but they all decided to promote early adoption of potentially broken API and trap themselves behind a feature detection nightmare.
Take the Proxy, already doubled in the same MDN documentation (tell me which one is not the standard at first look to these links) and not as mozProxy VS Proxy, it's same bloody thing nobody can feature-detect if not through stupid try catch over attempts, pretending these will tell us if we are within ES6 idea of Proxy or ... before that, who really knows?!
Moreover, early adoption means early problems impossible to fix once adopted and this is the trend we've been trained for last 3 years: it's early adoption, it's prefixed because not stable, you should not trust prefixed things but you know what? every freaking article on the web gonna abuse them so you'll feel comfortable using un-trustable code maybe even on production so that next step is indeed: who cares about API reliability!
There are few reason JS has been always considered a toy language ... I think dropping prefixes and promoting early unstable adoption of "whatever idea" cannot bring any benefit to anyone but apparently I am the only one that is concerned about this ... anyway ...

Transpiler Are NOT A Solution

At least at the very beginning, transpilers cannot be used for those browsers that do not support decent debugging environments, source maps, or ES6 at all. Try to imagine a target browser does not support a piece of JS in the way the transpiler creates it ... try to imagine that if a transpilers translate some ES5 magic linearly many things will break.
Try to imagine that a transpiler will not fix the DOM or any possible gotcha ... what you gonna do at that time, change the transpiler?
There are many reasons GWT didn't fly as adoption ... and these are just one part of the problem.
Another gotcha about transpilers, it's impossible to load at runtime anything, it's impossible to evaluate any piece of code, it's impossible to ... well, unless you don't want to throw a runtime transpiler in the middle!
Remember also that generators cannot be transpiled ... or better, transpilers can simulate them but if something goes wrong I wish you best luck finding out the problem AND solving it with a non capable generator ... remember, ES6 has not even a caller magic able to help debugging manually if necessary ... just saying ...
Last but not least, transpilers could also have bugs on top of buggy engines, how ideal ^_^

Evergreen Browsers Are A White Lie

I have bought for personal reason a Firefox OS phone ZTE Open and I am not receiving updates from ZTE since ever. This is just an example of broken ever green browser ... my browser is not updating since nothing is actually updating in there.
I can install Chrome in my iPod but that is not Chrome for Android and it does not update automagically as the Chrome in KitKat would do ... that is not an evergreen browser, neither is necessarily Safari mobile since I need to wait for the OS to push me updates and maybe I am not in the mood of applying them.
I could go on for hours ... passing through HW and memory limitation for some new feature as WebGL 3.0 could be, where my old phone with my old GPU that does not support Open GL ES 3.0 will simply never work as expected.
The evergreen browser is a partial myth we should re-consider ... surely Chrome demonstrated on the Desktop that it can keep update itself, but in the mobile era where the fragmentation between OS and HardWare is HUGE we must be fools to believe every device will never need to be changed again since the browser will update forever ... you know what I mean? Moreover, at least for other 2 years, there will be a big global market share where no source map, neither ES6, nor evergreen browsers will be available: welcome in the era of developing countries too!

After All, HTML5 FTW!

Even Intel Edison, the latest Quark based SD Card ... ahem, PC, has been developed "working primarily in C and Javascript" so, together with all massive improvements CSS is making and the robust framework the DOM is these days, even if slower than everything else surrounding it, HTML5 will keep pushing harder and gain unthinkable goals from embedded devices to large scale online portals/applications.

That's It For Now

And while I hope everything I wrote won't ever happen, except good things, I cannot wait to wake up in 2 years and check all things that were true and all things that were flops :-)