[thelist] debugging for Safari
liorean
liorean at f2o.org
Fri Mar 19 13:50:58 CST 2004
Scott Blanchard wrote:
> Since Safari does not have a javascript console (or atleast I can't find
> it), how would one best debug an application in this browser? I get no
> errors when running this code in Firefox's javascript console, however,
> the app freezes in Safari.
There's a number of ways. The first would be to enable the debug menu,
if you haven't enabled it already. The command (in the terminal) would be:
% defaults write com.apple.Safari IncludeDebugMenu 1
If you later want to disable it, just do the same with a 0 instead of a 1.
That allows you to get at a few useful tools:
- Show DOM Tree
- Import/export bookmarks
- Log JavaScript Exceptions
- Sampling
- Security
Log JavaScript Exceptions brings up JavaScript exceptions in the system
console. They aren't especially useful, though. Something much more
useful is the usual method of inserting alert/confirm/prompt and
inspecting object types and values as well as enumerable properties and
methods. Also, something useful is the try..catch statements. You could
use them to log errors or status messages or variable inspections as per
the alert/confirm/prompt way mentioned above, but while running, without
halting the execution just because an error has been thrown.
Also, make sure that compared to Mozilla, everything works for the same
code forks (except for the things that Mozilla doesn't support), and
that no warnings or errors are reported using Strict Warnings. Opera is
sometimes closer to Safari than Mozilla is, though, so you could try the
same code in Opera 7.50 Preview 3 and check the JavaScript Console in
Opera for clues. See <http://web-graphics.com/mtarchive/001178.php> for
Opera.
--
David "liorean" Andersson
ViewStyles, ViewScripts, SwitchStyles and GraphicsInfo bookmarklets:
<http://liorean.web-graphics.com/>
Hangouts:
<http://codingforums.com/> <http://yourmusicforums.com/>
More information about the thelist
mailing list