Difficult to anticipate where debugger step functions will step to

NEW
Unassigned

Status

DevTools
Debugger
3 years ago
a month ago

People

(Reporter: callahad, Unassigned)

Tracking

Trunk
x86
Mac OS X

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
Try stepping through the following code. Can you guess where you'll end up each time you click Step In?

    function foo() {
      return a() ? b() ? c() : d() ? e() : f() && g() : h();
    }

    function a() { return Math.random() >= 0.5; }
    function b() { return Math.random() >= 0.5; }
    function c() { return Math.random() >= 0.5; }
    function d() { return Math.random() >= 0.5; }
    function e() { return Math.random() >= 0.5; }
    function f() { return Math.random() >= 0.5; }
    function g() { return Math.random() >= 0.5; }
    function h() { return Math.random() >= 0.5; }

The tools should help me with this.

This is not completely contrived; I had to wade through a ternary with identical structure when tracking down Bug 1143857. Proof at 4:15 in https://www.youtube.com/watch?v=PUgRMRQoTq4&t=4m15s
(Reporter)

Comment 1

3 years ago
For easy testing, the above code can be found at http://people.mozilla.org/~dcallahan/tmp/bug1145752.html
Created attachment 8762972 [details]
Screenshots of Chrome and IE devtools while stepping

I hope Firefox debugger one day will highlight the statement it's at. Chrome devtools does this very well.

(If it's any consolation, IE's devtools are on par with us and old Opera Dragonfly was even worse than Firefox devtools on this test case..)

Updated

a year ago
See Also: → bug 1363325, bug 1370655

Updated

a month ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.