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

Unified Diff: chrome/test/remoting/http_server/clientpage.js

Issue 180273015: Simple HTTP server for Chromoting End-to-End tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing lint issues reported by gjslint Created 6 years, 10 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 | « chrome/test/remoting/http_server/clientpage.html ('k') | chrome/test/remoting/http_server/hostpage.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/remoting/http_server/clientpage.js
diff --git a/chrome/test/remoting/http_server/clientpage.js b/chrome/test/remoting/http_server/clientpage.js
new file mode 100644
index 0000000000000000000000000000000000000000..f346a299b791d1e9ba95e918862424d7fcc44ea7
--- /dev/null
+++ b/chrome/test/remoting/http_server/clientpage.js
@@ -0,0 +1,55 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Set some global variables for the browsertest to pick up
+var keyTestNamespace = {
+ keypressSucceeded: false,
+ keypressText: ''
+};
+
+/**
+ * Method to make an XHR call to the server for status
+ */
+// TODO(chaitali): Update this method to poll and get status of all
+// test vars in each poll and stop when all are true.
+function poll() {
+
+ var request = new XMLHttpRequest();
+ request.open('GET', 'poll?test=keytest', true);
+
+ request.onreadystatechange = function() {
+ if (request.readyState == 4 && request.status == 200) {
+ console.log('Polling status : ' + request.responseText);
+ var data;
+ try {
+ data = JSON.parse(request.responseText);
+ } catch (err) {
+ console.log('Could not parse server response.');
+ return;
+ }
+ // If keypress succeeded then
+ // update relevant vars and stop polling.
+ if (data.keypressSucceeded == true) {
+ keyTestNamespace.keypressSucceeded = data.keypressSucceeded;
+ keyTestNamespace.keypressText = data.keypressText;
+ } else {
+ // If keypress did not succeed we should
+ // continue polling.
+ setTimeout(poll, 1000);
+ }
+ }
+ };
+
+ request.onerror = function() {
+ console.log('Polling failed');
+ };
+
+ request.send();
+}
+
+window.addEventListener(
+ 'load',
+ poll.bind(null),
+ false);
+
« no previous file with comments | « chrome/test/remoting/http_server/clientpage.html ('k') | chrome/test/remoting/http_server/hostpage.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698