Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 338466 - improve handling of script blocks within html files
Summary: improve handling of script blocks within html files
Status: NEW
Alias: None
Product: JSDT
Classification: WebTools
Component: Debug (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: Future   Edit
Assignee: Project Inbox CLA
QA Contact: Michael Rennie CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-28 15:51 EST by Grant Gayed CLA
Modified: 2013-10-06 06:16 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Grant Gayed CLA 2011-02-28 15:51:06 EST
This is NOT a side-effect of Friday's changes, it happens before them as well.

- save the file below to your local file system
- connect to a Crossfire server
- navigate to the locally-saved page from below
- open its source
- the only place where a breakpoint is allowed to be set is to double-click beside line 1 (the <html> tag), which places the breakpoint beside the "theFunctionOne" function in the editor
  -> showing the breakpoint beside "theFunctionOne" function seems wrong (FWIW the setbreakpoint Crossfire request contains "line: 1")
  -> attempting to put a breakpoint anywhere else fails

//file: repeat.html
<html>
<head>
<script>
function theFunctionTwo(z) {
   var d = 2;
   alert(d);
   var e = 'asdf';
   alert(e);
   var f = null;
   alert(f);
   var g = true;
   alert(g);
   var h = false;
   alert(h);
   var i = 3.567;
   alert(i);
   var j = 'jkl;';
   alert(j);
   var k = '';
   alert(k);
   var l = window;
   alert(l);
   var m = [3];
   alert(m);
   var n = document;
   alert(n);
   var o = l;
   alert(o);
}
function theFunctionOne() {
   alert("hi");
   setTimeout("theFunctionOne()", 5000);
   var a = 2;
   var b = 2;
   theFunctionTwo(3);
   var c = 2;
}
window.onload=theFunctionOne;
</script>
</head>
<body>
hi
</body>
</html>
Comment 1 Michael Rennie CLA 2011-03-02 17:11:02 EST
This is because we currently do not have a support story for handling script blocks in the HTML code, and Crossfire sends the entire file as the source for the script. For testing to be able to view the source, the crossfire support is hacked up to wrap the html in a js file.

For example:
1. if the source URI reported for the html page is '/' then a new document will be created called 'page.js' to show the source
2. if there is a source URI the html page is still wrapped in a js file like <html file name>.js. So in your example you see 'repeat.html.js'

This problem is a symptom of a much larger issue of properly handling script blocks in HTML pages. Should we do processing locally to only display source blocks? Should we just find a way to handle the block in the HTML files? Should we update crossfire to only return script block source?

My personal vote would be to properly support the script blocks within the HTML.
Comment 2 Nitin Dahyabhai CLA 2012-04-25 20:40:55 EDT
(In reply to comment #1)
> My personal vote would be to properly support the script blocks within the
> HTML.

What would that entail?
Comment 3 Michael Rennie CLA 2012-04-26 10:21:58 EDT
(In reply to comment #2)
> (In reply to comment #1)
> > My personal vote would be to properly support the script blocks within the
> > HTML.
> 
> What would that entail?

A way to seamlessly use/generate ASTs to better support our breakpoint location story / step into selection / hyper-link debugging / variable hover, etc. for starts.
Comment 4 hmf Mising name CLA 2013-10-06 06:16:59 EDT
+1 for this. Not being able to set breakpoints and step through scripts
in the HTML file is counter-intuitive and a little frustrating. 

A way to circumvent this using Firebug is to set the breakpoints 
within Firebug itself. We can then step through the code in the
JSDT. 

However we then get another issue: the debugger does not have the 
correct values of the variables. No hovering works, nor does the 
variable windows show anything useful (shows empty objects).

Tested with:
 - Firefox 24.0
 - Firebug 1.12.3
 - Eclipse Kepler