Changeset 86157 in webkit


Ignore:
Timestamp:
May 10, 2011 8:50:40 AM (13 years ago)
Author:
Adam Roben
Message:

Update some plugin tests to work with WebKit2's asynchronous windowed plugin positioning on Windows

Fixes <http://webkit.org/b/60442> <rdar://problem/9403200> REGRESSION (r85795):
platform/win/plugins/window-geometry-initialized-before-set-window.html and
platform/win/plugins/window-region-is-set-to-clip-rect.html failing on Windows 7 Release
(WebKit2 Tests)

Reviewed by Anders Carlsson.

Tools:

  • DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp:

(NPNInvalidateRectInvalidatesWindow::NPP_SetWindow): Moved some code from here to the new
WindowedPluginTest::testHarnessWindow function.

  • DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp:

(WindowGeometryInitializedBeforeSetWindow::NPP_SetWindow): Only check the window's size, not
its position. In WebKit2, the position won't have been set yet, so we can't test it. But it
turns out only the size mattered for <http://webkit.org/b/46716>, which this test was
created for.

  • DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp:

(WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect): Converted to be a
WindowedPluginTest, and initialized new members.
(WindowRegionIsSetToClipRect::startTest): Make our plugin window visible, and set things up
to ensure we get a WM_WINDOWPOSCHANGED message about it becoming visible.
(WindowRegionIsSetToClipRect::finishTest): Check that the window region is what we expect,
then clean up and tell the test harness we're done.
(WindowRegionIsSetToClipRect::checkWindowRegion): Moved code to check the window region here
from NPP_SetWindow. Changed to use the fancy new log() function instead of pluginLog().
(WindowRegionIsSetToClipRect::showTestHarnessWindowIfNeeded): Show the test harness's window
if it is hidden. This is needed to ensure we get a WM_WINDOWPOSCHANGED message when our own
window becomes visible.
(WindowRegionIsSetToClipRect::hideTestHarnessWindowIfNeeded): Hide the test harness's window
if it was hidden at the start of the test.
(WindowRegionIsSetToClipRect::wndProc): When our timer fires, tell the UI process to paint.
This should cause our window to become visible and our window region to get set. When we get
a WM_WINDOWPOSCHANGED message, we can finally finish the test.
(WindowRegionIsSetToClipRect::NPP_GetValue): Return our script object.
(WindowRegionIsSetToClipRect::ScriptObject::hasMethod): We only have one method:
"startTest".
(WindowRegionIsSetToClipRect::ScriptObject::invoke): Call through to the PluginTest object.

  • DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.cpp:

(WindowedPluginTest::testHarnessWindow):

  • DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.h:

Added this helper function. Code came from NPNInvalidateRectInvalidatesWindow.

LayoutTests:

  • platform/win/plugins/window-geometry-initialized-before-set-window-expected.txt: Updated

for new test output that doesn't claim anything about the window's position.

  • platform/win/plugins/window-region-is-set-to-clip-rect.html: Hide the plugin initially,

and tell the plugin when the load event has fired.

  • platform/win-wk2/platform/win/plugins/window-geometry-initialized-before-set-window-expected.txt: Removed.
  • platform/win-wk2/platform/win/plugins/window-region-is-set-to-clip-rect-expected.txt: Removed.
