- add sources.
[platform/framework/web/crosswalk.git] / src / content / test / data / browser_plugin_embedder.html
1 <script type="text/javascript">
2 function SetSrc(src) {
3   var plugin = document.getElementById('plugin');
4   plugin.src = src;
5 }
6 function SetSize(w, h) {
7   var plugin = document.getElementById('plugin');
8   plugin.width = w;
9   plugin.height = h;
10 }
11 function 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 }
21 function SetTitle(str) {
22   document.title = str;
23 }
24 document.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">
34 var msg;
35 function 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
53 var plugin = document.getElementById('plugin');
54 window.addEventListener('message', receiveMessage, false);
55 plugin.addEventListener('-internal-instanceid-allocated', function(e) {
56   plugin['-internal-attach']({});
57 });
58 </script>