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

Side by Side Diff: chrome/browser/resources/engagement/site_engagement.js

Issue 2780873003: Add a browser test for the chrome://site-engagement WebUI. (Closed)
Patch Set: Switch to Promise Created 3 years, 8 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 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 'use strict'; 5 'use strict';
6 6
7 // Allow a function to be provided by tests, which will be called when
8 // the page has been populated with site engagement details.
9 var resolvePageIsPopulated = null;
10 var pageIsPopulated = new Promise(function(resolve, reject) {
11 resolvePageIsPopulated = resolve;
12 });
13
14 function pageIsPopulatedPromiseForTest() {
15 return pageIsPopulated;
16 }
17
7 define('main', [ 18 define('main', [
8 'chrome/browser/engagement/site_engagement.mojom', 19 'chrome/browser/engagement/site_engagement.mojom',
9 'content/public/renderer/frame_interfaces', 20 'content/public/renderer/frame_interfaces',
10 ], function(siteEngagementMojom, frameInterfaces) { 21 ], function(siteEngagementMojom, frameInterfaces) {
11 return function() { 22 return function() {
12 var uiHandler = new siteEngagementMojom.SiteEngagementUIHandlerPtr( 23 var uiHandler = new siteEngagementMojom.SiteEngagementUIHandlerPtr(
13 frameInterfaces.getInterface( 24 frameInterfaces.getInterface(
14 siteEngagementMojom.SiteEngagementUIHandler.name)); 25 siteEngagementMojom.SiteEngagementUIHandler.name));
15 26
16 var engagementTableBody = $('engagement-table-body'); 27 var engagementTableBody = $('engagement-table-body');
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 * Regenerates the engagement table from |info|. 159 * Regenerates the engagement table from |info|.
149 */ 160 */
150 function renderTable() { 161 function renderTable() {
151 clearTable(); 162 clearTable();
152 sortInfo(); 163 sortInfo();
153 // Round each score to 2 decimal places. 164 // Round each score to 2 decimal places.
154 info.forEach(function(info) { 165 info.forEach(function(info) {
155 info.score = Number(Math.round(info.score * 100) / 100); 166 info.score = Number(Math.round(info.score * 100) / 100);
156 engagementTableBody.appendChild(createRow(info)); 167 engagementTableBody.appendChild(createRow(info));
157 }); 168 });
169
170 resolvePageIsPopulated();
158 } 171 }
159 172
160 /** 173 /**
161 * Retrieve site engagement info and render the engagement table. 174 * Retrieve site engagement info and render the engagement table.
162 */ 175 */
163 function updateEngagementTable() { 176 function updateEngagementTable() {
164 // Populate engagement table. 177 // Populate engagement table.
165 uiHandler.getSiteEngagementInfo().then(function(response) { 178 uiHandler.getSiteEngagementInfo().then(function(response) {
166 info = response.info; 179 info = response.info;
167 renderTable(info); 180 renderTable(info);
168 }); 181 });
169 }; 182 };
170 183
171 updateEngagementTable(); 184 updateEngagementTable();
172 enableAutoupdate(); 185 enableAutoupdate();
173 }; 186 };
174 }); 187 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698