| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 suite('route', function() { | 5 suite('route', function() { |
| 6 /** | 6 /** |
| 7 * Returns a new promise that resolves after a window 'popstate' event. | 7 * Returns a new promise that resolves after a window 'popstate' event. |
| 8 * @return {!Promise} | 8 * @return {!Promise} |
| 9 */ | 9 */ |
| 10 function whenPopState(causeEvent) { | 10 function whenPopState(causeEvent) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return whenPopState(function() { | 150 return whenPopState(function() { |
| 151 window.history.back(); | 151 window.history.back(); |
| 152 }).then(function() { | 152 }).then(function() { |
| 153 assertEquals(settings.Route.BASIC, settings.getCurrentRoute()); | 153 assertEquals(settings.Route.BASIC, settings.getCurrentRoute()); |
| 154 assertTrue(settings.lastRouteChangeWasPopstate()); | 154 assertTrue(settings.lastRouteChangeWasPopstate()); |
| 155 | 155 |
| 156 settings.navigateTo(settings.Route.ADVANCED); | 156 settings.navigateTo(settings.Route.ADVANCED); |
| 157 assertFalse(settings.lastRouteChangeWasPopstate()); | 157 assertFalse(settings.lastRouteChangeWasPopstate()); |
| 158 }); | 158 }); |
| 159 }); | 159 }); |
| 160 |
| 161 test('getRouteForPath trailing slashes', function() { |
| 162 assertEquals(settings.Route.BASIC, settings.getRouteForPath('/')); |
| 163 assertEquals(null, settings.getRouteForPath('//')); |
| 164 |
| 165 // Simple path. |
| 166 assertEquals(settings.Route.PEOPLE, settings.getRouteForPath('/people/')); |
| 167 assertEquals(settings.Route.PEOPLE, settings.getRouteForPath('/people')); |
| 168 |
| 169 // Path with a slash. |
| 170 assertEquals( |
| 171 settings.Route.SITE_SETTINGS_COOKIES, |
| 172 settings.getRouteForPath('/content/cookies')); |
| 173 assertEquals( |
| 174 settings.Route.SITE_SETTINGS_COOKIES, |
| 175 settings.getRouteForPath('/content/cookies/')); |
| 176 |
| 177 if (cr.isChromeOS) { |
| 178 // Path with a dash. |
| 179 assertEquals( |
| 180 settings.Route.KEYBOARD, |
| 181 settings.getRouteForPath('/keyboard-overlay')); |
| 182 assertEquals( |
| 183 settings.Route.KEYBOARD, |
| 184 settings.getRouteForPath('/keyboard-overlay/')); |
| 185 } |
| 186 }); |
| 160 }); | 187 }); |
| OLD | NEW |