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

Unified Diff: remoting/webapp/crd/js/crd_main.js

Issue 771003002: Add support for deferring app initialization when testing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years 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: remoting/webapp/crd/js/crd_main.js
diff --git a/remoting/webapp/crd/js/crd_main.js b/remoting/webapp/crd/js/crd_main.js
index f7dc51e3289a1e2785dfa0d0796a3473f40cf86d..76f80c8ed14728a4143cf8e9e0a3ed2f3fd2972e 100644
--- a/remoting/webapp/crd/js/crd_main.js
+++ b/remoting/webapp/crd/js/crd_main.js
@@ -177,12 +177,31 @@ remoting.updateLocalHostState = function() {
};
/**
- * Entry point ('load' handler) for Remote Desktop (CRD) webapp.
+ * Entry point for test code. In order to make test and production
+ * code as similar as possible, the same entry point is used for
+ * production code, but since production code should never have
+ * 'source' set to 'test', it continue with initialization
+ * immediately. As a fail-safe, the mechanism by which initialization
+ * completes when under test is controlled by a simple UI, making it
+ * possible to use the app even if the previous assumption fails to
+ * hold in some corner cases.
*/
+remoting.initDesktopRemotingForTesting = function() {
+ var urlParams = getUrlParameters_();
+ if (urlParams['source'] === 'test') {
+ document.getElementById('browser-test-continue-init').addEventListener(
+ 'click', remoting.initDesktopRemoting, false);
+ document.getElementById('browser-test-deferred-init').hidden = false;
+ } else {
+ remoting.initDesktopRemoting();
+ }
+}
+
+
remoting.initDesktopRemoting = function() {
remoting.app = new remoting.Application();
var desktop_remoting = new remoting.DesktopRemoting(remoting.app);
remoting.app.init();
};
-window.addEventListener('load', remoting.initDesktopRemoting, false);
+window.addEventListener('load', remoting.initDesktopRemotingForTesting, false);

Powered by Google App Engine
This is Rietveld 408576698