summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests')
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSAfterRemovingPluginElement.cpp64
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp118
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp49
-rw-r--r--WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp114
4 files changed, 313 insertions, 32 deletions
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSAfterRemovingPluginElement.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSAfterRemovingPluginElement.cpp
new file mode 100644
index 0000000..4b5d3e0
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/EvaluateJSAfterRemovingPluginElement.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 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 after removing the plugin element from the document should not crash.
+
+class EvaluateJSAfterRemovingPluginElement : public PluginTest {
+public:
+ EvaluateJSAfterRemovingPluginElement(NPP, const string& identifier);
+
+private:
+ virtual NPError NPP_DestroyStream(NPStream*, NPReason);
+
+ bool m_didExecuteScript;
+};
+
+static PluginTest::Register<EvaluateJSAfterRemovingPluginElement> registrar("evaluate-js-after-removing-plugin-element");
+
+EvaluateJSAfterRemovingPluginElement::EvaluateJSAfterRemovingPluginElement(NPP npp, const string& identifier)
+ : PluginTest(npp, identifier)
+ , m_didExecuteScript(false)
+{
+ waitUntilDone();
+}
+
+NPError EvaluateJSAfterRemovingPluginElement::NPP_DestroyStream(NPStream*, NPReason)
+{
+ if (m_didExecuteScript)
+ return NPERR_NO_ERROR;
+ m_didExecuteScript = true;
+
+ executeScript("var plugin = document.getElementsByTagName('embed')[0]; plugin.parentElement.removeChild(plugin);");
+ executeScript("document.body.appendChild(document.createTextNode('Executing script after removing the plugin element from the document succeeded.'));");
+ notifyDone();
+
+ return NPERR_NO_ERROR;
+}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp
new file mode 100644
index 0000000..2b06198
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/DrawsGradient.cpp
@@ -0,0 +1,118 @@
+/* Copyright (C) 2010 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 "WindowedPluginTest.h"
+
+#include "PluginObject.h"
+
+using namespace std;
+
+// Just fills its window with some gradients
+
+class DrawsGradient : public WindowedPluginTest {
+public:
+ DrawsGradient(NPP, const string& identifier);
+
+private:
+ void paint(HDC) const;
+
+ LRESULT onPaint(WPARAM, LPARAM, bool& handled);
+ LRESULT onPrintClient(WPARAM, LPARAM, bool& handled);
+
+ virtual LRESULT wndProc(UINT message, WPARAM, LPARAM, bool& handled);
+};
+
+static PluginTest::Register<DrawsGradient> registrar("draws-gradient");
+
+DrawsGradient::DrawsGradient(NPP npp, const string& identifier)
+ : WindowedPluginTest(npp, identifier)
+{
+}
+
+LRESULT DrawsGradient::wndProc(UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ LRESULT result = 0;
+
+ switch (message) {
+ case WM_PAINT:
+ result = onPaint(wParam, lParam, handled);
+ break;
+ case WM_PRINTCLIENT:
+ result = onPrintClient(wParam, lParam, handled);
+ break;
+ default:
+ handled = false;
+ }
+
+ return result;
+}
+
+LRESULT DrawsGradient::onPaint(WPARAM, LPARAM, bool& handled)
+{
+ PAINTSTRUCT paintStruct;
+ HDC dc = ::BeginPaint(window(), &paintStruct);
+ if (!dc)
+ return 0;
+
+ paint(dc);
+ ::EndPaint(window(), &paintStruct);
+
+ handled = true;
+ return 0;
+}
+
+LRESULT DrawsGradient::onPrintClient(WPARAM wParam, LPARAM, bool& handled)
+{
+ paint(reinterpret_cast<HDC>(wParam));
+
+ handled = true;
+ return 0;
+}
+
+void DrawsGradient::paint(HDC dc) const
+{
+ RECT clientRect;
+ if (!::GetClientRect(window(), &clientRect))
+ return;
+
+ TRIVERTEX vertices[] = {
+ // Upper-left: green
+ { clientRect.left, clientRect.top, 0, 0xff00, 0, 0 },
+ // Upper-right: blue
+ { clientRect.right, clientRect.top, 0, 0, 0xff00, 0 },
+ // Lower-left: yellow
+ { clientRect.left, clientRect.bottom, 0xff00, 0xff00, 0, 0 },
+ // Lower-right: red
+ { clientRect.right, clientRect.bottom, 0xff00, 0, 0, 0 },
+ };
+
+ GRADIENT_TRIANGLE mesh[] = {
+ // Upper-left triangle
+ { 0, 1, 2 },
+ // Lower-right triangle
+ { 1, 2, 3 },
+ };
+
+ ::GradientFill(dc, vertices, _countof(vertices), mesh, _countof(mesh), GRADIENT_FILL_TRIANGLE);
+}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp
index 90ea54d..e598c49 100644
--- a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp
@@ -23,7 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "PluginTest.h"
+#include "WindowedPluginTest.h"
#include "PluginObject.h"
@@ -69,28 +69,24 @@ TemporaryWindowMover::~TemporaryWindowMover()
::SetWindowPos(m_window, 0, m_savedWindowRect.left, m_savedWindowRect.top, 0, 0, SWP_HIDEWINDOW | standardSetWindowPosFlags);
}
-class NPNInvalidateRectInvalidatesWindow : public PluginTest {
+class NPNInvalidateRectInvalidatesWindow : public WindowedPluginTest {
public:
NPNInvalidateRectInvalidatesWindow(NPP, const string& identifier);
~NPNInvalidateRectInvalidatesWindow();
private:
- static LRESULT CALLBACK wndProc(HWND, UINT message, WPARAM, LPARAM);
+ virtual LRESULT wndProc(UINT message, WPARAM, LPARAM, bool& handled);
void onPaint();
void testInvalidateRect();
virtual NPError NPP_SetWindow(NPP, NPWindow*);
- HWND m_window;
- WNDPROC m_originalWndProc;
TemporaryWindowMover* m_windowMover;
};
NPNInvalidateRectInvalidatesWindow::NPNInvalidateRectInvalidatesWindow(NPP npp, const string& identifier)
- : PluginTest(npp, identifier)
- , m_window(0)
- , m_originalWndProc(0)
+ : WindowedPluginTest(npp, identifier)
, m_windowMover(0)
{
}
@@ -100,30 +96,20 @@ NPNInvalidateRectInvalidatesWindow::~NPNInvalidateRectInvalidatesWindow()
delete m_windowMover;
}
-NPError NPNInvalidateRectInvalidatesWindow::NPP_SetWindow(NPP instance, NPWindow* window)
+NPError NPNInvalidateRectInvalidatesWindow::NPP_SetWindow(NPP instance, NPWindow* npWindow)
{
- HWND newWindow = reinterpret_cast<HWND>(window->window);
- if (newWindow == m_window)
- return NPERR_NO_ERROR;
-
- if (m_window) {
- ::RemovePropW(m_window, instancePointerProperty);
- ::SetWindowLongPtr(m_window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(m_originalWndProc));
- m_originalWndProc = 0;
- }
+ NPError error = WindowedPluginTest::NPP_SetWindow(instance, npWindow);
+ if (error != NPERR_NO_ERROR)
+ return error;
- m_window = newWindow;
- if (!m_window)
+ if (!window())
return NPERR_NO_ERROR;
- m_originalWndProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtrW(m_window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(wndProc)));
- ::SetPropW(m_window, instancePointerProperty, this);
-
// The test harness's window (the one that contains the WebView) is off-screen and hidden.
// We need to move it on-screen and make it visible in order for the plugin's window to
// accumulate an update region when the DWM is disabled.
- HWND testHarnessWindow = ::GetAncestor(m_window, GA_ROOT);
+ HWND testHarnessWindow = ::GetAncestor(window(), GA_ROOT);
if (!testHarnessWindow) {
pluginLog(instance, "Failed to get test harness window");
return NPERR_GENERIC_ERROR;
@@ -141,14 +127,13 @@ NPError NPNInvalidateRectInvalidatesWindow::NPP_SetWindow(NPP instance, NPWindow
return NPERR_NO_ERROR;
}
-LRESULT NPNInvalidateRectInvalidatesWindow::wndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+LRESULT NPNInvalidateRectInvalidatesWindow::wndProc(UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
{
- NPNInvalidateRectInvalidatesWindow* instance = reinterpret_cast<NPNInvalidateRectInvalidatesWindow*>(::GetPropW(hwnd, instancePointerProperty));
-
if (message == WM_PAINT)
- instance->onPaint();
+ onPaint();
- return ::CallWindowProcW(instance->m_originalWndProc, hwnd, message, wParam, lParam);
+ handled = false;
+ return 0;
}
void NPNInvalidateRectInvalidatesWindow::onPaint()
@@ -162,7 +147,7 @@ void NPNInvalidateRectInvalidatesWindow::onPaint()
void NPNInvalidateRectInvalidatesWindow::testInvalidateRect()
{
RECT clientRect;
- if (!::GetClientRect(m_window, &clientRect)) {
+ if (!::GetClientRect(window(), &clientRect)) {
pluginLog(m_npp, "::GetClientRect failed");
return;
}
@@ -173,7 +158,7 @@ void NPNInvalidateRectInvalidatesWindow::testInvalidateRect()
}
// Clear the invalid region.
- if (!::ValidateRect(m_window, 0)) {
+ if (!::ValidateRect(window(), 0)) {
pluginLog(m_npp, "::ValidateRect failed");
return;
}
@@ -187,7 +172,7 @@ void NPNInvalidateRectInvalidatesWindow::testInvalidateRect()
NPN_InvalidateRect(&rectToInvalidate);
RECT invalidRect;
- if (!::GetUpdateRect(m_window, &invalidRect, FALSE)) {
+ if (!::GetUpdateRect(window(), &invalidRect, FALSE)) {
pluginLog(m_npp, "::GetUpdateRect failed");
return;
}
diff --git a/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp
new file mode 100644
index 0000000..975a598
--- /dev/null
+++ b/WebKitTools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2010 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;
+
+// The plugin's window's window region should be set to the plugin's clip rect.
+
+class WindowRegionIsSetToClipRect : public PluginTest {
+public:
+ WindowRegionIsSetToClipRect(NPP, const string& identifier);
+
+private:
+ virtual NPError NPP_SetWindow(NPP, NPWindow*);
+
+ bool m_didReceiveInitialSetWindowCall;
+};
+
+static PluginTest::Register<WindowRegionIsSetToClipRect> registrar("window-region-is-set-to-clip-rect");
+
+WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect(NPP npp, const string& identifier)
+ : PluginTest(npp, identifier)
+ , m_didReceiveInitialSetWindowCall(false)
+{
+}
+
+NPError WindowRegionIsSetToClipRect::NPP_SetWindow(NPP instance, NPWindow* window)
+{
+ if (m_didReceiveInitialSetWindowCall)
+ return NPERR_NO_ERROR;
+ m_didReceiveInitialSetWindowCall = true;
+
+ if (window->type != NPWindowTypeWindow) {
+ pluginLog(instance, "window->type should be NPWindowTypeWindow but was %d", window->type);
+ return NPERR_GENERIC_ERROR;
+ }
+
+ HWND hwnd = reinterpret_cast<HWND>(window->window);
+
+ RECT regionRect;
+ if (::GetWindowRgnBox(hwnd, &regionRect) == ERROR) {
+ pluginLog(instance, "::GetWindowRgnBox failed with error %u", ::GetLastError());
+ return NPERR_GENERIC_ERROR;
+ }
+
+ // This expected rect is based on the layout of window-region-is-set-to-clip-rect.html.
+ RECT expectedRect = { 50, 50, 100, 100 };
+ if (!::EqualRect(&regionRect, &expectedRect)) {
+ pluginLog(instance, "Expected region rect {left=%u, top=%u, right=%u, bottom=%u}, but got {left=%d, top=%d, right=%d, bottom=%d}", expectedRect.left, expectedRect.top, expectedRect.right, expectedRect.bottom, regionRect.left, regionRect.top, regionRect.right, regionRect.bottom);
+ return NPERR_GENERIC_ERROR;
+ }
+
+ pluginLog(instance, "PASS: Plugin's window's window region has been set as expected");
+
+ // While we're here, check that our window class doesn't have the CS_PARENTDC style, which
+ // defeats clipping by ignoring the window region and always clipping to the parent window.
+ // FIXME: It would be nice to have a pixel test that shows that we're
+ // getting clipped correctly, but unfortunately window regions are ignored
+ // during WM_PRINT (see <http://webkit.org/b/49034>).
+ wchar_t className[512];
+ if (!::GetClassNameW(hwnd, className, _countof(className))) {
+ pluginLog(instance, "::GetClassName failed with error %u", ::GetLastError());
+ return NPERR_GENERIC_ERROR;
+ }
+
+#ifdef DEBUG_ALL
+ const wchar_t webKitDLLName[] = L"WebKit_debug.dll";
+#else
+ const wchar_t webKitDLLName[] = L"WebKit.dll";
+#endif
+ HMODULE webKitModule = ::GetModuleHandleW(webKitDLLName);
+ if (!webKitModule) {
+ pluginLog(instance, "::GetModuleHandleW failed with error %u", ::GetLastError());
+ return NPERR_GENERIC_ERROR;
+ }
+
+ WNDCLASSW wndClass;
+ if (!::GetClassInfoW(webKitModule, className, &wndClass)) {
+ pluginLog(instance, "::GetClassInfoW failed with error %u", ::GetLastError());
+ return NPERR_GENERIC_ERROR;
+ }
+
+ if (wndClass.style & CS_PARENTDC)
+ pluginLog(instance, "FAIL: Plugin's window's class has the CS_PARENTDC style, which will defeat clipping");
+ else
+ pluginLog(instance, "PASS: Plugin's window's class does not have the CS_PARENTDC style");
+
+ return NPERR_NO_ERROR;
+}