Location:
trunk
Files:
2 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r86156 r86157  
     12011-05-10  Adam Roben  <aroben@apple.com>
     2
     3        Update some plugin tests to work with WebKit2's asynchronous windowed plugin positioning on Windows
     4
     5        Fixes <http://webkit.org/b/60442> <rdar://problem/9403200> REGRESSION (r85795):
     6        platform/win/plugins/window-geometry-initialized-before-set-window.html and
     7        platform/win/plugins/window-region-is-set-to-clip-rect.html failing on Windows 7 Release
     8        (WebKit2 Tests)
     9
     10        Reviewed by Anders Carlsson.
     11
     12        * platform/win/plugins/window-geometry-initialized-before-set-window-expected.txt: Updated
     13        for new test output that doesn't claim anything about the window's position.
     14
     15        * platform/win/plugins/window-region-is-set-to-clip-rect.html: Hide the plugin initially,
     16        and tell the plugin when the load event has fired.
     17
     18        * platform/win-wk2/platform/win/plugins/window-geometry-initialized-before-set-window-expected.txt: Removed.
     19        * platform/win-wk2/platform/win/plugins/window-region-is-set-to-clip-rect-expected.txt: Removed.
     20
    1212011-05-10  Csaba Osztrogonác  <ossy@webkit.org>
    222
  • trunk/LayoutTests/platform/win/plugins/window-geometry-initialized-before-set-window-expected.txt

    r68520 r86157  
    1 CONSOLE MESSAGE: line 0: PLUGIN: Plugin's HWND has been sized and positioned before NPP_SetWindow was called
     1CONSOLE MESSAGE: line 0: PLUGIN: Plugin's HWND has been sized before NPP_SetWindow was called
    22
    33This tests that a plugin's HWND is already sized and positioned before NPP_SetWindow is called.
  • trunk/LayoutTests/platform/win/plugins/window-region-is-set-to-clip-rect.html

    r71416 r86157  
    55        if (window.layoutTestController)
    66            layoutTestController.dumpAsText();
     7        addEventListener('load', function() { document.getElementsByTagName('embed')[0].startTest() }, false);
    78    </script>
    89    <style>
     
    1718            top: -50px;
    1819            left: -50px;
     20            visibility: hidden;
    1921        }
    2022    </style>
  • trunk/Tools/ChangeLog

    r86141 r86157  
     12011-05-10  Adam Roben  <aroben@apple.com>
     2
     3        Update some plugin tests to work with WebKit2's asynchronous windowed plugin positioning on Windows
     4
     5        Fixes <http://webkit.org/b/60442> <rdar://problem/9403200> REGRESSION (r85795):
     6        platform/win/plugins/window-geometry-initialized-before-set-window.html and
     7        platform/win/plugins/window-region-is-set-to-clip-rect.html failing on Windows 7 Release
     8        (WebKit2 Tests)
     9
     10        Reviewed by Anders Carlsson.
     11
     12        * DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp:
     13        (NPNInvalidateRectInvalidatesWindow::NPP_SetWindow): Moved some code from here to the new
     14        WindowedPluginTest::testHarnessWindow function.
     15
     16        * DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp:
     17        (WindowGeometryInitializedBeforeSetWindow::NPP_SetWindow): Only check the window's size, not
     18        its position. In WebKit2, the position won't have been set yet, so we can't test it. But it
     19        turns out only the size mattered for <http://webkit.org/b/46716>, which this test was
     20        created for.
     21
     22        * DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp:
     23        (WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect): Converted to be a
     24        WindowedPluginTest, and initialized new members.
     25        (WindowRegionIsSetToClipRect::startTest): Make our plugin window visible, and set things up
     26        to ensure we get a WM_WINDOWPOSCHANGED message about it becoming visible.
     27        (WindowRegionIsSetToClipRect::finishTest): Check that the window region is what we expect,
     28        then clean up and tell the test harness we're done.
     29        (WindowRegionIsSetToClipRect::checkWindowRegion): Moved code to check the window region here
     30        from NPP_SetWindow. Changed to use the fancy new log() function instead of pluginLog().
     31        (WindowRegionIsSetToClipRect::showTestHarnessWindowIfNeeded): Show the test harness's window
     32        if it is hidden. This is needed to ensure we get a WM_WINDOWPOSCHANGED message when our own
     33        window becomes visible.
     34        (WindowRegionIsSetToClipRect::hideTestHarnessWindowIfNeeded): Hide the test harness's window
     35        if it was hidden at the start of the test.
     36        (WindowRegionIsSetToClipRect::wndProc): When our timer fires, tell the UI process to paint.
     37        This should cause our window to become visible and our window region to get set. When we get
     38        a WM_WINDOWPOSCHANGED message, we can finally finish the test.
     39        (WindowRegionIsSetToClipRect::NPP_GetValue): Return our script object.
     40        (WindowRegionIsSetToClipRect::ScriptObject::hasMethod): We only have one method:
     41        "startTest".
     42        (WindowRegionIsSetToClipRect::ScriptObject::invoke): Call through to the PluginTest object.
     43
     44        * DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.cpp:
     45        (WindowedPluginTest::testHarnessWindow):
     46        * DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.h:
     47        Added this helper function. Code came from NPNInvalidateRectInvalidatesWindow.
     48
    1492011-05-10  Csaba Osztrogonác  <ossy@webkit.org>
    250
  • trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/win/NPNInvalidateRectInvalidatesWindow.cpp

    r71417 r86157  
    110110    // accumulate an update region when the DWM is disabled.
    111111
    112     HWND testHarnessWindow = ::GetAncestor(window(), GA_ROOT);
     112    HWND testHarnessWindow = this->testHarnessWindow();
    113113    if (!testHarnessWindow) {
    114114        pluginLog(instance, "Failed to get test harness window");
  • trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowGeometryInitializedBeforeSetWindow.cpp

    r68785 r86157  
    6464        }
    6565
    66         HWND parent = ::GetParent(hwnd);
    67         if (!parent) {
    68             pluginLog(instance, "::GetParent failed");
     66        if ((rect.right - rect.left) != window->width || (rect.bottom - rect.top) != window->height) {
     67            pluginLog(instance, "Size of HWND's rect and size of NPWindow's rect are not equal");
    6968            return NPERR_GENERIC_ERROR;
    7069        }
    7170
    72         // MSDN says that calling ::MapWindowPoints this way will tell it we're passing a RECT rather than two POINTs.
    73         if (!::MapWindowPoints(hwnd, parent, reinterpret_cast<POINT*>(&rect), 2)) {
    74             pluginLog(instance, "::MapWindowPoints failed");
    75             return NPERR_GENERIC_ERROR;
    76         }
    77 
    78         if (rect.left != window->x || rect.top != window->y || (rect.right - rect.left) != window->width || (rect.bottom - rect.top) != window->height) {
    79             pluginLog(instance, "HWND's rect and NPWindow's rect are not equal");
    80             return NPERR_GENERIC_ERROR;
    81         }
    82 
    83         pluginLog(instance, "Plugin's HWND has been sized and positioned before NPP_SetWindow was called");
     71        pluginLog(instance, "Plugin's HWND has been sized before NPP_SetWindow was called");
    8472        return NPERR_NO_ERROR;
    8573    }
  • trunk/Tools/DumpRenderTree/TestNetscapePlugIn/Tests/win/WindowRegionIsSetToClipRect.cpp

    r71416 r86157  
    2424 */
    2525
    26 #include "PluginTest.h"
     26#include "WindowedPluginTest.h"
    2727
    2828#include "PluginObject.h"
     
    3232// The plugin's window's window region should be set to the plugin's clip rect.
    3333
    34 class WindowRegionIsSetToClipRect : public PluginTest {
     34class WindowRegionIsSetToClipRect : public WindowedPluginTest {
    3535public:
    3636    WindowRegionIsSetToClipRect(NPP, const string& identifier);
    3737
    3838private:
    39     virtual NPError NPP_SetWindow(NPP, NPWindow*);
    40 
    41     bool m_didReceiveInitialSetWindowCall;
     39    struct ScriptObject : Object<ScriptObject> {
     40        bool hasMethod(NPIdentifier);
     41        bool invoke(NPIdentifier, const NPVariant*, uint32_t, NPVariant*);
     42    };
     43
     44    static const UINT_PTR triggerPaintTimerID = 1;
     45
     46    void startTest();
     47    void finishTest();
     48    void checkWindowRegion();
     49
     50    void showTestHarnessWindowIfNeeded();
     51    void hideTestHarnessWindowIfNeeded();
     52
     53    // WindowedPluginTest
     54    virtual LRESULT wndProc(UINT message, WPARAM, LPARAM, bool& handled);
     55
     56    // PluginTest
     57    virtual NPError NPP_GetValue(NPPVariable, void*);
     58
     59    bool m_didCheckWindowRegion;
     60    bool m_testHarnessWindowWasVisible;
    4261};
    4362
     
    4564
    4665WindowRegionIsSetToClipRect::WindowRegionIsSetToClipRect(NPP npp, const string& identifier)
    47     : PluginTest(npp, identifier)
    48     , m_didReceiveInitialSetWindowCall(false)
    49 {
    50 }
    51 
    52 NPError WindowRegionIsSetToClipRect::NPP_SetWindow(NPP instance, NPWindow* window)
    53 {
    54     if (m_didReceiveInitialSetWindowCall)
    55         return NPERR_NO_ERROR;
    56     m_didReceiveInitialSetWindowCall = true;
    57 
    58     if (window->type != NPWindowTypeWindow) {
    59         pluginLog(instance, "window->type should be NPWindowTypeWindow but was %d", window->type);
    60         return NPERR_GENERIC_ERROR;
    61     }
    62 
    63     HWND hwnd = reinterpret_cast<HWND>(window->window);
     66    : WindowedPluginTest(npp, identifier)
     67    , m_didCheckWindowRegion(false)
     68    , m_testHarnessWindowWasVisible(false)
     69{
     70}
     71
     72void WindowRegionIsSetToClipRect::startTest()
     73{
     74    // In WebKit1, our window's window region will be set immediately. In WebKit2, it won't be set
     75    // until the UI process paints. Since the UI process will also show our window when it paints,
     76    // we can detect when the paint occurs (and thus when our window region should be set) by
     77    // starting with our plugin element hidden, then making it visible and waiting for a
     78    // WM_WINDOWPOSCHANGED event to tell us our window has been shown.
     79
     80    waitUntilDone();
     81
     82    // If the test harness window isn't visible, we might not receive a WM_WINDOWPOSCHANGED message
     83    // when our window is made visible. So we temporarily show the test harness window during this test.
     84    showTestHarnessWindowIfNeeded();
     85
     86    // Make our window visible. (In WebKit2, this won't take effect immediately.)
     87    executeScript("document.getElementsByTagName('embed')[0].style.visibility = 'visible';");
     88
     89    // We trigger a UI process paint after a slight delay to ensure that the UI process has
     90    // received the "make the plugin window visible" message before it paints.
     91    // FIXME: It would be nice to have a way to guarantee that the UI process had received that
     92    // message before we triggered a paint. Hopefully that would let us get rid of this semi-
     93    // arbitrary timeout.
     94    ::SetTimer(window(), triggerPaintTimerID, 250, 0);
     95}
     96
     97void WindowRegionIsSetToClipRect::finishTest()
     98{
     99    checkWindowRegion();
     100    hideTestHarnessWindowIfNeeded();
     101    notifyDone();
     102}
     103
     104void WindowRegionIsSetToClipRect::checkWindowRegion()
     105{
     106    if (m_didCheckWindowRegion)
     107        return;
     108    m_didCheckWindowRegion = true;
    64109
    65110    RECT regionRect;
    66     if (::GetWindowRgnBox(hwnd, &regionRect) == ERROR) {
    67         pluginLog(instance, "::GetWindowRgnBox failed with error %u", ::GetLastError());
    68         return NPERR_GENERIC_ERROR;
     111    if (::GetWindowRgnBox(window(), &regionRect) == ERROR) {
     112        log("::GetWindowRgnBox failed, or window has no window region");
     113        return;
    69114    }
    70115
     
    72117    RECT expectedRect = { 50, 50, 100, 100 };
    73118    if (!::EqualRect(&regionRect, &expectedRect)) {
    74         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);
    75         return NPERR_GENERIC_ERROR;
    76     }
    77 
    78     pluginLog(instance, "PASS: Plugin's window's window region has been set as expected");
     119        log("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);
     120        return;
     121    }
     122
     123    log("PASS: Plugin's window's window region has been set as expected");
    79124
    80125    // While we're here, check that our window class doesn't have the CS_PARENTDC style, which
     
    84129    // during WM_PRINT (see <http://webkit.org/b/49034>).
    85130    wchar_t className[512];
    86     if (!::GetClassNameW(hwnd, className, _countof(className))) {
    87         pluginLog(instance, "::GetClassName failed with error %u", ::GetLastError());
    88         return NPERR_GENERIC_ERROR;
     131    if (!::GetClassNameW(window(), className, _countof(className))) {
     132        log("::GetClassName failed with error %u", ::GetLastError());
     133        return;
    89134    }
    90135
     
    96141    HMODULE webKitModule = ::GetModuleHandleW(webKitDLLName);
    97142    if (!webKitModule) {
    98         pluginLog(instance, "::GetModuleHandleW failed with error %u", ::GetLastError());
    99         return NPERR_GENERIC_ERROR;
     143        log("::GetModuleHandleW failed with error %u", ::GetLastError());
     144        return;
    100145    }
    101146
    102147    WNDCLASSW wndClass;
    103148    if (!::GetClassInfoW(webKitModule, className, &wndClass)) {
    104         pluginLog(instance, "::GetClassInfoW failed with error %u", ::GetLastError());
     149        log("::GetClassInfoW failed with error %u", ::GetLastError());
     150        return;
     151    }
     152
     153    if (wndClass.style & CS_PARENTDC)
     154        log("FAIL: Plugin's window's class has the CS_PARENTDC style, which will defeat clipping");
     155    else
     156        log("PASS: Plugin's window's class does not have the CS_PARENTDC style");
     157}
     158
     159void WindowRegionIsSetToClipRect::showTestHarnessWindowIfNeeded()
     160{
     161    HWND testHarnessWindow = this->testHarnessWindow();
     162    m_testHarnessWindowWasVisible = ::IsWindowVisible(testHarnessWindow);
     163    if (m_testHarnessWindowWasVisible)
     164        return;
     165    ::ShowWindow(testHarnessWindow, SW_SHOWNA);
     166}
     167
     168void WindowRegionIsSetToClipRect::hideTestHarnessWindowIfNeeded()
     169{
     170    if (m_testHarnessWindowWasVisible)
     171        return;
     172    ::ShowWindow(testHarnessWindow(), SW_HIDE);
     173}
     174
     175LRESULT WindowRegionIsSetToClipRect::wndProc(UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
     176{
     177    switch (message) {
     178    case WM_TIMER:
     179        if (wParam != triggerPaintTimerID)
     180            break;
     181        handled = true;
     182        ::KillTimer(window(), wParam);
     183        // Tell the UI process to paint.
     184        ::PostMessageW(::GetParent(window()), WM_PAINT, 0, 0);
     185        break;
     186    case WM_WINDOWPOSCHANGED: {
     187        WINDOWPOS* windowPos = reinterpret_cast<WINDOWPOS*>(lParam);
     188        if (!(windowPos->flags & SWP_SHOWWINDOW))
     189            break;
     190        finishTest();
     191        break;
     192    }
     193
     194    }
     195
     196    return 0;
     197}
     198
     199NPError WindowRegionIsSetToClipRect::NPP_GetValue(NPPVariable variable, void* value)
     200{
     201    if (variable != NPPVpluginScriptableNPObject)
    105202        return NPERR_GENERIC_ERROR;
    106     }
    107 
    108     if (wndClass.style & CS_PARENTDC)
    109         pluginLog(instance, "FAIL: Plugin's window's class has the CS_PARENTDC style, which will defeat clipping");
    110     else
    111         pluginLog(instance, "PASS: Plugin's window's class does not have the CS_PARENTDC style");
     203
     204    *static_cast<NPObject**>(value) = ScriptObject::create(this);
    112205
    113206    return NPERR_NO_ERROR;
    114207}
     208
     209bool WindowRegionIsSetToClipRect::ScriptObject::hasMethod(NPIdentifier methodName)
     210{
     211    return methodName == pluginTest()->NPN_GetStringIdentifier("startTest");
     212}
     213
     214bool WindowRegionIsSetToClipRect::ScriptObject::invoke(NPIdentifier identifier, const NPVariant*, uint32_t, NPVariant*)
     215{
     216    assert(identifier == pluginTest()->NPN_GetStringIdentifier("startTest"));
     217    static_cast<WindowRegionIsSetToClipRect*>(pluginTest())->startTest();
     218    return true;
     219}
  • trunk/Tools/DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.cpp

    r71417 r86157  
    3737}
    3838
     39HWND WindowedPluginTest::testHarnessWindow() const
     40{
     41    return ::GetAncestor(window(), GA_ROOT);
     42}
     43
    3944NPError WindowedPluginTest::NPP_SetWindow(NPP instance, NPWindow* window)
    4045{
  • trunk/Tools/DumpRenderTree/TestNetscapePlugIn/win/WindowedPluginTest.h

    r71417 r86157  
    3434
    3535    HWND window() const { return m_window; }
     36    HWND testHarnessWindow() const;
    3637
    3738    // For derived classes to override
Note: See TracChangeset for help on using the changeset viewer.