Throw exceptions that allow API reuse outside the browser

http://lists.w3.org/Archives/Public/www-international/2014OctDec/0091.ht
ml
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27248