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

Unified Diff: chrome/browser/resources/certificate_viewer.js

Issue 10382145: Fix for broken CertificateViewerUITest.testDetails. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: addEventListener() requires 'true' for useCapture argument. Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/webui/certificate_viewer_dialog_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/certificate_viewer.js
diff --git a/chrome/browser/resources/certificate_viewer.js b/chrome/browser/resources/certificate_viewer.js
index 417f5604149127090ba1f345c62099a21237d685..d8223b1100805d84acfd26e0f120f0a4f5c38398 100644
--- a/chrome/browser/resources/certificate_viewer.js
+++ b/chrome/browser/resources/certificate_viewer.js
@@ -17,17 +17,31 @@ cr.define('cert_viewer', function() {
var args = JSON.parse(chrome.dialogArguments);
getCertificateInfo(args);
+ /**
+ * Initialize the second tab's contents.
+ * This is a 'oneShot' function, meaning it will only be invoked once,
+ * no matter how many times it is called. This is done for unit-testing
+ * purposes in case a test needs to initialize the tab before the timer
+ * fires.
+ */
+ var initializeDetailTab = oneShot(function() {
+ initializeTree($('hierarchy'), showCertificateFields);
+ initializeTree($('cert-fields'), showCertificateFieldValue);
+ createCertificateHierarchy(args.hierarchy);
+ });
+
// The second tab's contents aren't visible on startup, so we can
// shorten startup by not populating those controls until after we
// have had a chance to draw the visible controls the first time.
// The value of 200ms is quick enough that the user couldn't open the
// tab in that time but long enough to allow the first tab to draw on
// even the slowest machine.
- setTimeout(function() {
- initializeTree($('hierarchy'), showCertificateFields);
- initializeTree($('cert-fields'), showCertificateFieldValue);
- createCertificateHierarchy(args.hierarchy);
- }, 200);
+ setTimeout(initializeDetailTab, 200);
+
+ $('tabbox').addEventListener('selectedChange', function f(e) {
+ $('tabbox').removeEventListener('selectedChange', f);
+ initializeDetailTab();
+ }, true);
stripGtkAccessorKeys();
@@ -41,6 +55,18 @@ cr.define('cert_viewer', function() {
}
/**
+ * Decorate a function so that it can only be invoked once.
+ */
+ function oneShot(fn) {
+ var fired = false;
+ return function() {
+ if (fired) return;
+ fn();
+ fired = true;
+ };
+ }
+
+ /**
* Initialize a cr.ui.Tree object from a given element using the specified
* change handler.
* @param {HTMLElement} tree The HTMLElement to style as a tree.
« no previous file with comments | « no previous file | chrome/test/data/webui/certificate_viewer_dialog_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698