Developer Tools Modifying Js Code Variables.

10 views
Skip to first unread message

mainak sethi

unread,
Apr 21, 2017, 11:31:43 AM4/21/17
to Google Chrome Developer Tools
Hi,
I recently found a bug in chrome debugging tools .

Bug Description;
Write a js script like

var a = 0;
a++;
console.log(a);

Now Open this script in chrome with a html template and pug debugger on line 2 (a++). As you hover over line 2 chrome executes the line and increase the variable value. So if u hover the line like 5 times . Chrome will update the value to 5, whereas expected behavior suggests value to remain 1. 

Basically developer tools are modifying the code which is not expected and it happens on any line containing mathematical operation as chrome actually executes the line and shows the result.

PhistucK

unread,
Apr 21, 2017, 11:39:49 AM4/21/17
to Google Chrome Developer Tools
I tried it like this -
data:text/html,<script src="data:text/javascript,var a = 0;%250d%250aa++;%250d%250aconsole.log(a);"></script>

It only happens for me if I select the entire expression and hover over it (and that behavior is expected - the Developer Tools feature runs the selected expression as if it were run by the page and returns its value. Side effects can happen and the JavaScript state is affected as usual). Otherwise, it only shows the value of a.

What version of Chrome are you using and on which platform?


PhistucK

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/1033356d-d4f8-4dc3-9c00-70a379760ee3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages