Commit 4c8ba961 authored by andersca@apple.com's avatar andersca@apple.com

2011-05-13 Anders Carlsson <andersca@apple.com>

        Reviewed by Sam Weinig.

        NPN_GetURL with a javascript: URL doesn't send back the result in the stream
        https://bugs.webkit.org/show_bug.cgi?id=60810

        In NetscapePluginStream::sendJavaScriptStream, we were incorrectly passing the result URL
        to the stream, instead of the result. Also, store the request URL in the NetscapePluginStream object
        to avoid sending it over the wire.

        * PluginProcess/PluginControllerProxy.cpp:
        (WebKit::PluginControllerProxy::didEvaluateJavaScript):
        * PluginProcess/PluginControllerProxy.h:
        * PluginProcess/PluginControllerProxy.messages.in:
        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
        (WebKit::NetscapePlugin::loadURL):
        (WebKit::NetscapePlugin::didEvaluateJavaScript):
        (WebKit::NetscapePlugin::manualStreamDidReceiveResponse):
        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
        * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
        (WebKit::NetscapePluginStream::NetscapePluginStream):
        (WebKit::NetscapePluginStream::sendJavaScriptStream):
        * WebProcess/Plugins/Netscape/NetscapePluginStream.h:
        (WebKit::NetscapePluginStream::create):
        * WebProcess/Plugins/Plugin.h:
        * WebProcess/Plugins/PluginProxy.cpp:
        (WebKit::PluginProxy::didEvaluateJavaScript):
        * WebProcess/Plugins/PluginProxy.h:
        * WebProcess/Plugins/PluginView.cpp:
        (WebKit::PluginView::performJavaScriptURLRequest):
2011-05-13  Anders Carlsson  <andersca@apple.com>

        Reviewed by Sam Weinig.

        NPN_GetURL with a javascript: URL doesn't send back the result in the stream
        https://bugs.webkit.org/show_bug.cgi?id=60810

        Add a test that calls NPN_GetURL on a javascript: URL and checks that it gets back the expected result.

        * plugins/get-url-with-javascript-url-expected.txt: Added.
        * plugins/get-url-with-javascript-url.html: Added.
2011-05-13  Anders Carlsson  <andersca@apple.com>

        Reviewed by Sam Weinig.

        NPN_GetURL with a javascript: URL doesn't send back the result in the stream
        https://bugs.webkit.org/show_bug.cgi?id=60810

        Add a test that calls NPN_GetURL on a javascript: URL and checks that it gets back the expected result.

        * DumpRenderTree/DumpRenderTree.gypi:
        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
        * DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
        * DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro:
        * GNUmakefile.am:
        Add files.

        * DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp:
        * DumpRenderTree/TestNetscapePlugIn/PluginTest.h:
        Add new NPN and NPP wrappers and sort them according to the order they appear in npfunctions.h

        * DumpRenderTree/TestNetscapePlugIn/Tests/GetURLWithJavaScriptURL.cpp: Added.
        (GetURLWithJavaScriptURL::GetURLWithJavaScriptURL):
        (GetURLWithJavaScriptURL::NPP_New):
        (GetURLWithJavaScriptURL::NPP_NewStream):
        (GetURLWithJavaScriptURL::NPP_DestroyStream):
        (GetURLWithJavaScriptURL::NPP_WriteReady):
        (GetURLWithJavaScriptURL::NPP_Write):
        * DumpRenderTree/TestNetscapePlugIn/main.cpp:
        (NPP_NewStream):
        (NPP_WriteReady):
        (NPP_Write):
        (NPP_URLNotify):
        call the PluginTest NPP wrappers.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86467 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1bee0824
2011-05-13 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
NPN_GetURL with a javascript: URL doesn't send back the result in the stream
https://bugs.webkit.org/show_bug.cgi?id=60810
Add a test that calls NPN_GetURL on a javascript: URL and checks that it gets back the expected result.
* plugins/get-url-with-javascript-url-expected.txt: Added.
* plugins/get-url-with-javascript-url.html: Added.
2011-05-13 Mark Pilgrim <pilgrim@chromium.org>
Reviewed by Tony Chang.
Test that evaluating a javascript: URL will send a stream with the result of the evaluation.
SUCCESS
<script>
function testSucceeded() {
document.getElementById('console').innerText = 'SUCCESS';
if (window.layoutTestController)
layoutTestController.notifyDone();
}
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
</script>
<body>
<embed id="plugin" type="application/x-webkit-test-netscape" test="get-url-with-javascript-url" width=100 height=100></embed>
<p id="description">Test that evaluating a javascript: URL will send a stream with the result of the evaluation.</p>
<div id="console">FAILURE</div>
2011-05-13 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
NPN_GetURL with a javascript: URL doesn't send back the result in the stream
https://bugs.webkit.org/show_bug.cgi?id=60810
In NetscapePluginStream::sendJavaScriptStream, we were incorrectly passing the result URL
to the stream, instead of the result. Also, store the request URL in the NetscapePluginStream object
to avoid sending it over the wire.
* PluginProcess/PluginControllerProxy.cpp:
(WebKit::PluginControllerProxy::didEvaluateJavaScript):
* PluginProcess/PluginControllerProxy.h:
* PluginProcess/PluginControllerProxy.messages.in:
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::loadURL):
(WebKit::NetscapePlugin::didEvaluateJavaScript):
(WebKit::NetscapePlugin::manualStreamDidReceiveResponse):
* WebProcess/Plugins/Netscape/NetscapePlugin.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::sendJavaScriptStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
(WebKit::NetscapePluginStream::create):
* WebProcess/Plugins/Plugin.h:
* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::didEvaluateJavaScript):
* WebProcess/Plugins/PluginProxy.h:
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::performJavaScriptURLRequest):
2011-05-13 Jeff Miller <jeffm@apple.com>
Reviewed by Darin Adler.
......
......@@ -402,9 +402,9 @@ void PluginControllerProxy::geometryDidChange(const IntRect& frameRect, const In
m_plugin->geometryDidChange(frameRect, clipRect);
}
void PluginControllerProxy::didEvaluateJavaScript(uint64_t requestID, const String& requestURLString, const String& result)
void PluginControllerProxy::didEvaluateJavaScript(uint64_t requestID, const String& result)
{
m_plugin->didEvaluateJavaScript(requestID, requestURLString, result);
m_plugin->didEvaluateJavaScript(requestID, result);
}
void PluginControllerProxy::streamDidReceiveResponse(uint64_t streamID, const String& responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers)
......
......@@ -110,7 +110,7 @@ private:
void frameDidFinishLoading(uint64_t requestID);
void frameDidFail(uint64_t requestID, bool wasCancelled);
void geometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, const ShareableBitmap::Handle& backingStoreHandle);
void didEvaluateJavaScript(uint64_t requestID, const String& requestURLString, const String& result);
void didEvaluateJavaScript(uint64_t requestID, const String& result);
void streamDidReceiveResponse(uint64_t streamID, const String& responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers);
void streamDidReceiveData(uint64_t streamID, const CoreIPC::DataReference& data);
void streamDidFinishLoading(uint64_t streamID);
......
......@@ -33,7 +33,7 @@ messages -> PluginControllerProxy {
FrameDidFail(uint64_t requestID, bool wasCancelled)
# Sent when JavaScript that the plug-in asked to be evaluated has been evaluated.
DidEvaluateJavaScript(uint64_t requestID, WTF::String requestURLString, WTF::String result)
DidEvaluateJavaScript(uint64_t requestID, WTF::String result)
# Sent when the plug-in receives a response for a stream.
StreamDidReceiveResponse(uint64_t streamID, WTF::String responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, WTF::String mimeType, WTF::String headers)
......
......@@ -168,7 +168,7 @@ void NetscapePlugin::loadURL(const String& method, const String& urlString, cons
if (target.isNull()) {
// The browser is going to send the data in a stream, create a plug-in stream.
RefPtr<NetscapePluginStream> pluginStream = NetscapePluginStream::create(this, requestID, sendNotification, notificationData);
RefPtr<NetscapePluginStream> pluginStream = NetscapePluginStream::create(this, requestID, urlString, sendNotification, notificationData);
ASSERT(!m_streams.contains(requestID));
m_streams.set(requestID, pluginStream.release());
......@@ -611,12 +611,12 @@ void NetscapePlugin::frameDidFail(uint64_t requestID, bool wasCancelled)
NPP_URLNotify(url.utf8().data(), wasCancelled ? NPRES_USER_BREAK : NPRES_NETWORK_ERR, notificationData);
}
void NetscapePlugin::didEvaluateJavaScript(uint64_t requestID, const String& requestURLString, const String& result)
void NetscapePlugin::didEvaluateJavaScript(uint64_t requestID, const String& result)
{
ASSERT(m_isStarted);
if (NetscapePluginStream* pluginStream = streamFromID(requestID))
pluginStream->sendJavaScriptStream(requestURLString, result);
pluginStream->sendJavaScriptStream(result);
}
void NetscapePlugin::streamDidReceiveResponse(uint64_t streamID, const KURL& responseURL, uint32_t streamLength,
......@@ -659,7 +659,7 @@ void NetscapePlugin::manualStreamDidReceiveResponse(const KURL& responseURL, uin
ASSERT(m_loadManually);
ASSERT(!m_manualStream);
m_manualStream = NetscapePluginStream::create(this, 0, false, 0);
m_manualStream = NetscapePluginStream::create(this, 0, responseURL.string(), false, 0);
m_manualStream->didReceiveResponse(responseURL, streamLength, lastModifiedTime, mimeType, headers);
}
......
......@@ -154,7 +154,7 @@ private:
virtual void visibilityDidChange();
virtual void frameDidFinishLoading(uint64_t requestID);
virtual void frameDidFail(uint64_t requestID, bool wasCancelled);
virtual void didEvaluateJavaScript(uint64_t requestID, const String& requestURLString, const String& result);
virtual void didEvaluateJavaScript(uint64_t requestID, const String& result);
virtual void streamDidReceiveResponse(uint64_t streamID, const WebCore::KURL& responseURL, uint32_t streamLength,
uint32_t lastModifiedTime, const String& mimeType, const String& headers);
virtual void streamDidReceiveData(uint64_t streamID, const char* bytes, int length);
......
......@@ -34,9 +34,10 @@ using namespace std;
namespace WebKit {
NetscapePluginStream::NetscapePluginStream(PassRefPtr<NetscapePlugin> plugin, uint64_t streamID, bool sendNotification, void* notificationData)
NetscapePluginStream::NetscapePluginStream(PassRefPtr<NetscapePlugin> plugin, uint64_t streamID, const String& requestURLString, bool sendNotification, void* notificationData)
: m_plugin(plugin)
, m_streamID(streamID)
, m_requestURLString(requestURLString)
, m_sendNotification(sendNotification)
, m_notificationData(notificationData)
, m_npStream()
......@@ -91,20 +92,20 @@ void NetscapePluginStream::didFail(bool wasCancelled)
stop(wasCancelled ? NPRES_USER_BREAK : NPRES_NETWORK_ERR);
}
void NetscapePluginStream::sendJavaScriptStream(const String& requestURLString, const String& result)
void NetscapePluginStream::sendJavaScriptStream(const String& result)
{
// starting the stream or delivering the data to it might cause the plug-in stream to go away, so we keep
// a reference to it here.
RefPtr<NetscapePluginStream> protect(this);
CString resultCString = requestURLString.utf8();
CString resultCString = result.utf8();
if (resultCString.isNull()) {
// There was an error evaluating the JavaScript, call NPP_URLNotify if needed and then destroy the stream.
notifyAndDestroyStream(NPRES_NETWORK_ERR);
return;
}
if (!start(requestURLString, resultCString.length(), 0, "text/plain", ""))
if (!start(m_requestURLString, resultCString.length(), 0, "text/plain", ""))
return;
deliverData(resultCString.data(), resultCString.length());
......
......@@ -45,9 +45,9 @@ class NetscapePlugin;
class NetscapePluginStream : public RefCounted<NetscapePluginStream> {
public:
static PassRefPtr<NetscapePluginStream> create(PassRefPtr<NetscapePlugin> plugin, uint64_t streamID, bool sendNotification, void* notificationData)
static PassRefPtr<NetscapePluginStream> create(PassRefPtr<NetscapePlugin> plugin, uint64_t streamID, const String& requestURLString, bool sendNotification, void* notificationData)
{
return adoptRef(new NetscapePluginStream(plugin, streamID, sendNotification, notificationData));
return adoptRef(new NetscapePluginStream(plugin, streamID, requestURLString, sendNotification, notificationData));
}
~NetscapePluginStream();
......@@ -60,13 +60,13 @@ public:
void didFinishLoading();
void didFail(bool wasCancelled);
void sendJavaScriptStream(const String& requestURLString, const String& result);
void sendJavaScriptStream(const String& result);
void stop(NPReason);
NPError destroy(NPReason);
private:
NetscapePluginStream(PassRefPtr<NetscapePlugin>, uint64_t streamID, bool sendNotification, void* notificationData);
NetscapePluginStream(PassRefPtr<NetscapePlugin>, uint64_t streamID, const String& requestURLString, bool sendNotification, void* notificationData);
bool start(const String& responseURLString, uint32_t streamLength,
uint32_t lastModifiedTime, const String& mimeType, const String& headers);
......@@ -80,7 +80,8 @@ private:
RefPtr<NetscapePlugin> m_plugin;
uint64_t m_streamID;
String m_requestURLString;
bool m_sendNotification;
void* m_notificationData;
......
......@@ -102,7 +102,7 @@ public:
// Tells the plug-in that a request to evaluate JavaScript (using PluginController::loadURL) has been fulfilled and passes
// back the result. If evaluating the script failed, result will be null.
virtual void didEvaluateJavaScript(uint64_t requestID, const String& requestURLString, const String& result) = 0;
virtual void didEvaluateJavaScript(uint64_t requestID, const String& result) = 0;
// Tells the plug-in that a stream has received its HTTP response.
virtual void streamDidReceiveResponse(uint64_t streamID, const WebCore::KURL& responseURL, uint32_t streamLength,
......
......@@ -233,9 +233,9 @@ void PluginProxy::frameDidFail(uint64_t requestID, bool wasCancelled)
m_connection->connection()->send(Messages::PluginControllerProxy::FrameDidFail(requestID, wasCancelled), m_pluginInstanceID);
}
void PluginProxy::didEvaluateJavaScript(uint64_t requestID, const WTF::String& requestURLString, const WTF::String& result)
void PluginProxy::didEvaluateJavaScript(uint64_t requestID, const WTF::String& result)
{
m_connection->connection()->send(Messages::PluginControllerProxy::DidEvaluateJavaScript(requestID, requestURLString, result), m_pluginInstanceID);
m_connection->connection()->send(Messages::PluginControllerProxy::DidEvaluateJavaScript(requestID, result), m_pluginInstanceID);
}
void PluginProxy::streamDidReceiveResponse(uint64_t streamID, const KURL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const WTF::String& mimeType, const WTF::String& headers)
......
......@@ -75,7 +75,7 @@ private:
virtual void visibilityDidChange();
virtual void frameDidFinishLoading(uint64_t requestID);
virtual void frameDidFail(uint64_t requestID, bool wasCancelled);
virtual void didEvaluateJavaScript(uint64_t requestID, const WTF::String& requestURLString, const WTF::String& result);
virtual void didEvaluateJavaScript(uint64_t requestID, const String& result);
virtual void streamDidReceiveResponse(uint64_t streamID, const WebCore::KURL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const WTF::String& mimeType, const WTF::String& headers);
virtual void streamDidReceiveData(uint64_t streamID, const char* bytes, int length);
virtual void streamDidFinishLoading(uint64_t streamID);
......
......@@ -793,7 +793,7 @@ void PluginView::performJavaScriptURLRequest(URLRequest* request)
result.getString(scriptState, resultString);
// Send the result back to the plug-in.
plugin->didEvaluateJavaScript(request->requestID(), decodeURLEscapeSequences(request->request().url()), resultString);
plugin->didEvaluateJavaScript(request->requestID(), resultString);
}
void PluginView::addStream(Stream* stream)
......
2011-05-13 Anders Carlsson <andersca@apple.com>
Reviewed by Sam Weinig.
NPN_GetURL with a javascript: URL doesn't send back the result in the stream
https://bugs.webkit.org/show_bug.cgi?id=60810
Add a test that calls NPN_GetURL on a javascript: URL and checks that it gets back the expected result.
* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
* DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro:
* GNUmakefile.am:
Add files.
* DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp:
* DumpRenderTree/TestNetscapePlugIn/PluginTest.h:
Add new NPN and NPP wrappers and sort them according to the order they appear in npfunctions.h
* DumpRenderTree/TestNetscapePlugIn/Tests/GetURLWithJavaScriptURL.cpp: Added.
(GetURLWithJavaScriptURL::GetURLWithJavaScriptURL):
(GetURLWithJavaScriptURL::NPP_New):
(GetURLWithJavaScriptURL::NPP_NewStream):
(GetURLWithJavaScriptURL::NPP_DestroyStream):
(GetURLWithJavaScriptURL::NPP_WriteReady):
(GetURLWithJavaScriptURL::NPP_Write):
* DumpRenderTree/TestNetscapePlugIn/main.cpp:
(NPP_NewStream):
(NPP_WriteReady):
(NPP_Write):
(NPP_URLNotify):
call the PluginTest NPP wrappers.
2011-05-13 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r86447.
......
......@@ -52,6 +52,7 @@
'TestNetscapePlugIn/TestObject.h',
'TestNetscapePlugIn/Tests/DocumentOpenInDestroyStream.cpp',
'TestNetscapePlugIn/Tests/EvaluateJSAfterRemovingPluginElement.cpp',
'TestNetscapePlugIn/Tests/GetURLWithJavaScriptURL.cpp',
'TestNetscapePlugIn/Tests/GetURLWithJavaScriptURLDestroyingPlugin.cpp',
'TestNetscapePlugIn/Tests/GetUserAgentWithNullNPPFromNPPNew.cpp',
'TestNetscapePlugIn/Tests/NPRuntimeObjectFromDestroyedPlugin.cpp',
......
......@@ -38,6 +38,7 @@
1A24BAA9120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */; };
1A31EB3813466AC100017372 /* ConvertPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A31EB3713466AC100017372 /* ConvertPoint.cpp */; };
1A3E28AA1311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */; };
1A5CC1F5137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */; };
1A8F02E80BB9B4EC008CFA34 /* TestObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A8F024C0BB9B056008CFA34 /* TestObject.h */; };
1AC6C8490D07638600CD3161 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C77F0D07589B00CD3161 /* main.cpp */; };
1AC6C84A0D07638600CD3161 /* PluginObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC6C7800D07589B00CD3161 /* PluginObject.cpp */; };
......@@ -215,6 +216,7 @@
1A24BAA8120734EE00FBB059 /* NPRuntimeObjectFromDestroyedPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeObjectFromDestroyedPlugin.cpp; sourceTree = "<group>"; };
1A31EB3713466AC100017372 /* ConvertPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConvertPoint.cpp; sourceTree = "<group>"; };
1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURLDestroyingPlugin.cpp; sourceTree = "<group>"; };
1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetURLWithJavaScriptURL.cpp; sourceTree = "<group>"; };
1A8F024C0BB9B056008CFA34 /* TestObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObject.h; sourceTree = "<group>"; };
1AC6C77F0D07589B00CD3161 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
1AC6C7800D07589B00CD3161 /* PluginObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginObject.cpp; sourceTree = "<group>"; };
......@@ -487,6 +489,7 @@
1A31EB3613466AC100017372 /* mac */,
1A215A7511F26072008AD0F5 /* DocumentOpenInDestroyStream.cpp */,
C0E720741281C828004EF533 /* EvaluateJSAfterRemovingPluginElement.cpp */,
1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */,
1A3E28A91311D73B00501349 /* GetURLWithJavaScriptURLDestroyingPlugin.cpp */,
1AD4CB2012A6D1350027A7AF /* GetUserAgentWithNullNPPFromNPPNew.cpp */,
1ACF898B132EF41C00E915D4 /* NPDeallocateCalledBeforeNPShutdown.cpp */,
......@@ -799,6 +802,7 @@
1ACF898D132EF41C00E915D4 /* NPDeallocateCalledBeforeNPShutdown.cpp in Sources */,
1A31EB3813466AC100017372 /* ConvertPoint.cpp in Sources */,
C031182B134E4A2B00919757 /* NPPSetWindowCalledDuringDestruction.cpp in Sources */,
1A5CC1F5137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -92,37 +92,73 @@ NPError PluginTest::NPP_Destroy(NPSavedData**)
return NPERR_NO_ERROR;
}
NPError PluginTest::NPP_DestroyStream(NPStream *stream, NPReason reason)
NPError PluginTest::NPP_SetWindow(NPP, NPWindow*)
{
return NPERR_NO_ERROR;
}
NPError PluginTest::NPP_GetValue(NPPVariable variable, void *value)
NPError PluginTest::NPP_NewStream(NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
{
// We don't know anything about plug-in values so just return NPERR_GENERIC_ERROR.
return NPERR_GENERIC_ERROR;
return NPERR_NO_ERROR;
}
NPError PluginTest::NPP_SetWindow(NPP, NPWindow*)
NPError PluginTest::NPP_DestroyStream(NPStream *stream, NPReason reason)
{
return NPERR_NO_ERROR;
}
int32_t PluginTest::NPP_WriteReady(NPStream*)
{
return 4096;
}
int32_t PluginTest::NPP_Write(NPStream*, int32_t offset, int32_t len, void* buffer)
{
return len;
}
int16_t PluginTest::NPP_HandleEvent(void*)
{
return 0;
}
void PluginTest::NPN_InvalidateRect(NPRect* invalidRect)
bool PluginTest::NPP_URLNotify(const char* url, NPReason, void* notifyData)
{
browser->invalidaterect(m_npp, invalidRect);
// FIXME: Port the code from NPP_URLNotify in main.cpp over to always using
// PluginTest, so we don't have to use a return value to indicate whether the "default" NPP_URLNotify implementation should be invoked.
return false;
}
NPError PluginTest::NPP_GetValue(NPPVariable variable, void *value)
{
// We don't know anything about plug-in values so just return NPERR_GENERIC_ERROR.
return NPERR_GENERIC_ERROR;
}
// NPN functions.
NPError PluginTest::NPN_GetURL(const char* url, const char* target)
{
return browser->geturl(m_npp, url, target);
}
NPError PluginTest::NPN_GetURLNotify(const char *url, const char *target, void *notifyData)
{
return browser->geturlnotify(m_npp, url, target, notifyData);
}
NPError PluginTest::NPN_GetValue(NPNVariable variable, void* value)
{
return browser->getvalue(m_npp, variable, value);
}
void PluginTest::NPN_InvalidateRect(NPRect* invalidRect)
{
browser->invalidaterect(m_npp, invalidRect);
}
// NPRuntime NPN functions.
NPIdentifier PluginTest::NPN_GetStringIdentifier(const NPUTF8 *name)
{
return browser->getstringidentifier(name);
......@@ -133,11 +169,6 @@ NPIdentifier PluginTest::NPN_GetIntIdentifier(int32_t intid)
return browser->getintidentifier(intid);
}
NPError PluginTest::NPN_GetValue(NPNVariable variable, void* value)
{
return browser->getvalue(m_npp, variable, value);
}
NPObject* PluginTest::NPN_CreateObject(NPClass* npClass)
{
return browser->createobject(m_npp, npClass);
......
......@@ -59,20 +59,28 @@ public:
// NPP functions.
virtual NPError NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved);
virtual NPError NPP_Destroy(NPSavedData**);
virtual NPError NPP_DestroyStream(NPStream* stream, NPReason reason);
virtual NPError NPP_GetValue(NPPVariable, void* value);
virtual NPError NPP_SetWindow(NPP, NPWindow*);
virtual NPError NPP_NewStream(NPMIMEType, NPStream*, NPBool seekable, uint16_t* stype);
virtual NPError NPP_DestroyStream(NPStream*, NPReason);
virtual int32_t NPP_WriteReady(NPStream*);
virtual int32_t NPP_Write(NPStream*, int32_t offset, int32_t len, void* buffer);
virtual int16_t NPP_HandleEvent(void* event);
virtual bool NPP_URLNotify(const char* url, NPReason, void* notifyData);
virtual NPError NPP_GetValue(NPPVariable, void* value);
// NPN functions.
NPError NPN_GetURL(const char* url, const char* target);
NPError NPN_GetURLNotify(const char* url, const char* target, void* notifyData);
NPError NPN_GetValue(NPNVariable, void* value);
void NPN_InvalidateRect(NPRect* invalidRect);
// NPRuntime NPN functions.
NPIdentifier NPN_GetStringIdentifier(const NPUTF8* name);
NPIdentifier NPN_GetIntIdentifier(int32_t intid);
NPError NPN_GetValue(NPNVariable, void* value);
NPObject* NPN_CreateObject(NPClass*);
bool NPN_RemoveProperty(NPObject*, NPIdentifier propertyName);
#ifdef XP_MACOSX
bool NPN_ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace);
#endif
......
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "PluginTest.h"
#include <vector>
using namespace std;
const char *javaScriptURL = "javascript:'Hello, ' + 'World!'";
const char *javaScriptResult = "Hello, World!";
// Test that evaluating a javascript: URL will send a stream with the result of the evaluation.
// Test that evaluating JavaScript using NPN_GetURL will a stream with result of the evaluation.
class GetURLWithJavaScriptURL : public PluginTest {
public:
GetURLWithJavaScriptURL(NPP npp, const string& identifier)
: PluginTest(npp, identifier)
, m_didFail(false)
{
}
private:
virtual NPError NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc, char *argn[], char *argv[], NPSavedData *saved)
{
NPN_GetURL(javaScriptURL, 0);
return NPERR_NO_ERROR;
}
NPError NPP_NewStream(NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
{
stream->pdata = this;
if (strcmp(stream->url, javaScriptURL))
m_didFail = true;
if (stream->end != strlen(javaScriptResult))
m_didFail = true;
*stype = NP_NORMAL;
return NPERR_NO_ERROR;
}
NPError NPP_DestroyStream(NPStream* stream, NPReason reason)
{
if (stream->pdata != this)
m_didFail = true;
if (reason != NPRES_DONE)
m_didFail = true;
if (m_data.size() != stream->end)
m_didFail = true;
m_data.push_back('\0');
if (strcmp(&m_data[0], javaScriptResult))
m_didFail = true;
if (!m_didFail)
executeScript("testSucceeded()");
else
executeScript("notifyDone()");
return NPERR_NO_ERROR;
}
int32_t NPP_WriteReady(NPStream* stream)
{
if (stream->pdata != this)
m_didFail = true;
return 2;
}
int32_t NPP_Write(NPStream* stream, int32_t offset, int32_t len, void* buffer)
{
if (stream->pdata != this)
m_didFail = true;
m_data.insert(m_data.end(), static_cast<char*>(buffer), static_cast<char*>(buffer) + len);
return len;
}
vector<char> m_data;
bool m_didFail;
};
static PluginTest::Register<GetURLWithJavaScriptURL> getURLWithJavaScriptURLDestroyingPlugin("get-url-with-javascript-url");
......@@ -396,7 +396,7 @@ NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool se
if (obj->onStreamLoad)
executeScript(obj, obj->onStreamLoad);
return NPERR_NO_ERROR;
return obj->pluginTest->NPP_NewStream(type, stream, seekable, stype);
}
NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
......@@ -431,7 +431,8 @@ NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)