Bug 149733

Summary: Web Inspector: Simplify TimelineRecordBar a bit
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, commit-queue, darin, graouts, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: DoNotImportToRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix none

Description Joseph Pecoraro 2015-10-01 17:08:06 PDT
Simplify TimelineRecordBar a bit. Its setter is only ever used with multiple records. Require an array instead of dynamically converting inputs.
Comment 1 Joseph Pecoraro 2015-10-01 17:08:45 PDT
Created attachment 262301 [details]
[PATCH] Proposed Fix
Comment 2 Matt Baker 2015-10-01 17:17:57 PDT
Comment on attachment 262301 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=262301&action=review

> Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.js:199
> +        console.assert(records instanceof Array, "records should be an array");

Should we return if !(records instance Array)? What's our policy toward this style of defensive coding?
Nit: I'd format the assert message as a complete sentence: "Records should be an array."
Comment 3 Darin Adler 2015-10-06 09:16:02 PDT
Joe, are you waiting to set commit-queue+ until you think about Matt’s comment? Surprised this is still not landed.
Comment 4 Joseph Pecoraro 2015-10-06 11:27:59 PDT
Comment on attachment 262301 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=262301&action=review

>> Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.js:199
>> +        console.assert(records instanceof Array, "records should be an array");
> 
> Should we return if !(records instance Array)? What's our policy toward this style of defensive coding?
> Nit: I'd format the assert message as a complete sentence: "Records should be an array."

In this case, our policy should be to use the API correctly. Adding an assert here would just help us catch any possible outliers that I didn't see on auditing the code. Ideally this assert can be removed entirely.
Comment 5 Matt Baker 2015-10-06 11:42:30 PDT
(In reply to comment #4)
> Comment on attachment 262301 [details]
> [PATCH] Proposed Fix
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=262301&action=review
> 
> >> Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.js:199
> >> +        console.assert(records instanceof Array, "records should be an array");
> > 
> > Should we return if !(records instance Array)? What's our policy toward this style of defensive coding?
> > Nit: I'd format the assert message as a complete sentence: "Records should be an array."
> 
> In this case, our policy should be to use the API correctly. Adding an
> assert here would just help us catch any possible outliers that I didn't see
> on auditing the code. Ideally this assert can be removed entirely.

So we'll continue to assert that inputs are valid to catch improper API use, but not attempt to sanitize invalid input or early return. Sounds reasonable.
Comment 6 WebKit Commit Bot 2015-10-06 12:14:16 PDT
Comment on attachment 262301 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 262301

Committed r190632: <http://trac.webkit.org/changeset/190632>
Comment 7 WebKit Commit Bot 2015-10-06 12:14:21 PDT
All reviewed patches have been landed.  Closing bug.