Closed Bug 1255734 Opened 8 years ago Closed 8 years ago

DevTools: Inspecting a primitive value in console throws a TypeError

Categories

(DevTools :: Object Inspector, defect, P1)

47 Branch
defect

Tracking

(firefox48 fixed)

RESOLVED FIXED
Firefox 48
Tracking Status
firefox48 --- fixed

People

(Reporter: jsnajdr, Assigned: jsnajdr)

Details

(Whiteboard: [btpp-fix-now])

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) Gecko/20100101 Firefox/47.0
Build ID: 20160225030209

Steps to reproduce:

1. Open devtools console.
2. Type 'inspect(1)' - to inspect a primitive value


Actual results:

If you have a browser toolbox console open, you can see a TypeError reported:

TypeError: invalid 'in' operand aGrip

This happens in the VariableViewController._populateFromObject, where there is a statement:

if ("ownPropertyLength" in aGrip)

aGrip is not an object, but it's the primitive number value 1.



Expected results:

No errors.
Adding a patch: 

- in VariablesViewController.setSingleVariable, call this.populate only if the object is not primitive. Otherwise, just return a resolved promise.

- I renamed the parameters of the setSingleVariable method to remove the Hungarian notation and make ESLint happy.

- added a new test case to browser_jsterm_inspect.js. Without the fix, the test times out (the "variablesview-updated" event is never fired).

- slightly refactored the test to use the "variablesview-updated" event instead of "fetched". It works consistently for both primitive and non-primitive values (the "variablesview-fetched" event is fired only when "populate" is called).
Attachment #8729433 - Flags: review?(vporof)
Component: Untriaged → Developer Tools: Console
Assignee: nobody → jsnajdr
Status: UNCONFIRMED → ASSIGNED
Component: Developer Tools: Console → Developer Tools: Object Inspector
Ever confirmed: true
Priority: -- → P1
Whiteboard: [btpp-fix-now]
Comment on attachment 8729433 [details] [diff] [review]
DevTools: Inspecting a primitive value in console throws a TypeError

Review of attachment 8729433 [details] [diff] [review]:
-----------------------------------------------------------------

Nice!
Attachment #8729433 - Flags: review?(vporof) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/282de7d09bce
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 48
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: