summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/register_form.html
blob: b2bd767b963bd7c57aeb74949e4c6deda86b2669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<!-- Test page for Chrome OS register form that is hosted at OEM partner site
     and is loaded in chrome://register host page -->
<html><head>
<title>Registration test form</title>
<style>

#main {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  padding: 10px;
  overflow: hidden;
  background: -webkit-gradient(linear, left top, left bottom, from(#FAFBFB), to(#CCD1D4));
}
</style>
<script>
document.addEventListener('DOMContentLoaded', load);
var hostUrl = 'chrome://register';

window.addEventListener('message', processMessage);

function $(o) {
  return document.getElementById(o);
}

function load() {
  var msg = {
    type: 'get_user_info',
    domain: location.href,
    payload: {}
  };
  window.parent.postMessage(msg, hostUrl);
  $('url').textContent = location.href;
}

function processMessage(e) {
  // TODO(nkostylev): e.origin is passed as null and not checked.
  // Probably because it's served from chrome:// scheme.
  if (e.data.domain != hostUrl) {
    registration(false);
    return;
  }
 
  if (e.data.type == 'set_user_info') {
    var info = e.data.payload;
    $('info').textContent = 'OS: ' + info.os_name + ', ' +
        info.os_version + ' SKU:' + info.system_sku + ', system hwqual: ' +
        info.system_hwqual + ', SN: ' + info.system_serial + ', lang: ' +
        info.os_language + ', connection: ' + info.os_connection + ', user: ' +
        info.user_email;
  }

  $('messageInfo').textContent = 'e.origin: ' + e.origin +
      ', e.data.domain: ' + e.data.domain;
}

function registration(result) {
  var msg = {
    type: 'complete_registration',
    domain: location.href,
    payload: {
      registration_status: result
    }
  };
  var parent = window.parent;
  parent.postMessage(msg, hostUrl);
}
</script>
</head>
<body>
<div id="main">
  <h3>Register your computer with Google</h3>
  <i>This registration form is hosted at </i><div id="url"></div><br>
  <i>User info received from host page:</i><br>
  <div id="info"></div><br>
  <i>Message info:</i><br>
  <div id="messageInfo"></div><br>
  <input type="button" value="Skip" onclick="registration(false);">
  <input type="button" value="Register" onclick="registration(true);">
</div>
</body></html>