add a use_alsa gyp setting
[chromium-blink-merge.git] / content / test / data / browser_plugin_embedder.html
blob9501d19df3e7586f5d13c6558bc771110a87739e
1 <script type="text/javascript">
2 function sizeChanged(evt) {
3 var data = JSON.parse(evt.detail);
4 document.title = "AutoSize(" + data.newWidth + ", " + data.newHeight + ")";
7 function loadAbort(evt) {
8 document.title = JSON.parse(evt.detail).reason;
10 function loadStart(evt) {
11 document.title = JSON.parse(evt.detail).url;
13 function loadStop(evt) {
14 document.title = "loadStop";
17 var commitIsTopLevel;
18 function loadCommit(evt) {
19 var detail = JSON.parse(evt.detail);
20 document.title = "loadCommit:" + detail.url;
21 commitIsTopLevel = detail.isTopLevel;
24 var redirectOldUrl;
25 var redirectNewUrl;
26 function loadRedirect(event) {
27 document.title = "redirected";
28 var detail = JSON.parse(event.detail);
29 if (detail.isTopLevel) {
30 redirectOldUrl = detail.oldUrl;
31 redirectNewUrl = detail.newUrl;
34 function SetSrc(src) {
35 var plugin = document.getElementById('plugin');
36 plugin.src = src;
38 function SetSize(w, h) {
39 var plugin = document.getElementById('plugin');
40 plugin.width = w;
41 plugin.height = h;
43 function PostMessage(data, shouldTargetIframe) {
44 plugin = document.getElementById('plugin');
45 // TODO(fsamuel): contentWindow can be accessed directly once
46 // http://wkbug.com/85679 lands.
47 if (shouldTargetIframe) {
48 plugin.contentWindow.frames[0].postMessage('testing123', '*');
49 } else {
50 plugin.contentWindow.frames.postMessage('testing123', '*');
53 function Back() {
54 var plugin = document.getElementById('plugin');
55 plugin.back();
57 function CanGoBack() {
58 var plugin = document.getElementById('plugin');
59 return plugin.canGoBack();
61 function CanGoForward() {
62 var plugin = document.getElementById('plugin');
63 return plugin.canGoForward();
65 function Forward() {
66 var plugin = document.getElementById('plugin');
67 plugin.forward();
69 function Go(relativeIndex) {
70 var plugin = document.getElementById('plugin');
71 plugin.go(relativeIndex);
73 function SetTitle(str) {
74 document.title = str;
76 document.title = 'embedder';
77 </script>
79 <object id="plugin"
80 tabindex="0"
81 type="application/browser-plugin"
82 width="640"
83 height="480"
84 border="0px"></object>
85 <script type="text/javascript">
86 var msg;
87 function receiveMessage(event) {
88 msg = event.data;
89 if (msg == 'ready') {
90 document.title = 'ready';
91 return;
93 if (msg.indexOf('stop_ack') == -1) {
94 event.source.postMessage('stop', '*');
95 } else {
96 var name = msg.replace("stop_ack", "").trim();
97 if (name !== '') {
98 window.document.title = name;
99 } else {
100 window.document.title = 'main guest';
104 var plugin = document.getElementById('plugin');
105 plugin.addEventListener('-internal-loadstart', loadStart);
106 plugin.addEventListener('-internal-loadabort', loadAbort);
107 plugin.addEventListener('-internal-loadredirect', loadRedirect);
108 window.addEventListener('message', receiveMessage, false);
109 plugin.addEventListener('-internal-loadstop', loadStop);
110 plugin.addEventListener('-internal-loadcommit', loadCommit);
111 plugin.addEventListener('-internal-sizechanged', sizeChanged);
112 </script>