| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @fileoverview Suite of tests for the Settings basic page. */ | 5 /** @fileoverview Suite of tests for the Settings basic page. */ |
| 6 | 6 |
| 7 GEN_INCLUDE(['settings_page_browsertest.js']); | 7 GEN_INCLUDE(['settings_page_browsertest.js']); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * @constructor | 10 * @constructor |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 else | 45 else |
| 46 sections = sections.concat(['internet', 'device']); | 46 sections = sections.concat(['internet', 'device']); |
| 47 | 47 |
| 48 for (var i = 0; i < sections.length; i++) { | 48 for (var i = 0; i < sections.length; i++) { |
| 49 var section = self.getSection(page, sections[i]); | 49 var section = self.getSection(page, sections[i]); |
| 50 expectTrue(!!section); | 50 expectTrue(!!section); |
| 51 self.verifySubpagesHidden(section); | 51 self.verifySubpagesHidden(section); |
| 52 } | 52 } |
| 53 }); | 53 }); |
| 54 | 54 |
| 55 // This test checks for a regression that occurred with scrollToSection_ | |
| 56 // failing to find its host element. | |
| 57 test('scroll to section', function() { | 55 test('scroll to section', function() { |
| 58 // Setting the page and section will cause a scrollToSection_. | 56 // Setting the page and section will cause a scrollToSection_. |
| 59 settings.navigateTo(settings.Route.ON_STARTUP); | 57 settings.navigateTo(settings.Route.ON_STARTUP); |
| 60 | 58 |
| 59 var page = self.getPage('basic'); |
| 60 |
| 61 return new Promise(function(resolve, reject) { | 61 return new Promise(function(resolve, reject) { |
| 62 // This test checks for a regression that occurred with scrollToSection_ |
| 63 // failing to find its host element. |
| 62 var intervalId = window.setInterval(function() { | 64 var intervalId = window.setInterval(function() { |
| 63 var page = self.getPage('basic'); | 65 var page = self.getPage('basic'); |
| 64 if (self.getSection(page, settings.getCurrentRoute().section)) { | 66 if (self.getSection(page, settings.getCurrentRoute().section)) { |
| 65 window.clearInterval(intervalId); | 67 window.clearInterval(intervalId); |
| 66 resolve(); | 68 resolve(); |
| 67 } | 69 } |
| 68 }, 55); | 70 }, 55); |
| 69 }.bind(self)); | 71 }.bind(self)).then(function() { |
| 72 // Should be scrolled to the On Startup section. |
| 73 assertNotEquals(0, page.scroller.scrollTop); |
| 74 |
| 75 return new Promise(function(resolve) { |
| 76 listenOnce(window, 'popstate', resolve); |
| 77 settings.navigateToPreviousRoute(); |
| 78 }); |
| 79 }).then(function() { |
| 80 // Should be at the top of the page after going Back from the section. |
| 81 assertEquals(0, page.scroller.scrollTop); |
| 82 }); |
| 70 }); | 83 }); |
| 71 }); | 84 }); |
| 72 | 85 |
| 73 // Run all registered tests. | 86 // Run all registered tests. |
| 74 mocha.run(); | 87 mocha.run(); |
| 75 }); | 88 }); |
| OLD | NEW |