Chromium Code Reviews| 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.
|
| + |