Closed Bug 1109612 Opened 10 years ago Closed 5 years ago

source code of failed script is not displayed when the failed code was activated through eval

Categories

(DevTools :: Console, defect, P2)

36 Branch
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1447244

People

(Reporter: atiware, Unassigned)

References

Details

(Keywords: reproducible, testcase)

Attachments

(5 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:36.0) Gecko/20100101 Firefox/36.0
Build ID: 20141209004001

Steps to reproduce:

it is not possible to see what the failed sourcecode is when the bugous js code was loaded through ajax call, and the formally correct source with eval executed (activated).

1. activate the web developer console
2. Load a js source with Ajax request
3. eval() the loaded code
4. call the bugous function located in the evaled code
5. the console displays an error message and a line number
6. click on the line number to display the failed code



Actual results:

the source code of the file with the eval call is displayed


Expected results:

should display the failed code
Firebug 2.0.7 displays the code correct
Component: Untriaged → Developer Tools: Console
Attached file Testcase
Ryan, who can take a look at this (and/or is this a dupe)? And, shouldn't we open files in the debugger instead of view-source? The debugger (at least on Nightly) does seem to be aware of the eval'd source separately. :-)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(jryans)
OS: Mac OS X → All
Hardware: x86 → All
Hmm, let's see what Nick thinks.
Flags: needinfo?(jryans) → needinfo?(nfitzgerald)
It seems that the console doesn't understand how to find eval'd sources in the debugger's source list.

I think it would make sense to fix bug 956087 so the debugger is always initialized when the console is open, and then instead of attaching a URL to each console message, attach a SourceActor's form. Then the console would just tell the debugger to show the source for the given form.

There is probably a more ductape-y solution if we want something faster, that involves keeping the way the debugger labels eval'd sources in sync with the console.

cc jlongster
Flags: needinfo?(nfitzgerald)
Actually, my first idea wouldn't work for console messages generated before opening the devtools. Blech.
(In reply to Nick Fitzgerald [:fitzgen] from comment #5)
> Actually, my first idea wouldn't work for console messages generated before
> opening the devtools. Blech.

I definitely still like the idea of initializing the debugger whenever the devtools is opened, no matter what tab is displayed. It's weird to me that a `debugger` statement won't pause when the debugger is opened. Also I think the future we'll need access to the debugger for more stuff (like sourcemaps, for actors that don't use a Debugger instance but want the original loc of a url/line).

I suspect that this will require changes internally to how we deal with the cached messages if we want to support this when the devtools is closed (which we should). The cached messages right now probably record URL, when it *should* record the Script instance, and if we had that it would be easy to map to the right SourceActor.
there is an another problem with the current developer tool in Firefox nightly.
if there is a syntax error in a content loaded per ajax call, Firefox displays only that there is a syntax error somewhere, firebug 2.0.7 displays least a small code snippet which makes it easier to locate the error in a big generated content.
(see the second screenshot and the second testcase)
A simple way to reproduce this. Put this code anywhere on a page:

<script>eval("x=y")</script>

Now Firefox displays an invalid URL in the console.

Google Chrome and Microsoft Explorer both get this right by linking to the actual codeline with the error.
See Also: → 1177941
fixed a typo in the testcase, so please use testcase-2-1109612-code-snippet-v2.zip to reproduce the problem.

btw. i ran into this problem today again, and i had to download an older version of firefox and install firebug-2.0 to be able to find the typo
Product: Firefox → DevTools

Brian, will the work you are doing with scripts will fix this? (to repro, open data:text/html,<meta charset=utf8><script>eval("x=y")</script> and click on the error message location in the console).

Flags: needinfo?(bhackett1024)
Priority: -- → P2

(In reply to Nicolas Chevobbe from comment #12)

Brian, will the work you are doing with scripts will fix this? (to repro, open data:text/html,<meta charset=utf8><script>eval("x=y")</script> and click on the error message location in the console).

Bug 1447244 will fix this case so that clicking on the link in the console goes to the eval text's source in the debugger instead of a view-source tab.

Flags: needinfo?(bhackett1024)

Thanks for answering Brian.
I'm setting this bug as dependent of Bug 1447244, and once fixed, we may use this one to add a test if it wasn't already done.

Depends on: 1447244
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: