Commit c4cc74ce authored by dmichael@chromium.org's avatar dmichael@chromium.org

Make PostMessageToJavaScript use new WebKit API instead of script.

I added some JavaScript code to test_case.html that previously would have made PostMessage not function (which I verified).

This depends on the following WebKit issue:
https://bugs.webkit.org/show_bug.cgi?id=71478

BUG=82604
TEST=N/A

Review URL: http://codereview.chromium.org/8437093

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110513 0039d316-1c4b-4281-b951-d872f2087c98
parent b9c3e559
...@@ -159,9 +159,31 @@ onload = function() { ...@@ -159,9 +159,31 @@ onload = function() {
obj.setAttribute("protocol", window.location.protocol); obj.setAttribute("protocol", window.location.protocol);
var container = document.getElementById("container"); var container = document.getElementById("container");
container.addEventListener("message", handleTestingMessage, true); container.addEventListener("message", handleTestingMessage, true);
// Register a bad dispatchEvent to make sure it isn't used. See 'EVIL' note
// below.
obj.dispatchEvent = function() {
LogHTML("<p>Bad dispatchEvent called!");
}
container.appendChild(obj); container.appendChild(obj);
} }
} }
// EVIL Note:
// This part of the script does some nefarious things to make sure that it
// doesn't affect the behavior of PostMessage (on which all the tests rely). In
// particular, we replace document.createEvent, MessageEvent.initMessageEvent,
// and the MessageEvent constructor. Previous versions of the PostMessage
// implementation made use of these and would fail (http://crbug.com/82604).
document.createEvent = function() {
LogHTML("<p>Bad document.createEvent called!");
}
function MessageEvent() {
LogHTML("<p>Bad MessageEvent constructor called!");
}
MessageEvent.prototype.initMessageEvent = function() {
LogHTML("<p>Bad MessageEvent.initMessageEvent called!");
}
</script> </script>
</head><body> </head><body>
<div> <div>
......
This diff is collapsed.
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
#include "third_party/npapi/bindings/npruntime.h" #include "third_party/npapi/bindings/npruntime.h"
struct PP_Var; struct PP_Var;
namespace WebKit {
class WebSerializedScriptValue;
}
namespace webkit { namespace webkit {
namespace ppapi { namespace ppapi {
...@@ -80,18 +83,10 @@ class MessageChannel { ...@@ -80,18 +83,10 @@ class MessageChannel {
// The NPObject we use to expose postMessage to JavaScript. // The NPObject we use to expose postMessage to JavaScript.
MessageChannelNPObject* np_object_; MessageChannelNPObject* np_object_;
// An NPVariant referring to the JavaScript function we use to send a message
// to a JavaScript target.
NPVariant onmessage_invoker_;
// Evaluates the JavaScript code for onmessage_invoker_ and makes
// it a callable NPVariant for that function. Returns true on success, false
// otherwise.
bool EvaluateOnMessageInvoker();
// Post a message to the onmessage handler for this channel's instance // Post a message to the onmessage handler for this channel's instance
// synchronously. This is used by PostMessageToJavaScript. // synchronously. This is used by PostMessageToJavaScript.
void PostMessageToJavaScriptImpl(PP_Var message_data); void PostMessageToJavaScriptImpl(
const WebKit::WebSerializedScriptValue& message_data);
// Post a message to the PPP_Instance HandleMessage function for this // Post a message to the PPP_Instance HandleMessage function for this
// channel's instance. This is used by PostMessageToNative. // channel's instance. This is used by PostMessageToNative.
void PostMessageToNativeImpl(PP_Var message_data); void PostMessageToNativeImpl(PP_Var message_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment