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

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

Issue 2811643002: [SiteEngagement WebUI] Replace C++ browser test with JS version. (Closed)
Patch Set: rebase, address comments Created 3 years, 7 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 7 // Allow a function to be provided by tests, which will be called when
8 // the page has been populated with site engagement details. 8 // the page has been populated with site engagement details.
9 var resolvePageIsPopulated = null; 9 var resolvePageIsPopulated = null;
10 var pageIsPopulatedPromise = new Promise((resolve, reject) => { 10 var pageIsPopulatedPromise = new Promise((resolve, reject) => {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 /** 114 /**
115 * Sets the base engagement score when a score input is changed. 115 * Sets the base engagement score when a score input is changed.
116 * Resets the length of engagement-bar-cell to match the new score. 116 * Resets the length of engagement-bar-cell to match the new score.
117 * Also resets the update interval. 117 * Also resets the update interval.
118 * @param {string} origin The origin of the engagement score to set. 118 * @param {string} origin The origin of the engagement score to set.
119 * @param {Event} e 119 * @param {Event} e
120 */ 120 */
121 function handleBaseScoreChange(origin, e) { 121 function handleBaseScoreChange(origin, e) {
122 var baseScoreInput = e.target; 122 var baseScoreInput = e.target;
123 uiHandler.setSiteEngagementScoreForUrl(origin, baseScoreInput.value); 123 uiHandler.setSiteEngagementBaseScoreForUrl(origin, baseScoreInput.value);
124 baseScoreInput.barCellRef.style.width = (baseScoreInput.value * 4) + 'px'; 124 baseScoreInput.barCellRef.style.width = (baseScoreInput.value * 4) + 'px';
125 baseScoreInput.blur(); 125 baseScoreInput.blur();
126 enableAutoupdate(); 126 enableAutoupdate();
127 } 127 }
128 128
129 /** 129 /**
130 * Remove all rows from the engagement table. 130 * Remove all rows from the engagement table.
131 */ 131 */
132 function clearTable() { 132 function clearTable() {
133 engagementTableBody.innerHTML = ''; 133 engagementTableBody.innerHTML = '';
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 info.base_score = roundScore(info.base_score); 188 info.base_score = roundScore(info.base_score);
189 info.installed_bonus = roundScore(info.installed_bonus); 189 info.installed_bonus = roundScore(info.installed_bonus);
190 info.notifications_bonus = roundScore(info.notifications_bonus); 190 info.notifications_bonus = roundScore(info.notifications_bonus);
191 info.total_score = roundScore(info.total_score); 191 info.total_score = roundScore(info.total_score);
192 192
193 // Collate the bonuses into a value for the bonus_score column. 193 // Collate the bonuses into a value for the bonus_score column.
194 info.bonus_score = info.installed_bonus + info.notifications_bonus; 194 info.bonus_score = info.installed_bonus + info.notifications_bonus;
195 195
196 engagementTableBody.appendChild(createRow(info)); 196 engagementTableBody.appendChild(createRow(info));
197 }); 197 });
198
199 resolvePageIsPopulated();
200 } 198 }
201 199
202 /** 200 /**
203 * Retrieve site engagement info and render the engagement table. 201 * Retrieve site engagement info and render the engagement table.
204 */ 202 */
205 function updateEngagementTable() { 203 function updateEngagementTable() {
206 // Populate engagement table. 204 // Populate engagement table.
207 uiHandler.getSiteEngagementDetails().then((response) => { 205 uiHandler.getSiteEngagementDetails().then((response) => {
208 info = response.info; 206 info = response.info;
209 renderTable(info); 207 renderTable(info);
208 resolvePageIsPopulated();
210 }); 209 });
211 }; 210 };
212 211
213 updateEngagementTable(); 212 updateEngagementTable();
214 enableAutoupdate(); 213 enableAutoupdate();
215 }; 214 };
216 }); 215 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698