If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

DevTools: Inspecting a primitive value in console throws a TypeError

RESOLVED FIXED in Firefox 48

Status

()

Firefox
Developer Tools: Object Inspector
P1
normal
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: jsnajdr, Assigned: jsnajdr)

Tracking

47 Branch
Firefox 48
Points:
---

Firefox Tracking Flags

(firefox48 fixed)

Details

(Whiteboard: [btpp-fix-now])

Attachments

(1 attachment)

(Assignee)

Description

2 years ago
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.
(Assignee)

Comment 1

2 years ago
Created attachment 8729433 [details] [diff] [review]
DevTools: Inspecting a primitive value in console throws a TypeError

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)
(Assignee)

Comment 2

2 years ago
https://treeherder.mozilla.org/#/jobs?repo=try&revision=868482a1c16b

Updated

2 years ago
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+
(Assignee)

Updated

2 years ago
Keywords: checkin-needed

Comment 4

2 years ago
https://hg.mozilla.org/integration/fx-team/rev/282de7d09bce
Keywords: checkin-needed

Comment 5

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/282de7d09bce
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
status-firefox48: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Firefox 48
You need to log in before you can comment on or make changes to this bug.