• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<script language="JavaScript">
4
5function setup() {
6  if (location.hostname == 'tests' || location.hostname == 'localhost')
7    return;
8
9  alert('This page can only be run from tests or localhost');
10
11  // Disable all elements.
12  var elements = document.getElementById("form").elements;
13  for (var i = 0, element; element = elements[i++]; ) {
14    element.disabled = true;
15  }
16}
17
18// Send a query to the browser process.
19function execURLRequest() {
20  document.getElementById('ta').value = 'Request pending...';
21
22  // Results in a call to the OnQuery method in urlrequest_test.cpp
23  window.cefQuery({
24    request: 'URLRequestTest:' + document.getElementById("url").value,
25    onSuccess: function(response) {
26      document.getElementById('ta').value = response;
27    },
28    onFailure: function(error_code, error_message) {
29      document.getElementById('ta').value = 'Failed with error ' + error_message + ' (' + error_code + ')';
30    }
31  });
32}
33</script>
34</head>
35<body bgcolor="white" onload="setup()">
36<form id="form">
37URL: <input type="text" id="url" value="http://www.google.com">
38<br/><input type="button" onclick="execURLRequest();" value="Execute CefURLRequest">
39<br/><textarea rows="10" cols="40" id="ta"></textarea>
40</form>
41</body>
42</html>
43