Open Bug 1745312 Opened 4 years ago Updated 1 year ago

Wrong Autosuggestion on `new Date()`

Categories

(DevTools :: Console, defect, P3)

Firefox 94
defect

Tracking

(Not tracked)

People

(Reporter: mr_w, Unassigned)

Details

Attachments

(1 file)

72.89 KB, application/zip
Details
Attached file Screenshots.zip

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0

Steps to reproduce:

I experimented a bit with the Intl API in the DevTools console. While doing that, I stumbled over a bug in the Autosuggestion.

Steps to reproduce:

  1. create a new Date object
  2. type to to see the suggestions -> new Date().to

Actual results:

When I create a new Date Object like so:
const d = new Date()
and afterwards start typing d.to, I get exactly 10 suggestions (see screenshot 1)

But when I'm trying to see the suggestions from new Date().to, I only get 6 suggestions and just 2 of them are actually working functions (see screenshot 2).

In screenshot 2 you can also see, in the background, that all the functions suggested by first creating the object and save as variable, and then start typing d.to are all working (I tried all 10); But the suggestions are wrong.

Expected results:

The suggestions obtained from:
const d = new Date()
d.to
should match the suggestions obtained from new Date().to

So all suggestions from screenshot 1 are the expected results.

The issues is in anayze-input-string.js , more precisely in https://searchfox.org/mozilla-central/rev/5e15e00fa247cba5b765727496619bf9010ed162/devtools/shared/webconsole/analyze-input-string.js#102,107-110
So in the end, for new Date().to, we only keep Date().to , and since Date() returns a simple string, we don't get the right items.

I tried quickly to fix this but I was breaking the completion when doing new D for example, where here, we do want to only consider D. So we can't simply check that lastStatement was new in devtools/shared/webconsole/analyze-input-string.js#105.
We may need to have a new state, e.g. STATE_NEW_KEYWORD or something so we could differentiate between new D and new Date().to.

The severity field is not set for this bug.
:nchevobbe, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(nchevobbe)

P3 S3 as it's only autocomplete and it's probably been here for a long time

Severity: -- → S3
Flags: needinfo?(nchevobbe)
Priority: -- → P3

Hi, I'd like to work on this. Can you assign it to me please?

Flags: needinfo?(nchevobbe)

(In reply to Riz from comment #4)

Hi, I'd like to work on this. Can you assign it to me please?

Sure, it's yours Riz :)

Assignee: nobody → rizwansyed876
Flags: needinfo?(nchevobbe)

Thanks

Hi, I don't think I will have time to work on this for a while. I think it would be wise to unassign this from me in case someone else decides they want to work on it.

Flags: needinfo?(nchevobbe)

(In reply to Riz from comment #7)

Hi, I don't think I will have time to work on this for a while. I think it would be wise to unassign this from me in case someone else decides they want to work on it.

sure

Assignee: rizwansyed876 → nobody
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(nchevobbe)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: