Closed Bug 1559717 Opened 5 months ago Closed 4 months ago

Object Inspector Invoke Getter button returns `undefined` if the getter returns `false`, `0` or `""`

Categories

(DevTools :: Console, defect, P1)

67 Branch
defect

Tracking

(firefox69 verified, firefox70 verified)

VERIFIED FIXED
Firefox 70
Tracking Status
firefox69 --- verified
firefox70 --- verified

People

(Reporter: patrickwasp, Assigned: nchevobbe)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:67.0) Gecko/20100101 Firefox/67.0

Steps to reproduce:

assign "false" to a property of a vue data object in Firefox 67.

https://github.com/vuejs/vue/issues/10106

Actual results:

the property is shown as "undefined" in the Firefox console

Expected results:

the property should be shown as "false"

Component: Untriaged → General
Product: Firefox → DevTools

The priority flag is not set for this bug.
:pbro, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(pbrosset)

This seems related to how/when we invoke the property getter from the console. This is indeed different on Chrome.
Moving this to our console component for further investigation.

Status: UNCONFIRMED → NEW
Component: General → Console
Ever confirmed: true
Flags: needinfo?(pbrosset)

Thanks for the report patrickwasp!

This seems to be something related to falsy values, as I could reproduce with a simpler STR

  1. Open the console
  2. Evaluate the following:
var a = {
  get b() {
    return false;
  }
};
a;
  1. In the output, expand the object
  2. Click on the "invoke getter" button for the b property

Expected result: it prints false
Actual result: it prints undefined

The bug also shows if: the getter returns an empty string ("") or 0 (null is fine)

Summary: development tools show incorrect value of variable → Object Inspector Invoke Getter button returns `undefined` if the getter returns `false`, `0` or `""`

We were displaying result.value.throw if result.value.return
was falsy. But it can happen that a getter does return a
falsy value, and we want to display it.
So now we turn the expression the other way around, we first
check result.value.throw, and then default to result.value.return.
A mochitest is added to ensure we hav expected value for different
getters returning falsy values.

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Priority: -- → P1
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/20477ed25859
Fix displaying getter value for getter returning falsy values. r=davidwalsh.
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 70

Comment on attachment 9080237 [details]
Bug 1559717 - Fix displaying getter value for getter returning falsy values. r=davidwalsh.

Beta/Release Uplift Approval Request

  • User impact if declined: When using the console to evaluate a getter that returns false , "" or 0, the console would say the getter value is undefined, which is erroneous and might confuse people.
    Getters are used a lot in VueJS, which is widely used.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: 1. Open the console
  1. Evaluate the following code:
var a = {
  get b() {
    return false;
  }
};
a;
  1. Expand the result object
  2. Click on the >> button next to b

Expected result: you should now have b: false

  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): DevTools only, one-line fix, covered by an extensive mochitest
  • String changes made/needed:
Attachment #9080237 - Flags: approval-mozilla-beta?
Flags: qe-verify+

Comment on attachment 9080237 [details]
Bug 1559717 - Fix displaying getter value for getter returning falsy values. r=davidwalsh.

Small fix with a lot of tests to ensure that the console returns the correct value in some situations. Approved for 69.0b9.

Attachment #9080237 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Confirmed issue with 69.0a1 (2019-06-19) .
Fix verified with 69.0b9 and 70.0a1 (2019-07-29) on Windows 10, macOS 10.13, Ubuntu 16.04.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.