Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: content/test/data/browser_plugin_embedder.html

Issue 10829225: Browser Plugin: Add HTML5-like postMessage support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No need to rename addEventListener/removeEventListener Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/test/data/browser_plugin_embedder.html
diff --git a/content/test/data/browser_plugin_embedder.html b/content/test/data/browser_plugin_embedder.html
index 45b374e3ac9f9d91494114f5cfb0b6418c9a0168..ed695f74cfd566fd7d9127eac32144dca86b7557 100644
--- a/content/test/data/browser_plugin_embedder.html
+++ b/content/test/data/browser_plugin_embedder.html
@@ -23,6 +23,16 @@ function SetSize(w, h) {
plugin.width = w;
plugin.height = h;
}
+function PostMessage(data, targetiframe) {
Charlie Reis 2012/10/12 00:31:43 nit: shouldTargetIframe (Otherwise it sounds like
Fady Samuel 2012/10/12 18:07:53 Done.
+ plugin = document.getElementById('plugin');
+ // TODO(fsamuel): contentWindow can be accessed directly once
+ // http://wkbug.com/85679 lands.
+ if (targetiframe) {
+ plugin.contentWindow.frames[0].postMessage('testing123', '*');
+ } else {
+ plugin.contentWindow.frames.postMessage('testing123', '*');
+ }
+}
function Back() {
var plugin = document.getElementById('plugin');
plugin.back();
@@ -47,10 +57,28 @@ document.title = 'embedder';
width="640"
height="480"
border="0px"></object>
-
-<script>
+<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);
</script>

Powered by Google App Engine
This is Rietveld 408576698