Diff
Modified: trunk/LayoutTests/ChangeLog (125456 => 125457)
--- trunk/LayoutTests/ChangeLog 2012-08-13 22:03:38 UTC (rev 125456)
+++ trunk/LayoutTests/ChangeLog 2012-08-13 22:04:01 UTC (rev 125457)
@@ -1,3 +1,13 @@
+2012-08-13 Brady Eidson <[email protected]>
+
+ With asynchronous plug-in initialization, WebProcess and PluginProcess can deadlock
+ <rdar://problem/12062125> and https://bugs.webkit.org/show_bug.cgi?id=93894
+
+ Reviewed by Alexey Proskuryakov.
+
+ * platform/mac-wk2/plugins/asychronous-deadlock-with-timer-and-evaluate-expected.txt: Added.
+ * platform/mac-wk2/plugins/asychronous-deadlock-with-timer-and-evaluate.html: Added.
+
2012-08-13 Thiago Marcos P. Santos <[email protected]>
CanvasRenderContext2D::font() does not re-serialize the font
Added: trunk/LayoutTests/platform/mac-wk2/plugins/asychronous-deadlock-with-timer-and-evaluate-expected.txt (0 => 125457)
--- trunk/LayoutTests/platform/mac-wk2/plugins/asychronous-deadlock-with-timer-and-evaluate-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/plugins/asychronous-deadlock-with-timer-and-evaluate-expected.txt 2012-08-13 22:04:01 UTC (rev 125457)
@@ -0,0 +1,8 @@
+
+Test that a plug-in initializing asynchronous that calls out to NPP_Evaluate within NPP_New doesn't deadlock against a WebProcess that is trying to call in to the plug-in element, waiting for it to complete initialization.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Waiting on synchronous initialization of the plug-in instance did not deadlock the Web and Plugin processes.
+
Added: trunk/LayoutTests/platform/mac-wk2/plugins/asychronous-deadlock-with-timer-and-evaluate.html (0 => 125457)
--- trunk/LayoutTests/platform/mac-wk2/plugins/asychronous-deadlock-with-timer-and-evaluate.html (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/plugins/asychronous-deadlock-with-timer-and-evaluate.html 2012-08-13 22:04:01 UTC (rev 125457)
@@ -0,0 +1,36 @@
+<head>
+<script src=""
+<script>
+if (window.testRunner) {
+ testRunner.overridePreference("WebKit2AsynchronousPluginInitializationEnabled", "1");
+ testRunner.overridePreference("WebKit2AsynchronousPluginInitializationEnabledForAllPlugins", "1");
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
+function runTest()
+{
+ if (!window.testRunner) {
+ debug("This test can only run from within DumpRenderTree because it requires TestNetscapePlugin.\n");
+ return;
+ }
+
+ // This call should force synchronous initialization of the plug-in instance which should *not* result in a Web vs Plugin process deadlock.
+ var unused = document.getElementById("TestElement").madeUpProperty;
+
+ testPassed("Waiting on synchronous initialization of the plug-in instance did not deadlock the Web and Plugin processes.");
+
+ testRunner.notifyDone();
+}
+</script>
+
+</head>
+<body _onload_="setTimeout('runTest()', 0)">
+<embed id="TestElement" type="application/x-webkit-test-netscape" test="evalute-js-within-npp-new"></embed>
+<p id="description"></p>
+<div id="console"></div>
+</body>
+
+<script>
+description("Test that a plug-in initializing asynchronous that calls out to NPP_Evaluate within NPP_New doesn't deadlock against a WebProcess that is trying to call in to the plug-in element, waiting for it to complete initialization.");
+</script>
Modified: trunk/Source/WebKit2/ChangeLog (125456 => 125457)
--- trunk/Source/WebKit2/ChangeLog 2012-08-13 22:03:38 UTC (rev 125456)
+++ trunk/Source/WebKit2/ChangeLog 2012-08-13 22:04:01 UTC (rev 125457)
@@ -1,3 +1,37 @@
+2012-08-13 Brady Eidson <[email protected]>
+
+ With asynchronous plug-in initialization, WebProcess and PluginProcess can deadlock
+ <rdar://problem/12062125> and https://bugs.webkit.org/show_bug.cgi?id=93894
+
+ Reviewed by Alexey Proskuryakov.
+
+ A few things were in play here:
+ - The WebProcess thought the plug-in was done initializing but it wasn't.
+ - The sync message out from the PluginProcess was not being handled by the WebProcess.
+
+ Expose the ability for the PluginProcess to act as if it is handling a sync message and needs messages dispatched:
+ * Platform/CoreIPC/Connection.h:
+ (CoreIPC::Connection::incrementDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount):
+ (CoreIPC::Connection::decrementDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount):
+
+ * PluginProcess/PluginControllerProxy.cpp:
+ (WebKit::PluginControllerProxy::PluginControllerProxy):
+ (WebKit::PluginControllerProxy::setInitializationReply): Save the delayed reply for synchronous initialization.
+ (WebKit::PluginControllerProxy::takeInitializationReply): Give back the delayed reply for initialization completion.
+ (WebKit::PluginControllerProxy::initialize):
+ * PluginProcess/PluginControllerProxy.h:
+ (WebKit::PluginControllerProxy::isInitializing): Accessor so WebProcessConnection knows whether or not to store the
+ delayed reply for later.
+
+ * PluginProcess/WebProcessConnection.messages.in: Make the synchronous form of "CreatePlugin" have a delayed reply.
+ * PluginProcess/WebProcessConnection.cpp:
+ (WebKit::WebProcessConnection::createPlugin): Store away the delayed reply message so it can be responded to after
+ asynchronous initialization completes.
+ (WebKit::WebProcessConnection::createPluginAsynchronously): If there is a stored away delayed reply message, respond to
+ it instead of sending the asynchronously reply.
+ * PluginProcess/WebProcessConnection.h:
+ (WebProcessConnection):
+
2012-08-13 Alexey Proskuryakov <[email protected]>
[WK2] Move a remaining per-process message from WebContext to WebProcessProxy
Modified: trunk/Source/WebKit2/Platform/CoreIPC/Connection.h (125456 => 125457)
--- trunk/Source/WebKit2/Platform/CoreIPC/Connection.h 2012-08-13 22:03:38 UTC (rev 125456)
+++ trunk/Source/WebKit2/Platform/CoreIPC/Connection.h 2012-08-13 22:04:01 UTC (rev 125457)
@@ -207,6 +207,9 @@
void wakeUpRunLoop();
+ void incrementDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount() { ++m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount; }
+ void decrementDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount() { --m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount; }
+
private:
template<typename T> class Message {
public:
Modified: trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp (125456 => 125457)
--- trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp 2012-08-13 22:03:38 UTC (rev 125456)
+++ trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp 2012-08-13 22:04:01 UTC (rev 125457)
@@ -43,6 +43,7 @@
#include <WebCore/GraphicsContext.h>
#include <WebCore/IdentifierRep.h>
#include <WebCore/NotImplemented.h>
+#include <wtf/TemporaryChange.h>
#include <wtf/text/WTFString.h>
#if PLATFORM(MAC)
@@ -66,6 +67,7 @@
#if USE(ACCELERATED_COMPOSITING)
, m_isAcceleratedCompositingEnabled(creationParameters.isAcceleratedCompositingEnabled)
#endif
+ , m_isInitializing(false)
, m_paintTimer(RunLoop::main(), this, &PluginControllerProxy::paint)
, m_pluginDestructionProtectCount(0)
, m_pluginDestroyTimer(RunLoop::main(), this, &PluginControllerProxy::destroy)
@@ -91,9 +93,22 @@
releaseNPObject(m_pluginElementNPObject);
}
+void PluginControllerProxy::setInitializationReply(PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> reply)
+{
+ ASSERT(!m_initializationReply);
+ m_initializationReply = reply;
+}
+
+PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> PluginControllerProxy::takeInitializationReply()
+{
+ return m_initializationReply.release();
+}
+
bool PluginControllerProxy::initialize(const PluginCreationParameters& creationParameters)
{
ASSERT(!m_plugin);
+
+ TemporaryChange<bool> initializing(m_isInitializing, true);
m_plugin = NetscapePlugin::create(PluginProcess::shared().netscapePluginModule());
if (!m_plugin) {
Modified: trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h (125456 => 125457)
--- trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h 2012-08-13 22:03:38 UTC (rev 125456)
+++ trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h 2012-08-13 22:04:01 UTC (rev 125457)
@@ -33,6 +33,7 @@
#include "PluginController.h"
#include "PluginControllerProxyMessages.h"
#include "ShareableBitmap.h"
+#include "WebProcessConnectionMessages.h"
#include <WebCore/RunLoop.h>
#include <wtf/Noncopyable.h>
@@ -70,6 +71,11 @@
PluginController* asPluginController() { return this; }
+ bool isInitializing() const { return m_isInitializing; }
+
+ void setInitializationReply(PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply>);
+ PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> takeInitializationReply();
+
private:
PluginControllerProxy(WebProcessConnection*, const PluginCreationParameters&);
@@ -159,7 +165,10 @@
String m_userAgent;
bool m_isPrivateBrowsingEnabled;
bool m_isAcceleratedCompositingEnabled;
+ bool m_isInitializing;
+ RefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> m_initializationReply;
+
RefPtr<Plugin> m_plugin;
WebCore::IntSize m_pluginSize;
Modified: trunk/Source/WebKit2/PluginProcess/WebProcessConnection.cpp (125456 => 125457)
--- trunk/Source/WebKit2/PluginProcess/WebProcessConnection.cpp 2012-08-13 22:03:38 UTC (rev 125456)
+++ trunk/Source/WebKit2/PluginProcess/WebProcessConnection.cpp 2012-08-13 22:04:01 UTC (rev 125457)
@@ -263,17 +263,23 @@
#endif
}
-void WebProcessConnection::createPlugin(const PluginCreationParameters& creationParameters, bool& result, bool& wantsWheelEvents, uint32_t& remoteLayerClientID)
+void WebProcessConnection::createPlugin(const PluginCreationParameters& creationParameters, PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> reply)
{
PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(creationParameters.pluginInstanceID);
- // The plug-in we're being asked to create synchronously might already exist if we just finished creating it asynchronously.
- // In that case we need to not create it again (but also need to return the correct information about its creation).
+ // The controller proxy for the plug-in we're being asked to create synchronously might already exist if it was requested asynchronously before.
if (pluginControllerProxy) {
- result = true;
- wantsWheelEvents = pluginControllerProxy->wantsWheelEvents();
+ // It might still be in the middle of initialization in which case we have to let that initialization complete and respond to this message later.
+ if (pluginControllerProxy->isInitializing()) {
+ pluginControllerProxy->setInitializationReply(reply);
+ return;
+ }
+
+ // If its initialization is complete then we need to respond to this message with the correct information about its creation.
#if PLATFORM(MAC)
- remoteLayerClientID = pluginControllerProxy->remoteLayerClientID();
+ reply->send(true, pluginControllerProxy->wantsWheelEvents(), pluginControllerProxy->remoteLayerClientID());
+#else
+ reply->send(true, pluginControllerProxy->wantsWheelEvents(), 0);
#endif
return;
}
@@ -283,7 +289,12 @@
if (creationParameters.asynchronousCreationIncomplete)
m_asynchronousInstanceIDsToIgnore.add(creationParameters.pluginInstanceID);
+ bool result = false;
+ bool wantsWheelEvents = false;
+ uint32_t remoteLayerClientID = 0;
createPluginInternal(creationParameters, result, wantsWheelEvents, remoteLayerClientID);
+
+ reply->send(result, wantsWheelEvents, remoteLayerClientID);
}
void WebProcessConnection::createPluginAsynchronously(const PluginCreationParameters& creationParameters)
@@ -297,16 +308,33 @@
// This version of CreatePlugin is only used by plug-ins that are known to behave when started asynchronously.
bool result = false;
+ bool wantsWheelEvents = false;
uint32_t remoteLayerClientID = 0;
- bool wantsWheelEvents = false;
if (creationParameters.artificialPluginInitializationDelayEnabled) {
unsigned artificialPluginInitializationDelay = 5;
sleep(artificialPluginInitializationDelay);
}
+ // Since plug-in creation can often message to the WebProcess synchronously (with NPP_Evaluate for example)
+ // we need to make sure that the web process will handle the plug-in process's synchronous messages,
+ // even if the web process is waiting on a synchronous reply itself.
+ // Normally the plug-in process doesn't give its synchronous messages the special flag to allow for that.
+ // We can force it to do so by incrementing the "DispatchMessageMarkedDispatchWhenWaitingForSyncReply" count.
+ m_connection->incrementDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount();
createPluginInternal(creationParameters, result, wantsWheelEvents, remoteLayerClientID);
+ m_connection->decrementDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount();
+ // If someone asked for this plug-in synchronously while it was in the middle of being created then we need perform the
+ // synchronous reply instead of sending the asynchronous reply.
+ PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(creationParameters.pluginInstanceID);
+ ASSERT(pluginControllerProxy);
+ if (RefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> delayedSyncReply = pluginControllerProxy->takeInitializationReply()) {
+ delayedSyncReply->send(result, wantsWheelEvents, remoteLayerClientID);
+ return;
+ }
+
+ // Otherwise, send the asynchronous results now.
if (!result) {
m_connection->sendSync(Messages::PluginProxy::DidFailToCreatePlugin(), Messages::PluginProxy::DidFailToCreatePlugin::Reply(), creationParameters.pluginInstanceID);
return;
Modified: trunk/Source/WebKit2/PluginProcess/WebProcessConnection.h (125456 => 125457)
--- trunk/Source/WebKit2/PluginProcess/WebProcessConnection.h 2012-08-13 22:03:38 UTC (rev 125456)
+++ trunk/Source/WebKit2/PluginProcess/WebProcessConnection.h 2012-08-13 22:04:01 UTC (rev 125457)
@@ -30,6 +30,7 @@
#include "Connection.h"
#include "Plugin.h"
+#include "WebProcessConnectionMessages.h"
#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
@@ -70,7 +71,7 @@
// Message handlers.
void didReceiveWebProcessConnectionMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
void didReceiveSyncWebProcessConnectionMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
- void createPlugin(const PluginCreationParameters&, bool& result, bool& wantsWheelEvents, uint32_t& remoteLayerClientID);
+ void createPlugin(const PluginCreationParameters&, PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply>);
void createPluginAsynchronously(const PluginCreationParameters&);
void destroyPlugin(uint64_t pluginInstanceID, bool asynchronousCreationIncomplete);
Modified: trunk/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in (125456 => 125457)
--- trunk/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in 2012-08-13 22:03:38 UTC (rev 125456)
+++ trunk/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in 2012-08-13 22:04:01 UTC (rev 125457)
@@ -24,7 +24,7 @@
messages -> WebProcessConnection {
# Creates a plug-in instance using the given creation parameters.
- CreatePlugin(WebKit::PluginCreationParameters pluginCreationParameters) -> (bool result, bool wantsWheelEvents, uint32_t remoteLayerClientID)
+ CreatePlugin(WebKit::PluginCreationParameters pluginCreationParameters) -> (bool creationResult, bool wantsWheelEvents, uint32_t remoteLayerClientID) Delayed
# Creates a plug-in instance asynchronously using the given creation parameters.
CreatePluginAsynchronously(WebKit::PluginCreationParameters pluginCreationParameters)
Modified: trunk/Tools/ChangeLog (125456 => 125457)
--- trunk/Tools/ChangeLog 2012-08-13 22:03:38 UTC (rev 125456)
+++ trunk/Tools/ChangeLog 2012-08-13 22:04:01 UTC (rev 125457)
@@ -1,3 +1,18 @@
+2012-08-13 Brady Eidson <[email protected]>
+
+ With asynchronous plug-in initialization, WebProcess and PluginProcess can deadlock
+ <rdar://problem/12062125> and https://bugs.webkit.org/show_bug.cgi?id=93894
+
+ Reviewed by Alexey Proskuryakov.
+
+ Add a test that calls out to NPP_Evaluate for some JS inside of NPP_New.
+
+ * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+ * DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSWithinNPP_New.cpp: Added.
+ (EvaluteJSWithinNPP_New):
+ (EvaluteJSWithinNPP_New::EvaluteJSWithinNPP_New):
+ (EvaluteJSWithinNPP_New::NPP_New):
+
2012-08-13 Sheriff Bot <[email protected]>
Unreviewed, rolling out r125422.
Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (125456 => 125457)
--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj 2012-08-13 22:03:38 UTC (rev 125456)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj 2012-08-13 22:04:01 UTC (rev 125457)
@@ -71,6 +71,7 @@
515F429C15C07872007C8F90 /* PluginScriptableObjectOverridesAllProperties.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515F429B15C07872007C8F90 /* PluginScriptableObjectOverridesAllProperties.cpp */; };
5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5185F69F10714A57007AA393 /* HistoryDelegate.mm */; };
5185F6B310714E12007AA393 /* HistoryDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5185F69E10714A57007AA393 /* HistoryDelegate.h */; };
+ 51CACBD815D96FD000EB53A2 /* EvaluateJSWithinNPP_New.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51CACBD715D96FD000EB53A2 /* EvaluateJSWithinNPP_New.cpp */; };
53CBB832134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBB830134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp */; };
53CBB833134E42F3001CE6A4 /* CyclicRedundancyCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 53CBB831134E42F3001CE6A4 /* CyclicRedundancyCheck.h */; };
5DB9AC970F722C3600684641 /* AHEM____.TTF in Copy Font Files */ = {isa = PBXBuildFile; fileRef = AA7F10C20CB3C1030003BDC9 /* AHEM____.TTF */; };
@@ -283,6 +284,7 @@
515F429B15C07872007C8F90 /* PluginScriptableObjectOverridesAllProperties.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginScriptableObjectOverridesAllProperties.cpp; sourceTree = "<group>"; };
5185F69E10714A57007AA393 /* HistoryDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HistoryDelegate.h; path = mac/HistoryDelegate.h; sourceTree = "<group>"; };
5185F69F10714A57007AA393 /* HistoryDelegate.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = HistoryDelegate.mm; path = mac/HistoryDelegate.mm; sourceTree = "<group>"; };
+ 51CACBD715D96FD000EB53A2 /* EvaluateJSWithinNPP_New.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EvaluateJSWithinNPP_New.cpp; path = TestNetscapePlugIn/Tests/EvaluateJSWithinNPP_New.cpp; sourceTree = SOURCE_ROOT; };
53CBB830134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CyclicRedundancyCheck.cpp; sourceTree = "<group>"; };
53CBB831134E42F3001CE6A4 /* CyclicRedundancyCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CyclicRedundancyCheck.h; sourceTree = "<group>"; };
5DE8AE4313A2C15800D6A37D /* libWebCoreTestSupport.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libWebCoreTestSupport.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -541,6 +543,7 @@
1A31EB3613466AC100017372 /* mac */,
1A215A7511F26072008AD0F5 /* DocumentOpenInDestroyStream.cpp */,
C0E720741281C828004EF533 /* EvaluateJSAfterRemovingPluginElement.cpp */,
+ 51CACBD715D96FD000EB53A2 /* EvaluateJSWithinNPP_New.cpp */,
4AD6A11313C8124000EA9737 /* FormValue.cpp */,
1AFF66BB137DEA8300791696 /* GetURLNotifyWithURLThatFailsToLoad.cpp */,
1A5CC1F3137DD2EC00A5D7E7 /* GetURLWithJavaScriptURL.cpp */,
@@ -906,6 +909,7 @@
1A66C35114576A920099A115 /* ContentsScaleFactor.cpp in Sources */,
515F429C15C07872007C8F90 /* PluginScriptableObjectOverridesAllProperties.cpp in Sources */,
5106803E15CC7B10001A8A23 /* SlowNPPNew.cpp in Sources */,
+ 51CACBD815D96FD000EB53A2 /* EvaluateJSWithinNPP_New.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Added: trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSWithinNPP_New.cpp (0 => 125457)
--- trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSWithinNPP_New.cpp (rev 0)
+++ trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSWithinNPP_New.cpp 2012-08-13 22:04:01 UTC (rev 125457)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 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 "PluginObject.h"
+
+using namespace std;
+
+// Executing JS within NPP_New when initializing asynchronously should not be able to deadlock with the WebProcess
+
+class EvaluteJSWithinNPP_New : public PluginTest {
+public:
+ EvaluteJSWithinNPP_New(NPP, const string& identifier);
+
+private:
+ virtual NPError NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData *);
+
+};
+
+EvaluteJSWithinNPP_New::EvaluteJSWithinNPP_New(NPP npp, const string& identifier)
+ : PluginTest(npp, identifier)
+{
+}
+
+NPError EvaluteJSWithinNPP_New::NPP_New(NPMIMEType pluginType, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData *saved)
+{
+ // Give the WebProcess enough time to be deadlocked waiting for the PluginProcess.
+ usleep(15000);
+ executeScript("var theLocation = window.location;");
+ return NPERR_NO_ERROR;
+}
+
+static PluginTest::Register<EvaluteJSWithinNPP_New> registrar("evalute-js-within-npp-new");