Closed Bug 1363307 Opened 9 years ago Closed 9 years ago

Add a warning when Console.timeEnd(label) is used with an unknown label

Categories

(DevTools :: Console, enhancement)

enhancement
Not set
normal

Tracking

(firefox55 verified)

VERIFIED FIXED
Firefox 55
Tracking Status
firefox55 --- verified

People

(Reporter: baku, Assigned: baku)

References

Details

(Keywords: dev-doc-needed, Whiteboard: [bugday-20170524])

Attachments

(2 files, 1 obsolete file)

> console.timeEnd('a'); we should warn the user the 'a' in an unknown timer label.
Attached patch console2.patch (obsolete) — Splinter Review
Assignee: nobody → amarchesini
Attachment #8865786 - Flags: review?(bgrinstead)
Comment on attachment 8865786 [details] [diff] [review] console2.patch Review of attachment 8865786 [details] [diff] [review]: ----------------------------------------------------------------- The tests are a little tricky to write, so I will attach a patch that adds coverage for this and also Bug 1363288 here ::: devtools/client/locales/en-US/webconsole.properties @@ +95,5 @@ > Autocomplete.blank= <- no result > > maxTimersExceeded=The maximum allowed number of timers in this page was exceeded. > timerAlreadyExists=Timer %S already exists. > +timerDoesntExist=Timer %S doen't exist. Typo: doesn't
Attachment #8865786 - Flags: review?(bgrinstead) → review+
Nicolas, this has a quick fix for the mocha tests (which are currently failing after the sourcemap changes) in addition to covering some new timer errors
Attachment #8866048 - Flags: review?(nchevobbe)
Comment on attachment 8866048 [details] [diff] [review] tests-webconsole-time.patch Review of attachment 8866048 [details] [diff] [review]: ----------------------------------------------------------------- One question about the fix for sourceMap and a comment about how we display timer name , but aside from that, everything looks good ::: devtools/client/webconsole/new-console-output/test/components/console-api-call.test.js @@ +146,5 @@ > + it("shows an error if called again", () => { > + const message = stubPreparedMessages.get("timerAlreadyExists"); > + const wrapper = render(ConsoleApiCall({ message, serviceContainer })); > + > + expect(wrapper.find(".message-body").text()).toBe("Timer bar already exists."); Not related to your patch I think, but I think this would be nicer if the Timer name would be quoted. > Timer "bar" already exists This is better suited for other test case like multi-words timer name > Timer "bar foo" already exists Or if the name of the timer is "Timer" > Timer "Timer" already exsits. ::: devtools/client/webconsole/new-console-output/test/fixtures/serviceContainer.js @@ +12,5 @@ > onViewSourceInScratchpad: () => {}, > openNetworkPanel: () => {}, > sourceMapService: { > subscribe: () => {}, > + originalPositionFor: () => { return new Promise(resolve => {}) }, Is there a risk that this makes a test hang in the future since we're never resolving the Promise ?
Attachment #8866048 - Flags: review?(nchevobbe) → review+
Comment on attachment 8865786 [details] [diff] [review] console2.patch Review of attachment 8865786 [details] [diff] [review]: ----------------------------------------------------------------- ::: devtools/client/locales/en-US/webconsole.properties @@ +94,5 @@ > # string containing anchor doesn't matches to any property in the content. > Autocomplete.blank= <- no result > > maxTimersExceeded=The maximum allowed number of timers in this page was exceeded. > timerAlreadyExists=Timer %S already exists. Could we quote the Timer name here and in the one below ? See https://bugzilla.mozilla.org/show_bug.cgi?id=1363307#c4 for cases where it would help.
(In reply to Nicolas Chevobbe [:nchevobbe] from comment #4) > Comment on attachment 8866048 [details] [diff] [review] > tests-webconsole-time.patch > > Review of attachment 8866048 [details] [diff] [review]: > ----------------------------------------------------------------- > > One question about the fix for sourceMap and a comment about how we display > timer name , but aside from that, everything looks good > > ::: > devtools/client/webconsole/new-console-output/test/components/console-api- > call.test.js > @@ +146,5 @@ > > + it("shows an error if called again", () => { > > + const message = stubPreparedMessages.get("timerAlreadyExists"); > > + const wrapper = render(ConsoleApiCall({ message, serviceContainer })); > > + > > + expect(wrapper.find(".message-body").text()).toBe("Timer bar already exists."); > > Not related to your patch I think, but I think this would be nicer if the > Timer name would be quoted. OK, I'll update the patch once Andrea has final versions posted since I need to run the stub generation against what will land > devtools/client/webconsole/new-console-output/test/fixtures/serviceContainer. > js > @@ +12,5 @@ > > onViewSourceInScratchpad: () => {}, > > openNetworkPanel: () => {}, > > sourceMapService: { > > subscribe: () => {}, > > + originalPositionFor: () => { return new Promise(resolve => {}) }, > > Is there a risk that this makes a test hang in the future since we're never > resolving the Promise ? Yeah, I guess we can go ahead and resolve right away
Attached patch console2.patchSplinter Review
Attachment #8865786 - Attachment is obsolete: true
Are you going to land these 3 patches all together?
Flags: needinfo?(bgrinstead)
(In reply to Andrea Marchesini [:baku] from comment #8) > Are you going to land these 3 patches all together? Yes, we may as well land them at the same time
Flags: needinfo?(bgrinstead)
Were you planning to upload new versions of the two patches?
Flags: needinfo?(amarchesini)
No. Those patches are OK for me.
Flags: needinfo?(amarchesini)
Pushed by bgrinstead@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/9fee9809299c Console.timeEnd(label) should warn if 'label' in an unknwon timer, r=bgrins https://hg.mozilla.org/integration/mozilla-inbound/rev/91427ef3b016 Update component test for timer errors;r=nchevobbe
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 55
I have reproduced this bug with Nightly 55.0a1 (2017-05-09) (64-bit) on Windows 7, 64 Bit! This bug's fix is verified with latest Nightly! Build ID : 20170517030204 User Agent : Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:55.0) Gecko/20100101 Firefox/55.0 [bugday-20170517]
I have reproduced this bug with Nightly 55.0a1 (2017-05-09) on Ubuntu 16.04, 64 Bit! The fix is now verified on latest Nightly! Build ID 20170523100217 User Agent Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 [bugday-20170524]
Whiteboard: [bugday-20170524]
As per Comment 15 & Comment 16, I am marking this bug as verified fixed.
Status: RESOLVED → VERIFIED
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: