Pass NPP_SetWindow a null window handle during plugin destruction on non-Mac platforms
authoraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2011 16:00:38 +0000 (16:00 +0000)
committeraroben@apple.com <aroben@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Apr 2011 16:00:38 +0000 (16:00 +0000)
commit1b14478b8103f7adabdf8cc39c452a0f05a4580c
tree425ac2e2912986acd52652f27643d5159f619ff6
parent3bff1f37f9569b4e74dfbdff13b3f5b4d35c9591
Pass NPP_SetWindow a null window handle during plugin destruction on non-Mac platforms

This matches WebKit1.

Fixes <http://webkit.org/b/47009> WebKit2 needs to call NPP_SetWindow when destroying a
plugin

Reviewed by Anders Carlsson.

Source/WebKit2:

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::destroy): Null out our NPWindow's window handle and pass it to
NPP_SetWindow (unless we're on Mac).

Tools:

Test that NPP_SetWindow is passed a null window handle during plugin destruction on non-Mac platforms

* DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp:
(pluginLogWithArguments): Moved code to format and log the message here...
(pluginLog): ...from here.

* DumpRenderTree/TestNetscapePlugIn/PluginObject.h: Added pluginLogWithArguments.

* DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp:
(PluginTest::log): Added. Calls through to pluginLogWithArguments.

* DumpRenderTree/TestNetscapePlugIn/PluginTest.h: Added log.

* DumpRenderTree/TestNetscapePlugIn/Tests/NPPSetWindowCalledDuringDestruction.cpp: Added.
(NPPSetWindowCalledDuringDestruction::setWillBeDestroyed): Records that destruction is about
to begin.
(NPPSetWindowCalledDuringDestruction::NPPSetWindowCalledDuringDestruction): Simple
constructor.
(NPPSetWindowCalledDuringDestruction::NPP_GetValue): Creates and returns a ScriptObject that
can be used to invoke our setWillBeDestroyed function.
(NPPSetWindowCalledDuringDestruction::NPP_SetWindow): Records what has happened (and logs if
anything unexpected happens).
(NPPSetWindowCalledDuringDestruction::NPP_Destroy): On Mac, logs a failure message if
NPP_SetWindow was called during destruction. On other platforms, logs a failure message if
NPP_SetWindow was *not* called during destruction.
(NPPSetWindowCalledDuringDestruction::ScriptObject::hasMethod): Return true for our only
method, setWillBeDestroyed.
(NPPSetWindowCalledDuringDestruction::ScriptObject::invoke): Call through to the PluginTest
object.

* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj:
* DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro:
* GNUmakefile.am:
Added new test.

* Scripts/old-run-webkit-tests: Skip the new test when using out-of-process plugins with
WebKit1 on Mac, since it can't work properly due to <http://webkit.org/b/58077>.

LayoutTests:

Test that NPP_SetWindow is passed a null window handle during plugin destruction on non-Mac platforms

* platform/win-wk2/Skipped: Removed a test that no longer crashes thanks to this fix.

* plugins/npp-set-window-called-during-destruction-expected.txt: Added.
* plugins/npp-set-window-called-during-destruction.html: Added.

* platform/mac/plugins/npp-set-window-called-during-destruction-expected.txt: Added. This is
different from the cross-platform results because we don't expect NPP_SetWindow to be called
during destruction.

* platform/win/plugins/npp-set-window-called-during-destruction-expected.txt: Added. This is
a copy of the cross-platform results, needed to override the Mac-specific results.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83300 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/plugins/npp-set-window-called-during-destruction-expected.txt [new file with mode: 0644]
LayoutTests/platform/win-wk2/Skipped
LayoutTests/platform/win/plugins/npp-set-window-called-during-destruction-expected.txt [new file with mode: 0644]
LayoutTests/plugins/npp-set-window-called-during-destruction-expected.txt [new file with mode: 0644]
LayoutTests/plugins/npp-set-window-called-during-destruction.html [new file with mode: 0644]
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
Tools/ChangeLog
Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp
Tools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h
Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.cpp
Tools/DumpRenderTree/TestNetscapePlugIn/PluginTest.h
Tools/DumpRenderTree/TestNetscapePlugIn/Tests/NPPSetWindowCalledDuringDestruction.cpp [new file with mode: 0644]
Tools/DumpRenderTree/TestNetscapePlugIn/win/TestNetscapePlugin.vcproj
Tools/DumpRenderTree/qt/TestNetscapePlugin/TestNetscapePlugin.pro
Tools/GNUmakefile.am
Tools/Scripts/old-run-webkit-tests