Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension causes unexplained JS syntax errors #18

Open
garypdev opened this issue May 25, 2013 · 2 comments
Open

Extension causes unexplained JS syntax errors #18

garypdev opened this issue May 25, 2013 · 2 comments

Comments

@garypdev
Copy link

Hi,

I'm trying to debug the website http://magic.defra.gov.uk/MagicMap.aspx so I can create a script that will provide additional features.

Many of the JS files are minimised so I was extremely pleased to find this extension. However when I enable the extension the website fails to function due to some reported JS syntax errors. The problem is that the reported errors do not make sense and sometimes point to lines in the expanded JS that do no exist. Also on different refreshes of the website, although the same three errors occur, they are reported in different files.

For example one run will produce:

SyntaxError: missing } after property list
} else if (activeTool == "distance") {
TOC.js (line 182, col 10)

SyntaxError: syntax error
}
UI_functions.js (line 194)

SyntaxError: return not in function
if (isNaN(xRet)) return {
FileSaveTools.js (line 85, col 25)

and another run will produce:

SyntaxError: missing } after property list
} else if (activeTool == "distance") {
TOC.js (line 182, col 10)

SyntaxError: syntax error
}
FileSaveTools.js (line 85)

SyntaxError: return not in function
if (isNaN(xRet)) return {
GIS_Utilities.js (line 407, col 25)

I'm using Firefox 21.0 with Firebug 1.11.4. If you could provide any pointers as to where I'm going wrong I'd be grateful.

Thanks,

Gary

@benmmurphy
Copy link
Owner

Hi,

I went to the website and most of the files are not minified except for one which loaded in chrome but not in firefox for some reason.

The javascript beautifier doesn't parse JS the same as the browser does so it is possible for it to corrupt the javascript. I would recommend either using Chrome (which has a deobfuscate button in built) or using a new build of firefox that supports source maps if you have access to the original source (https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/).

I've heard rumours that firefox has a new javascript AST api so I might look at that or maybe firefox/firebug devs will use that within their tools to provide similar formatting support to chrome.

@garypdev
Copy link
Author

Hi Ben,

Thanks for the reply. There are quite a few files (such as BaseMap.js) that are minified but I now realise I was debugging this at completely the wrong level. I'd gone too far down into the arcgis and dojo libraries. Having said that I also tried Fiddler2 which managed to beautify all the JS files apart from one. Excluding that one file from beautification allowed the website to run (albeit slowly). Many thank for the tips which will not doubt be useful in the future.

Gary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants