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

Side by Side 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: Addressing Jamie's comments Created 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Set some global variables for the browsertest to pick up
6 var keyTestNamespace = {
7 keypressSucceeded: false,
8 keypressText: ''
9 };
10
11 /**
12 * Method to make an XHR call to the server for status
13 */
14 // TODO(chaitali): Update this method to poll and get status of all
15 // test vars in each poll and stop when all are true.
16 function poll() {
17
18 var request = new XMLHttpRequest();
19 request.open('GET', 'poll?test=keytest', true);
20
21 request.onreadystatechange = function() {
22 if (request.readyState == 4 && request.status == 200) {
23 console.log('Polling status : ' + request.responseText);
24 var data;
25 try {
26 data = JSON.parse(request.responseText);
27 } catch (err) {
28 console.log('Could not parse server response.');
29 return;
30 }
31 // If keypress succeeded then
32 // update relevant vars and stop polling.
33 if (data.keypressSucceeded == true) {
34 keyTestNamespace.keypressSucceeded = data.keypressSucceeded;
35 keyTestNamespace.keypressText = data.keypressText;
36 } else {
37 // If keypress did not succeed we should
38 // continue polling.
39 setTimeout(poll, 1000);
40 }
41 }
42 };
43
44 request.onerror = function() {
45 console.log('Polling failed');
46 };
47
48 request.send();
49 };
50
51 window.addEventListener(
52 'load',
53 function(){
Jamie 2014/03/06 00:15:01 Nit: space before '{'. Or just use poll.bind(null)
chaitali 2014/03/06 00:41:51 Done.
54 poll();
55 },
56 false);
57
OLDNEW
« 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