Should chose the best match during 'route' if there are multiple matches.
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jan 2018 23:41:37 +0000 (23:41 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jan 2018 23:41:37 +0000 (23:41 +0000)
commitdb62ab7d373bddd970af21e08d3f024f447d636d
tree6707589d4490c63ab44ebe9d3004ddade8c7c118
parent867cbf0f5396808f9c72771595ee4bcc5af204c1
Should chose the best match during 'route' if there are multiple matches.
https://bugs.webkit.org/show_bug.cgi?id=182326

Reviewed by Ryosuke Niwa.

r227749 made a change that 'analysisCategoryPage' will be added before 'analysisTaskPage'.
As route names for both pages starts with 'analysis', whichever added first will be chosen.
For a route like 'analysis/task/1'. As a result, 'analysisCategoryPage' will be chosen and
this is not expected behavior. Adding the logic on the cases when route name does not extact
match the route name, always choose the longest mathcing route name.

Also modernized the code of 'page-router.js' to use const & let instead of var.

Added a browser test to guard against this bug.

* browser-tests/index.html: Import 'page-router-tests.js'.
* browser-tests/page-router-tests.js: Added unit test to guard against this bug.
* public/v3/pages/page-router.js:
(PageRouter.prototype.route): Added logic to find best matching in the case of inexact match.
(PageRouter.prototype.pageDidOpen):
(PageRouter.prototype._updateURLState):
(PageRouter.prototype._serializeToHash):
(PageRouter.prototype._deserializeFromHash):
(PageRouter.prototype._serializeHashQueryValue):
(PageRouter.prototype._deserializeHashQueryValue):
(PageRouter.prototype._countOccurrences):
(PageRouter):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227938 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/browser-tests/index.html
Websites/perf.webkit.org/browser-tests/page-router-tests.js [new file with mode: 0644]
Websites/perf.webkit.org/public/v3/pages/page-router.js