[webkit-dev] Improving DOM Exception console messages.

Elliott Sprehn esprehn at chromium.org
Wed Sep 26 17:17:53 PDT 2012


Awesome! This had come up as something I wanted to fix a few weeks ago as
well.

On Wed, Sep 26, 2012 at 9:20 AM, Ojan Vafai <ojan at chromium.org> wrote:

> Sounds great!
>
>
> On Wed, Sep 26, 2012 at 8:12 AM, Mike West <mkwst at chromium.org> wrote:
>
>> Hello, webkit-dev!
>>
>> TL;DR: I'd like to improve the console messages displayed for DOM
>> exceptions. I'm hoping that no one thinks this is a miserable,
>> miserable idea.
>>
>> At the moment, the following code generates an exception with a
>> message reading "SECURITY_ERR: DOM Exception 18".
>>
>> ----8<------8<------8<------
>> <!doctype html>
>> <html>
>>   <head>
>>     <title>Bug 152212</title>
>>     <meta http-equiv="X-WebKit-CSP" content="connect-src 'none'">
>>   </head>
>>   <body>
>>     <script>
>>       var xhr = new XMLHttpRequest();
>>       var url = '
>> https://api.twitter.com/1/trends/daily.json?exclude=hashtags';
>>       xhr.open('GET', url, true);
>>       xhr.send();
>>     </script>
>>   </body>
>> </html>
>> ---->8------>8------>8------
>>
>> In this case, the exception is generated because Content Security
>> Policy blocks the XMLHttpRequest, but it's tough to tell, because the
>> exact same error crops up for 31 different exception cases[1]. It
>> might be CSP, it might be a disallowed HTTP method, who knows. Because
>> of the variety, searching for the exception message is unhelpful. In
>> this case, I end up on StackOverflow, reading about cookies and
>> jQuery[2], which is unlikely to be of service.
>>
>> This isn't a great experience, and while SECURITY_ERR is particularly
>> widespread, the scenario is similar for the other DOM exceptions
>> WebKit throws. Each ends up in ExceptionBase, where a message is
>> assembled from the exception type and code, and the developer is left
>> more than a little underinformed.
>>
>> I'd like to add the ability to pass some sort of contextual message
>> along with the error code. This would involve some work on JSC and V8
>> bindings, as well as a whole lot of single-line changes to the various
>> bits of the DOM where these error codes are generated.
>>
>> In this case, a useful message might be: "SECURITY_ERR: DOM Exception
>> 18. XMLHttpRequest connections to
>> 'http://localhost:8000/xmlhttprequest/resources/get.txt' are blocked
>> due to this page's Content Security Policy." This would have the
>> positive impact of giving developers something useful to work with. It
>> would also have the impact of changing the exception text, which is
>> why I'm writing this email. :)
>>
>> Before I get too far along in experimental implementations, are there
>> fundamental objections to changing the exception text to include some
>> optional context?
>>
>> [1]:
>> https://cs.corp.google.com/#search/&q=SECURITY_ERR%20file:WebCore&sq=package:%5Echrome$&type=cs
>> [2]:
>> http://stackoverflow.com/questions/2704929/uncaught-error-security-err-dom-exception-18
>>
>> -Mike
>> _______________________________________________
>> webkit-dev mailing list
>> webkit-dev at lists.webkit.org
>> http://lists.webkit.org/mailman/listinfo/webkit-dev
>>
>
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20120926/232cfbbd/attachment.html>


More information about the webkit-dev mailing list