| 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 cr.define('settings_subpage', function() { | 5 cr.define('settings_subpage', function() { |
| 6 suite('SettingsSubpage', function() { | 6 suite('SettingsSubpage', function() { |
| 7 test('navigates to parent when there is no history', function() { | 7 test('navigates to parent when there is no history', function() { |
| 8 PolymerTest.clearBody(); | 8 PolymerTest.clearBody(); |
| 9 | 9 |
| 10 // Pretend that we initially started on the CERTIFICATES route. | 10 // Pretend that we initially started on the CERTIFICATES route. |
| 11 window.history.replaceState( | 11 window.history.replaceState( |
| 12 undefined, '', settings.Route.CERTIFICATES.path); | 12 undefined, '', settings.routes.CERTIFICATES.path); |
| 13 settings.initializeRouteFromUrl(); | 13 settings.initializeRouteFromUrl(); |
| 14 assertEquals(settings.Route.CERTIFICATES, settings.getCurrentRoute()); | 14 assertEquals(settings.routes.CERTIFICATES, settings.getCurrentRoute()); |
| 15 | 15 |
| 16 var subpage = document.createElement('settings-subpage'); | 16 var subpage = document.createElement('settings-subpage'); |
| 17 document.body.appendChild(subpage); | 17 document.body.appendChild(subpage); |
| 18 | 18 |
| 19 MockInteractions.tap(subpage.$$('button')); | 19 MockInteractions.tap(subpage.$$('button')); |
| 20 assertEquals(settings.Route.PRIVACY, settings.getCurrentRoute()); | 20 assertEquals(settings.routes.PRIVACY, settings.getCurrentRoute()); |
| 21 }); | 21 }); |
| 22 | 22 |
| 23 test('navigates to any route via window.back()', function(done) { | 23 test('navigates to any route via window.back()', function(done) { |
| 24 PolymerTest.clearBody(); | 24 PolymerTest.clearBody(); |
| 25 | 25 |
| 26 settings.navigateTo(settings.Route.BASIC); | 26 settings.navigateTo(settings.routes.BASIC); |
| 27 settings.navigateTo(settings.Route.SYNC); | 27 settings.navigateTo(settings.routes.SYNC); |
| 28 assertEquals(settings.Route.SYNC, settings.getCurrentRoute()); | 28 assertEquals(settings.routes.SYNC, settings.getCurrentRoute()); |
| 29 | 29 |
| 30 var subpage = document.createElement('settings-subpage'); | 30 var subpage = document.createElement('settings-subpage'); |
| 31 document.body.appendChild(subpage); | 31 document.body.appendChild(subpage); |
| 32 | 32 |
| 33 MockInteractions.tap(subpage.$$('button')); | 33 MockInteractions.tap(subpage.$$('button')); |
| 34 | 34 |
| 35 window.addEventListener('popstate', function(event) { | 35 window.addEventListener('popstate', function(event) { |
| 36 assertEquals(settings.Route.BASIC, settings.getCurrentRoute()); | 36 assertEquals(settings.routes.BASIC, settings.getCurrentRoute()); |
| 37 done(); | 37 done(); |
| 38 }); | 38 }); |
| 39 }); | 39 }); |
| 40 }); | 40 }); |
| 41 | 41 |
| 42 suite('SettingsSubpageSearch', function() { | 42 suite('SettingsSubpageSearch', function() { |
| 43 test('host autofocus propagates to <input>', function() { | 43 test('host autofocus propagates to <input>', function() { |
| 44 PolymerTest.clearBody(); | 44 PolymerTest.clearBody(); |
| 45 var element = document.createElement('settings-subpage-search'); | 45 var element = document.createElement('settings-subpage-search'); |
| 46 element.setAttribute('autofocus', true); | 46 element.setAttribute('autofocus', true); |
| 47 document.body.appendChild(element); | 47 document.body.appendChild(element); |
| 48 | 48 |
| 49 assertTrue(element.$$('input').hasAttribute('autofocus')); | 49 assertTrue(element.$$('input').hasAttribute('autofocus')); |
| 50 | 50 |
| 51 element.removeAttribute('autofocus'); | 51 element.removeAttribute('autofocus'); |
| 52 assertFalse(element.$$('input').hasAttribute('autofocus')); | 52 assertFalse(element.$$('input').hasAttribute('autofocus')); |
| 53 }); | 53 }); |
| 54 }); | 54 }); |
| 55 }); | 55 }); |
| OLD | NEW |