summaryrefslogtreecommitdiffstats
path: root/content/test/data/browser_plugin_embedder.html
blob: c0168b59805df366150591f6abcaeb61f9b773c1 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<script type="text/javascript">
function loadAbort(evt) {
  document.title = evt.type;
}
function loadStart(evt) {
  document.title = evt.url;
}
function loadStop(evt) {
  document.title = "loadStop";
}

var commitIsTopLevel;
function loadCommit(evt) {
  document.title = "loadCommit:" + evt.url;
  commitIsTopLevel = evt.isTopLevel;
}

var redirectOldUrl;
var redirectNewUrl;
function loadRedirect(event) {
  document.title = "redirected";
  if (event.isTopLevel) {
    redirectOldUrl = event.oldUrl;
    redirectNewUrl = event.newUrl;
  }
}
function SetSrc(src) {
  var plugin = document.getElementById('plugin');
  plugin.src = src;
}
function SetSize(w, h) {
  var plugin = document.getElementById('plugin');
  plugin.width = w;
  plugin.height = h;
}
function PostMessage(data, shouldTargetIframe) {
  plugin = document.getElementById('plugin');
  // TODO(fsamuel): contentWindow can be accessed directly once
  // http://wkbug.com/85679 lands.
  if (shouldTargetIframe) {
    plugin.contentWindow.frames[0].postMessage('testing123', '*');
  } else {
    plugin.contentWindow.frames.postMessage('testing123', '*');
  }
}
function Back() {
  var plugin = document.getElementById('plugin');
  plugin.back();
}
function CanGoBack() {
  var plugin = document.getElementById('plugin');
  return plugin.canGoBack();
}
function CanGoForward() {
  var plugin = document.getElementById('plugin');
  return plugin.canGoForward();
}
function Forward() {
  var plugin = document.getElementById('plugin');
  plugin.forward();
}
function Go(relativeIndex) {
  var plugin = document.getElementById('plugin');
  plugin.go(relativeIndex);
}
function SetTitle(str) {
  document.title = str;
}
document.title = 'embedder';
</script>

<object id="plugin"
    tabindex="0"
    type="application/browser-plugin"
    width="640"
    height="480"
    border="0px"></object>
<script type="text/javascript">
var msg;
function receiveMessage(event) {
  msg = event.data;
  if (msg == 'ready') {
    document.title = 'ready';
    return;
  }
  if (msg.indexOf('stop_ack') == -1) {
    event.source.postMessage('stop', '*');
  } else {
    var name = msg.replace("stop_ack", "").trim();
    if (name !== '') {
      window.document.title = name;
    } else {
      window.document.title = 'main guest';
    }
  }
}
  var plugin = document.getElementById('plugin');
  plugin.addEventListener('loadstart', loadStart);
  plugin.addEventListener('loadabort', loadAbort);
  plugin.addEventListener('loadredirect', loadRedirect);
  window.addEventListener('message', receiveMessage, false);
  plugin.addEventListener('loadstop', loadStop);
  plugin.addEventListener('loadcommit', loadCommit);
</script>