RESOLVED FIXED 138839
Web Inspector: Debugger should not mutate variable when hovering mouse over ++n expression
https://bugs.webkit.org/show_bug.cgi?id=138839
Summary Web Inspector: Debugger should not mutate variable when hovering mouse over +...
Joseph Pecoraro
Reported 2014-11-18 11:32:54 PST
* SUMMARY When debugging javascript paused in the debugger, hovering over a line of the form ++n actually mutates the value of n. n++ does not have this behavior. * TEST <script type="text/javascript"> function test() { debugger; var n = 0; console.log(n); // Hover over next line. n shouldn't change n++; console.log(n); // Hover over next line. n changes but shouldn't ++n; console.log(n); } document.onload = test(); </script> * STEPS TO REPRODUCE 1. Inspect test case 2. Reload or type test() into the console 3. Test hovering over n++ and see it doesn't mutate 4. Test hovering over ++n and see that it mutates n every time you hover over it
Attachments
[PATCH] Proposed Fix (2.29 KB, patch)
2014-11-18 11:36 PST, Joseph Pecoraro
timothy: review+
timothy: commit-queue-
[PATCH] Proposed Fix (2.42 KB, patch)
2014-11-18 14:01 PST, Joseph Pecoraro
no flags
Radar WebKit Bug Importer
Comment 1 2014-11-18 11:33:10 PST
Joseph Pecoraro
Comment 2 2014-11-18 11:36:57 PST
Created attachment 241796 [details] [PATCH] Proposed Fix
Joseph Pecoraro
Comment 3 2014-11-18 11:37:53 PST
Timothy Hatcher
Comment 4 2014-11-18 11:51:02 PST
Comment on attachment 241796 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=241796&action=review > Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js:490 > + if (isExpression && token.string === "++") What about --?
Joseph Pecoraro
Comment 5 2014-11-18 12:03:50 PST
(In reply to comment #4) > Comment on attachment 241796 [details] > [PATCH] Proposed Fix > > View in context: > https://bugs.webkit.org/attachment.cgi?id=241796&action=review > > > Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js:490 > > + if (isExpression && token.string === "++") > > What about --? Doh! Tim also caught other operators, like: n+=n; I'll put up another patch.
Joseph Pecoraro
Comment 6 2014-11-18 14:01:06 PST
Created attachment 241810 [details] [PATCH] Proposed Fix
Timothy Hatcher
Comment 7 2014-11-19 09:54:02 PST
Comment on attachment 241810 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=241810&action=review > Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorTokenTrackingController.js:492 > + // Disallow operators. We want the hovered expression to be just a single operand. > + // Also, some operators can modify values, such as pre-increment and assignment operators. > + if (isExpression && token.type.contains("operator")) > + break; Nice!
WebKit Commit Bot
Comment 8 2014-11-19 10:34:15 PST
Comment on attachment 241810 [details] [PATCH] Proposed Fix Clearing flags on attachment: 241810 Committed r176325: <http://trac.webkit.org/changeset/176325>
WebKit Commit Bot
Comment 9 2014-11-19 10:34:18 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.