|
|
Chromium Code Reviews|
Created:
4 years, 1 month ago by dpapad Modified:
4 years ago Reviewers:
tommycli CC:
arv+watch_chromium.org, chromium-reviews, dbeam+watch-settings_chromium.org, michaelpg+watch-md-settings_chromium.org, michaelpg+watch-md-ui_chromium.org, stevenjb+watch-md-settings_chromium.org Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionMD Settings: Allow trailing slashes in otherwise valid URLs.
BUG=615242
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation
Committed: https://crrev.com/67c02ed84a243982e46ed96bdf392ee213b5fef1
Cr-Commit-Position: refs/heads/master@{#434816}
Patch Set 1 #Patch Set 2 : Fix case of / #
Total comments: 5
Patch Set 3 : Beef up the regexp. #
Total comments: 4
Patch Set 4 : add more assertions #Patch Set 5 : Nit per Tommy's comment. #
Messages
Total messages: 39 (23 generated)
Description was changed from ========== MD Settings; Allow trailing slashes in otherwise valid URLs. BUG=615242 ========== to ========== MD Settings; Allow trailing slashes in otherwise valid URLs. BUG=615242 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ==========
The CQ bit was checked by dpapad@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
The CQ bit was checked by dpapad@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== MD Settings; Allow trailing slashes in otherwise valid URLs. BUG=615242 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ========== to ========== MD Settings: Allow trailing slashes in otherwise valid URLs. BUG=615242 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
dpapad@chromium.org changed reviewers: + tommycli@chromium.org
Could not find an easy way to write a test for this. navigateTo() accepts Route instances, not plain URLs, and initializeRouteFromUrl() looks at the URL, which I can't tweak during a test.
On 2016/11/23 21:32:08, dpapad wrote: > Could not find an easy way to write a test for this. navigateTo() accepts Route > instances, not plain URLs, and initializeRouteFromUrl() looks at the URL, which > I can't tweak during a test. Hi, Since getRouteForPath is exposed in the public interface, you could write some unit-test style tests like: expectEq(settings.Route.PEOPLE, 'people'); expectEq(settings.Route.PEOPLE, 'people/'); and so forth. Thanks!
thanks for the in-person explanation. production code lgtm. whole thing lgtm assuming adding those tests to route_tests works. Some comments below. https://codereview.chromium.org/2518763002/diff/20001/chrome/browser/resource... File chrome/browser/resources/settings/route.js (right): https://codereview.chromium.org/2518763002/diff/20001/chrome/browser/resource... chrome/browser/resources/settings/route.js:252: return !!matchingKey ? Route[matchingKey] : null; I assume doing Route[undefined] is bad? (when there is no matching key)? https://codereview.chromium.org/2518763002/diff/20001/chrome/browser/resource... chrome/browser/resources/settings/route.js:286: currentQueryParameters_ = new URLSearchParams(window.location.search); Should we use replaceState here to canonicalize the paths? i.e. when the user types in chrome://md-settings/searchEngines/, and presses enter, on load, it changes to chrome://md-settings/searchEngines. I think that would be a nicety, but not necessarily required. Maybe separate patch or deferring that would be fine too.
https://codereview.chromium.org/2518763002/diff/20001/chrome/browser/resource... File chrome/browser/resources/settings/route.js (right): https://codereview.chromium.org/2518763002/diff/20001/chrome/browser/resource... chrome/browser/resources/settings/route.js:249: return Route[key].path == (path == '/' ? path : path.replace(/\/$/, '')); As I am adding tests, I realized that getRouteForPath('//') returns BASIC instead of null. Looking for a way to tweak the regexp to fix this. https://codereview.chromium.org/2518763002/diff/20001/chrome/browser/resource... chrome/browser/resources/settings/route.js:252: return !!matchingKey ? Route[matchingKey] : null; On 2016/11/23 at 22:33:46, tommycli wrote: > I assume doing Route[undefined] is bad? (when there is no matching key)? Yes. The effective behavior was the same, a fals-y value was returned by getRouteForPath(), but using |undefined| as a key seemed odd to me. Current version seems more explicit.
The CQ bit was checked by dpapad@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
@tommycli: PTAL. I modified this CL since original LG, by beefing up the regular expression and adding tests. https://codereview.chromium.org/2518763002/diff/20001/chrome/browser/resource... File chrome/browser/resources/settings/route.js (right): https://codereview.chromium.org/2518763002/diff/20001/chrome/browser/resource... chrome/browser/resources/settings/route.js:286: currentQueryParameters_ = new URLSearchParams(window.location.search); On 2016/11/23 at 22:33:46, tommycli wrote: > Should we use replaceState here to canonicalize the paths? > > i.e. when the user types in chrome://md-settings/searchEngines/, and presses enter, on load, it changes to chrome://md-settings/searchEngines. > > I think that would be a nicety, but not necessarily required. Maybe separate patch or deferring that would be fine too. Leaving this for a separate CL, so that I can ensure first that others are OK with this change (old Options does not seem to do that).
lgtm nit: https://codereview.chromium.org/2518763002/diff/40001/chrome/browser/resource... File chrome/browser/resources/settings/route.js (right): https://codereview.chromium.org/2518763002/diff/40001/chrome/browser/resource... chrome/browser/resources/settings/route.js:245: var CANONICAL_PATH_REGEX = /(^\/)([\/-\w]{1,})(\/$)/; Any particular reason to use {1,} instead of +? just curious
https://codereview.chromium.org/2518763002/diff/40001/chrome/browser/resource... File chrome/browser/resources/settings/route.js (right): https://codereview.chromium.org/2518763002/diff/40001/chrome/browser/resource... chrome/browser/resources/settings/route.js:245: var CANONICAL_PATH_REGEX = /(^\/)([\/-\w]{1,})(\/$)/; On 2016/11/24 00:02:51, tommycli wrote: > Any particular reason to use {1,} instead of +? just curious Instead of just "+" Question mark is for the question, not for the non-greedy modifier lol
https://codereview.chromium.org/2518763002/diff/40001/chrome/browser/resource... File chrome/browser/resources/settings/route.js (right): https://codereview.chromium.org/2518763002/diff/40001/chrome/browser/resource... chrome/browser/resources/settings/route.js:245: var CANONICAL_PATH_REGEX = /(^\/)([\/-\w]{1,})(\/$)/; On 2016/11/24 at 00:04:07, tommycli wrote: > On 2016/11/24 00:02:51, tommycli wrote: > > Any particular reason to use {1,} instead of +? just curious > > Instead of just "+" > > Question mark is for the question, not for the non-greedy modifier lol Yes. I need to ensure that there is at least on character between the leading and trailing slashes, otherwise this assertion in my test fails, assertEquals(null, settings.getRouteForPath('//')); because it returns BASIC instead of null. The user visible bug is that if user navigates to chrome://md-settings// is considered a valid path, where as the expected behavior is to be forwarded to chrome://md-settings.
The CQ bit was checked by dpapad@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2518763002/diff/40001/chrome/browser/resource... File chrome/browser/resources/settings/route.js (right): https://codereview.chromium.org/2518763002/diff/40001/chrome/browser/resource... chrome/browser/resources/settings/route.js:245: var CANONICAL_PATH_REGEX = /(^\/)([\/-\w]{1,})(\/$)/; On 2016/11/24 at 00:07:41, dpapad wrote: > On 2016/11/24 at 00:04:07, tommycli wrote: > > On 2016/11/24 00:02:51, tommycli wrote: > > > Any particular reason to use {1,} instead of +? just curious > > > > Instead of just "+" > > > > Question mark is for the question, not for the non-greedy modifier lol > > Yes. I need to ensure that there is at least on character between the leading and trailing slashes, otherwise this assertion in my test fails, > > assertEquals(null, settings.getRouteForPath('//')); > > because it returns BASIC instead of null. The user visible bug is that if user navigates to > chrome://md-settings// is considered a valid path, where as the expected behavior is to be forwarded to > chrome://md-settings. Done. I double checked and {1,} is equivalent to + (I must have tried * instead of + initially).
The CQ bit was checked by dpapad@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from tommycli@chromium.org Link to the patchset: https://codereview.chromium.org/2518763002/#ps80001 (title: "Nit per Tommy's comment.")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) chromeos_amd64-generic_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) chromeos_x86-generic_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) chromium_presubmit on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) closure_compilation on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) linux_chromium_chromeos_compile_dbg_ng on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) linux_chromium_chromeos_ozone_rel_ng on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) linux_chromium_clobber_rel_ng on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL) linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_TIMED_OUT, no build URL)
The CQ bit was checked by dpapad@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
The CQ bit was checked by dpapad@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 80001, "attempt_start_ts": 1480379268081130,
"parent_rev": "e400993781978e47f01392bda00965e343126355", "commit_rev":
"14cea14c8c32887f2e5745ba0fca5960f6cd1c3d"}
Message was sent while issue was closed.
Committed patchset #5 (id:80001)
Message was sent while issue was closed.
Description was changed from ========== MD Settings: Allow trailing slashes in otherwise valid URLs. BUG=615242 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation ========== to ========== MD Settings: Allow trailing slashes in otherwise valid URLs. BUG=615242 CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation Committed: https://crrev.com/67c02ed84a243982e46ed96bdf392ee213b5fef1 Cr-Commit-Position: refs/heads/master@{#434816} ==========
Message was sent while issue was closed.
Patchset 5 (id:??) landed as https://crrev.com/67c02ed84a243982e46ed96bdf392ee213b5fef1 Cr-Commit-Position: refs/heads/master@{#434816} |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
