Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/test/data/webui/settings/settings_idle_load_browsertest.js

Issue 2754563002: MD Settings: Lazy load the contents of the "advanced" settings. (Closed)
Patch Set: Address comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 Tests for settings-idle-render. */ 5 /** @fileoverview Tests for settings-idle-load. */
6 6
7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */ 7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */
8 var ROOT_PATH = '../../../../../'; 8 var ROOT_PATH = '../../../../../';
9 9
10 /** 10 /**
11 * @constructor 11 * @constructor
12 * @extends testing.Test 12 * @extends testing.Test
13 */ 13 */
14 function SettingsIdleRenderBrowserTest() {} 14 function SettingsIdleLoadBrowserTest() {}
15 15
16 SettingsIdleRenderBrowserTest.prototype = { 16 SettingsIdleLoadBrowserTest.prototype = {
17 __proto__: testing.Test.prototype, 17 __proto__: testing.Test.prototype,
18 18
19 /** @override */ 19 /** @override */
20 browsePreload: 'chrome://md-settings/controls/setting_idle_render.html', 20 browsePreload: 'chrome://md-settings/controls/setting_idle_load.html',
21 21
22 /** @override */ 22 /** @override */
23 extraLibraries: [ 23 extraLibraries: [
24 ROOT_PATH + 'third_party/mocha/mocha.js', 24 ROOT_PATH + 'third_party/mocha/mocha.js',
25 '../mocha_adapter.js', 25 '../mocha_adapter.js',
26 ], 26 ],
27 27
28 /** @override */ 28 /** @override */
29 isAsync: true, 29 isAsync: true,
30 30
31 /** @override */ 31 /** @override */
32 runAccessibilityChecks: false, 32 runAccessibilityChecks: false,
33 }; 33 };
34 34
35 TEST_F('SettingsIdleRenderBrowserTest', 'render', function() { 35 TEST_F('SettingsIdleLoadBrowserTest', 'All', function() {
36 // Register mocha tests. 36 // Register mocha tests.
37 suite('Settings idle render tests', function() { 37 suite('Settings idle load tests', function() {
38 setup(function() { 38 setup(function() {
39 var template = 39 var template =
40 '<template is="settings-idle-render" id="idleTemplate">' + 40 '<template is="settings-idle-load" id="idleTemplate" '+
41 ' <div>' + 41 ' url="chrome://resources/html/polymer.html">' +
42 ' </div>' + 42 ' <div></div>' +
43 '</template>'; 43 '</template>';
44 document.body.innerHTML = template; 44 document.body.innerHTML = template;
45 // The div should not be initially accesible. 45 // The div should not be initially accesible.
46 assertFalse(!!document.body.querySelector('div')); 46 assertFalse(!!document.body.querySelector('div'));
47 }); 47 });
48 48
49 test('stamps after get()', function() { 49 test('stamps after get()', function() {
50 // Calling get() will force stamping without waiting for idle time. 50 // Calling get() will force stamping without waiting for idle time.
51 var inner = document.getElementById('idleTemplate').get(); 51 return document.getElementById('idleTemplate').get().then(
52 assertEquals('DIV', inner.nodeName); 52 function(inner) {
53 assertEquals(inner, document.body.querySelector('div')); 53 assertEquals('DIV', inner.nodeName);
54 assertEquals(inner, document.body.querySelector('div'));
55 });
54 }); 56 });
55 57
56 test('stamps after idle', function(done) { 58 test('stamps after idle', function(done) {
57 requestIdleCallback(function() { 59 requestIdleCallback(function() {
58 // After JS calls idle-callbacks, this should be accesible. 60 // After JS calls idle-callbacks, this should be accesible.
59 assertTrue(!!document.body.querySelector('div')); 61 assertTrue(!!document.body.querySelector('div'));
60 done(); 62 done();
61 }); 63 });
62 }); 64 });
63 }); 65 });
64 66
65 // Run all registered tests. 67 // Run all registered tests.
66 mocha.run(); 68 mocha.run();
67 }); 69 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698