Bug 167524 - Add support for Trac instances that host multiple projects.
Summary: Add support for Trac instances that host multiple projects.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-01-27 12:53 PST by Kocsen Chung
Modified: 2017-01-30 15:04 PST (History)
7 users (show)

See Also:


Attachments
Patch (9.65 KB, patch)
2017-01-27 13:00 PST, Kocsen Chung
no flags Details | Formatted Diff | Diff
Patch (9.18 KB, patch)
2017-01-30 13:37 PST, Kocsen Chung
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kocsen Chung 2017-01-27 12:53:20 PST
Add support for Trac instances that host multiple projects.
Comment 1 Kocsen Chung 2017-01-27 13:00:08 PST
Created attachment 299953 [details]
Patch
Comment 2 Alexey Proskuryakov 2017-01-28 16:36:30 PST
Comment on attachment 299953 [details]
Patch

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

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:120
> -        console.assert(fromDate <= toDate);
> +        if (fromDate > toDate)
> +            throw RangeError("Parameter fromDate should be before or on toDate.");

Why this change? This is logically an assertion, so it's cleaner to express it as such.

Just like in C/C++, adding a unit test that violates an assertion is not worth it.

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:131
> +            "&from=" + encodeURIComponent(toDay.toISOString().slice(0, 10)) +
> +            "&daysback=" + encodeURIComponent((toDay - fromDay) / 1000 / 60 / 60 / 24);

Why add encodeURIComponent here if it's not needed?
Comment 3 Kocsen Chung 2017-01-30 13:29:12 PST
(In reply to comment #2)
> Comment on attachment 299953 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=299953&action=review
> 
> > Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:120
> > -        console.assert(fromDate <= toDate);
> > +        if (fromDate > toDate)
> > +            throw RangeError("Parameter fromDate should be before or on toDate.");
> 
> Why this change? This is logically an assertion, so it's cleaner to express
> it as such.
> 
> Just like in C/C++, adding a unit test that violates an assertion is not
> worth it.

It seemed too lenient to allow a range violation of this kind get away with an assertion. Additionally, it would allow for testing this code path. The way I interpret it, an assertion is an error and should be treated as such; especially in production code.
However, I do see your point that it may not be worth it to test this assert violation. Moreover I concur that it would be cleaner to express it as such. I will revert this change.

> 
> > Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:131
> > +            "&from=" + encodeURIComponent(toDay.toISOString().slice(0, 10)) +
> > +            "&daysback=" + encodeURIComponent((toDay - fromDay) / 1000 / 60 / 60 / 24);
> 
> Why add encodeURIComponent here if it's not needed?

Mostly as a security mechanism to not trust date input and as a result avoid unexpected or erroneous requests to the server. In my performance profiling, this had minimal effect and can provide security benefits.

Thanks for the review, Alexey.
Comment 4 Kocsen Chung 2017-01-30 13:37:24 PST
Created attachment 300139 [details]
Patch
Comment 5 WebKit Commit Bot 2017-01-30 15:04:50 PST
Comment on attachment 300139 [details]
Patch

Clearing flags on attachment: 300139

Committed r211388: <http://trac.webkit.org/changeset/211388>
Comment 6 WebKit Commit Bot 2017-01-30 15:04:54 PST
All reviewed patches have been landed.  Closing bug.