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

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: 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/hostpage.html ('k') | chrome/test/remoting/http_server/http_server.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c99a144f6b0e943e4c51b072603f860573788684
--- /dev/null
+++ b/chrome/test/remoting/http_server/hostpage.js
@@ -0,0 +1,44 @@
+// 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} event The keypress event.
+ */
+function handleTextareaKeyPressed(event) {
+ // If the "Enter" key is pressed then process the text in the textarea.
+ if (event.which == 13) {
+ var testTextVal = document.getElementById('testtext').value;
+ var postParams = 'text=' + testTextVal;
+
+ var request = new XMLHttpRequest();
+ request.open('POST', 'keytest/test', true);
+ 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);
+ },
+ false);
+
« no previous file with comments | « chrome/test/remoting/http_server/hostpage.html ('k') | chrome/test/remoting/http_server/http_server.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698