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