Closed Bug 1421770 Opened 7 years ago Closed 5 years ago

"this" loses context

Categories

(DevTools :: Debugger, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mhammar31, Unassigned)

Details

Attachments

(1 file)

Attached image thisloosescontext.png
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0
Build ID: 20171112125346

Steps to reproduce:

when you stop execution and try to see information about the execution the "this" value is the windows-object.


Actual results:

when I try to see information about a variable by using this.x or executing a method by this.method() in the Variables-list (add watch expression ) it can't be done because this is no longer what it should be according to the context where the code stopped. "this" points to window. 
I CAN find "this" in the function-scope och maybe block-scope. But I can't create a watch with "this" because everything you add as a watch doesn't execute in the same context as the code stopped in.
This bug/feature appeared some time ago. Earlier versions of the debugger didn't work like this.
It is not always like this. I haven't really found any pattern when "this" points to window or the context "this".


Expected results:

 I think that the context of Variables and added watches should match the context that the code is in. If "this" in the code is an object X then "this" in the variables-panel should be so also.
I don't really know if this is the wrong place to report this bug. I tried to find Firefox debugger, but couldn't.
This bug is anyway about Firefox debugger.
Component: Dev Kit → Developer Tools: Debugger
Product: Developer Ecosystem → Firefox
I noticed that if you choose different levels in the call stack, the "this" pointer actually works for every layer except for the topmost, the one where execution stops. 
It seems that I can.t post a picture if I add a comment like this, so I cant show that, but by clicking on different levels of the codestack that can be seen. 
It is unfortunate that on the topmost level, the level where most of the work is done, all watches in the variable-pane default to be under the global context. So you can't use the feature in a good way where it is needed the most.
Summary: this looses context → "this" looses context
Product: Firefox → DevTools

I believe this relates to the old debugger. Honza, could you confirm?

Flags: needinfo?(odvarko)
Summary: "this" looses context → "this" loses context

This seemed to work well when I tested it. If you still see the issue, could you try and give us an example where this doesn't work for you?

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED

I tested this and it works for me just fine.
Honza

Flags: needinfo?(odvarko)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: