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

Unified Diff: chrome/test/remoting/http_server/hostpage.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 initial code review comments 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
Index: chrome/test/remoting/http_server/hostpage.js
diff --git a/chrome/test/remoting/http_server/hostpage.js b/chrome/test/remoting/http_server/hostpage.js
new file mode 100644
index 0000000000000000000000000000000000000000..a39cbecb2b8aba3529a882313d6cc554bcca2382
--- /dev/null
+++ b/chrome/test/remoting/http_server/hostpage.js
@@ -0,0 +1,42 @@
+// 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.
+
+/**
+ * Keypress handler for the textarea. Sends the textarea value
+ * to the HTTP server when "Enter" key is pressed.
+ * @param {Event} e The keypress event.
+ */
+function handleTextareaKeyPressed(event) {
+ // If the "Enter" key is pressed
+ // then process the text in the textarea.
Jamie 2014/03/04 21:40:35 Nit: This comment is wrapped in an odd place.
chaitali 2014/03/05 22:02:22 Done.
+ if (event.which == 13) {
+ var testTextVal = document.getElementById('testtext').value;
+ var postParams = 'text=' + testTextVal;
+
+ var request = new XMLHttpRequest();
+ request.open('POST', '/keytest/test', true);
Jamie 2014/03/04 21:40:35 Can we use a relative URL here too?
chaitali 2014/03/05 22:02:22 Same comment. Removed the initial / if thats what
+ request.setRequestHeader(
+ 'Content-type', 'application/x-www-form-urlencoded');
+
+ request.onreadystatechange = function() {
+ if(request.readyState == 4 && request.status == 200) {
+ console.log('Sent POST request to server.');
+ }
+ };
+
+ request.onerror = function() {
+ console.log('Request failed');
+ };
+
+ request.send(postParams);
+ }
+};
+
+window.addEventListener('load', function(){
+ document.getElementById('testtext').addEventListener(
+ 'keypress',
+ handleTextareaKeyPressed,
+ false);
+});
Jamie 2014/03/04 21:40:35 Missing 'false'.
chaitali 2014/03/05 22:02:22 Done.
+

Powered by Google App Engine
This is Rietveld 408576698