summaryrefslogtreecommitdiffstats
path: root/content/test
diff options
context:
space:
mode:
authorfsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 19:31:56 +0000
committerfsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-17 19:31:56 +0000
commit606703e127017b433889a2343fc3c599a62a2718 (patch)
tree2a581651a356e7cf3cfa90a91d7c33ef113fc2e3 /content/test
parent19546a8096fcbba51082b76dd5f65f94add26af6 (diff)
downloadchromium_src-606703e127017b433889a2343fc3c599a62a2718.zip
chromium_src-606703e127017b433889a2343fc3c599a62a2718.tar.gz
chromium_src-606703e127017b433889a2343fc3c599a62a2718.tar.bz2
Browser Plugin: Add HTML5-like postMessage support
This is an implementation of HTML5-like postMessage support for the browser plugin. It works as follows: In BrowserPluginEmbedder:NavigateGuest, the browser process creates two swapped out RenderView: A swapped out RenderView for the guest in the embedder render process and a swapped out RenderView for the embedder in the guest render process. The guest RenderView in the embedder process can be accessed via browserPlugin.contentWindow or through the MessageEvent object received from the guest, event.source. The embedder RenderView in the guest process can be accessed through the MessageEvent object on message events, event.source. BrowserPluginEmbedderHelper, and BrowserPluginGuestHelper intercept ViewHostMsg_RouteMessageEvent messages from the swapped out RenderViews and route them appropriately. Note: BrowserPluginBindings now registers add/removeCustomEventListener instead of add/removeEventListener so that the default WebKit implementations are not shadowed by the custom implementations to allow for WebKit MessageEvents to be registered. BUG=141238 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=162353 Review URL: https://codereview.chromium.org/10829225 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162487 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/test')
-rw-r--r--content/test/data/browser_plugin_embedder.html32
-rw-r--r--content/test/data/browser_plugin_post_message_guest.html23
2 files changed, 53 insertions, 2 deletions
diff --git a/content/test/data/browser_plugin_embedder.html b/content/test/data/browser_plugin_embedder.html
index e192865..5702027 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, 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();
@@ -55,10 +65,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>
diff --git a/content/test/data/browser_plugin_post_message_guest.html b/content/test/data/browser_plugin_post_message_guest.html
new file mode 100644
index 0000000..57c1c3c
--- /dev/null
+++ b/content/test/data/browser_plugin_post_message_guest.html
@@ -0,0 +1,23 @@
+<script>
+ var embedder;
+ function receiveMessage(event) {
+ embedder = event.source;
+ if (event.data !== 'stop') {
+ event.source.postMessage('foobar', '*');
+ } else {
+ if (event.data !== '') {
+ event.source.postMessage('stop_ack ' + window.name, '*');
+ }
+ }
+ }
+ window.addEventListener('message', receiveMessage, false);
+ function CreateChildFrame(src) {
+ var ifrm = document.createElement("IFRAME");
+ ifrm.style.width = "640px";
+ ifrm.style.height = "480px";
+ ifrm.src = src;
+ ifrm.name = 'iframe';
+ document.body.appendChild(ifrm);
+ embedder.postMessage('ready', '*');
+ }
+</script>