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

Unified Diff: chrome/browser/resources/engagement/site_engagement.js

Issue 2780873003: Add a browser test for the chrome://site-engagement WebUI. (Closed)
Patch Set: Address review 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/engagement/site_engagement.js
diff --git a/chrome/browser/resources/engagement/site_engagement.js b/chrome/browser/resources/engagement/site_engagement.js
index f8c7ccccd9aa492e39e7f14c040a9ce41733ed15..e93cd1603ca6d08d42d03489ecafe3cafed455e1 100644
--- a/chrome/browser/resources/engagement/site_engagement.js
+++ b/chrome/browser/resources/engagement/site_engagement.js
@@ -4,6 +4,27 @@
'use strict';
+// Allow a function to be provided by tests, which will be called when
+// the page has been populated with site engagement details.
+var pagePopulatedCallback = null;
+var isPagePopulated = false;
+
+function setPagePopulatedCallbackForTest(callback) {
Bernhard Bauer 2017/03/31 13:04:59 This looks like you could use Promises (https://de
calamity 2017/04/03 04:38:52 Indeed! I think something like var populatedReso
Wez 2017/04/05 20:49:37 Done. Note that the downside is that we're alloca
Bernhard Bauer 2017/04/06 15:20:47 I personally don't think it's a big issue, but you
Wez 2017/04/06 23:48:06 The problem is then that the page might have compl
+ if (isPagePopulated) {
+ callback();
+ } else {
+ pagePopulatedCallback = callback;
+ }
+}
+
+function notifyPagePopulated() {
+ isPagePopulated = true;
+ if (pagePopulatedCallback) {
+ pagePopulatedCallback();
+ pagePopulatedCallback = null;
+ }
+}
+
define('main', [
'chrome/browser/engagement/site_engagement.mojom',
'content/public/renderer/frame_interfaces',
@@ -155,6 +176,8 @@ define('main', [
info.score = Number(Math.round(info.score * 100) / 100);
engagementTableBody.appendChild(createRow(info));
});
+
+ notifyPagePopulated();
calamity 2017/04/03 04:38:52 I think this should move to line 191 so that the p
Wez 2017/04/05 20:49:37 The browser test is actually verifying that there
}
/**

Powered by Google App Engine
This is Rietveld 408576698