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

Side by Side Diff: chrome/test/data/webui/settings/settings_idle_render_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
(Empty)
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
3 // found in the LICENSE file.
4
5 /** @fileoverview Tests for settings-idle-render. */
6
7 /** @const {string} Path to root from chrome/test/data/webui/settings/. */
8 var ROOT_PATH = '../../../../../';
9
10 /**
11 * @constructor
12 * @extends testing.Test
13 */
14 function SettingsIdleRenderBrowserTest() {}
15
16 SettingsIdleRenderBrowserTest.prototype = {
17 __proto__: testing.Test.prototype,
18
19 /** @override */
20 browsePreload: 'chrome://md-settings/controls/setting_idle_render.html',
21
22 /** @override */
23 extraLibraries: [
24 ROOT_PATH + 'third_party/mocha/mocha.js',
25 '../mocha_adapter.js',
26 ],
27
28 /** @override */
29 isAsync: true,
30
31 /** @override */
32 runAccessibilityChecks: false,
33 };
34
35 TEST_F('SettingsIdleRenderBrowserTest', 'render', function() {
36 // Register mocha tests.
37 suite('Settings idle render tests', function() {
38 setup(function() {
39 var template =
40 '<template is="settings-idle-render" id="idleTemplate">' +
41 ' <div>' +
42 ' </div>' +
43 '</template>';
44 document.body.innerHTML = template;
45 // The div should not be initially accesible.
46 assertFalse(!!document.body.querySelector('div'));
47 });
48
49 test('stamps after get()', function() {
50 // Calling get() will force stamping without waiting for idle time.
51 var inner = document.getElementById('idleTemplate').get();
52 assertEquals('DIV', inner.nodeName);
53 assertEquals(inner, document.body.querySelector('div'));
54 });
55
56 test('stamps after idle', function(done) {
57 requestIdleCallback(function() {
58 // After JS calls idle-callbacks, this should be accesible.
59 assertTrue(!!document.body.querySelector('div'));
60 done();
61 });
62 });
63 });
64
65 // Run all registered tests.
66 mocha.run();
67 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698