Bug 149733 - Web Inspector: Simplify TimelineRecordBar a bit
Summary: Web Inspector: Simplify TimelineRecordBar a bit
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: DoNotImportToRadar
Depends on:
Blocks:
 
Reported: 2015-10-01 17:08 PDT by Joseph Pecoraro
Modified: 2015-10-06 12:14 PDT (History)
9 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (1.31 KB, patch)
2015-10-01 17:08 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.