• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<script type="text/javascript">
2function SetSrc(src) {
3  var plugin = document.getElementById('plugin');
4  plugin.src = src;
5}
6function SetSize(w, h) {
7  var plugin = document.getElementById('plugin');
8  plugin.width = w;
9  plugin.height = h;
10}
11function PostMessage(data, shouldTargetIframe) {
12  plugin = document.getElementById('plugin');
13  // TODO(fsamuel): contentWindow can be accessed directly once
14  // http://wkbug.com/85679 lands.
15  if (shouldTargetIframe) {
16    plugin.contentWindow.frames[0].postMessage('testing123', '*');
17  } else {
18    plugin.contentWindow.frames.postMessage('testing123', '*');
19  }
20}
21function SetTitle(str) {
22  document.title = str;
23}
24document.title = 'embedder';
25</script>
26
27<object id="plugin"
28    tabindex="0"
29    type="application/browser-plugin"
30    width="640"
31    height="480"
32    border="0px"></object>
33<script type="text/javascript">
34var msg;
35function receiveMessage(event) {
36  msg = event.data;
37  if (msg == 'ready') {
38    document.title = 'ready';
39    return;
40  }
41  if (msg.indexOf('stop_ack') == -1) {
42    event.source.postMessage('stop', '*');
43  } else {
44    var name = msg.replace("stop_ack", "").trim();
45    if (name !== '') {
46      window.document.title = name;
47    } else {
48      window.document.title = 'main guest';
49    }
50  }
51}
52
53var plugin = document.getElementById('plugin');
54window.addEventListener('message', receiveMessage, false);
55plugin.addEventListener('-internal-instanceid-allocated', function(e) {
56  plugin['-internal-attach']({});
57});
58</script>
59