Changeset 80001 in webkit


Ignore:
Timestamp:
Mar 1, 2011 7:29:44 AM (13 years ago)
Author:
Adam Roben
Message:

Convert seconds to milliseconds before calling ::SetTimer

Fixes <http://webkit.org/b/55417> <rdar://problem/9065287> RunLoop::Timer fires 1000x too
early on Windows

Reviewed by Anders Carlsson.

Source/WebKit2:

  • Platform/win/RunLoopWin.cpp:

(RunLoop::TimerBase::start): Convert the timeout interval to milliseconds, since that's what
::SetTimer expects.

Tools:

Test that the WebKit2 responsiveness timer doesn't fire too early

  • TestWebKitAPI/PlatformUtilities.h: Added sleep().
  • TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly.cpp: Added.

(TestWebKitAPI::didReceiveMessageFromInjectedBundle):
(TestWebKitAPI::didFinishLoadForFrame):
(TestWebKitAPI::processDidBecomeUnresponsive):
(TestWebKitAPI::setInjectedBundleClient):
(TestWebKitAPI::setPageLoaderClient):
Simple helper functions.

(TestWebKitAPI::TEST): Load an HTML file to make sure the web process is initialized. Then
tell the web process to pause and press the spacebar key. The spacebar keypress should cause
the responsiveness timer to start, but the web process should unpause before it has a chance
to fire. Run until the web process has unpaused, and assert that the timer didn't fire.

  • TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp: Added.

(TestWebKitAPI::ResponsivenessTimerDoesntFireEarlyTest::ResponsivenessTimerDoesntFireEarlyTest):
Call up to the base class.
(TestWebKitAPI::ResponsivenessTimerDoesntFireEarlyTest::didReceiveMessage): When asked to
pause, sleep for 0.5 seconds, then send back a message saying we paused.

  • TestWebKitAPI/mac/PlatformUtilitiesMac.mm:

(TestWebKitAPI::Util::sleep): Added. Calls through to usleep.

  • TestWebKitAPI/win/PlatformUtilitiesWin.cpp:

(TestWebKitAPI::Util::sleep): Added. Calls through to ::Sleep.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/win/TestWebKitAPI.vcproj:
  • TestWebKitAPI/win/TestWebKitAPIInjectedBundle.vcproj:

Added new files.

Location:
trunk
Files:
1 added
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r79999 r80001  
     12011-03-01  Adam Roben  <aroben@apple.com>
     2
     3        Convert seconds to milliseconds before calling ::SetTimer
     4
     5        Fixes <http://webkit.org/b/55417> <rdar://problem/9065287> RunLoop::Timer fires 1000x too
     6        early on Windows
     7
     8        Reviewed by Anders Carlsson.
     9
     10        * Platform/win/RunLoopWin.cpp:
     11        (RunLoop::TimerBase::start): Convert the timeout interval to milliseconds, since that's what
     12        ::SetTimer expects.
     13
    1142011-03-01  Andras Becsi  <abecsi@webkit.org>
    215
  • trunk/Source/WebKit2/Platform/win/RunLoopWin.cpp

    r77939 r80001  
    157157    m_isRepeating = repeat;
    158158    m_runLoop->m_activeTimers.set(m_ID, this);
    159     ::SetTimer(m_runLoop->m_runLoopMessageWindow, m_ID, nextFireInterval, 0);
     159    ::SetTimer(m_runLoop->m_runLoopMessageWindow, m_ID, nextFireInterval * 1000, 0);
    160160}
    161161
  • trunk/Tools/ChangeLog

    r79999 r80001  
     12011-03-01  Adam Roben  <aroben@apple.com>
     2
     3        Test that the WebKit2 responsiveness timer doesn't fire too early
     4
     5        Test for <http://webkit.org/b/55417> <rdar://problem/9065287> RunLoop::Timer fires 1000x too
     6        early on Windows
     7
     8        Reviewed by Anders Carlsson.
     9
     10        * TestWebKitAPI/PlatformUtilities.h: Added sleep().
     11
     12        * TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly.cpp: Added.
     13        (TestWebKitAPI::didReceiveMessageFromInjectedBundle):
     14        (TestWebKitAPI::didFinishLoadForFrame):
     15        (TestWebKitAPI::processDidBecomeUnresponsive):
     16        (TestWebKitAPI::setInjectedBundleClient):
     17        (TestWebKitAPI::setPageLoaderClient):
     18        Simple helper functions.
     19
     20        (TestWebKitAPI::TEST): Load an HTML file to make sure the web process is initialized. Then
     21        tell the web process to pause and press the spacebar key. The spacebar keypress should cause
     22        the responsiveness timer to start, but the web process should unpause before it has a chance
     23        to fire. Run until the web process has unpaused, and assert that the timer didn't fire.
     24
     25        * TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp: Added.
     26        (TestWebKitAPI::ResponsivenessTimerDoesntFireEarlyTest::ResponsivenessTimerDoesntFireEarlyTest):
     27        Call up to the base class.
     28        (TestWebKitAPI::ResponsivenessTimerDoesntFireEarlyTest::didReceiveMessage): When asked to
     29        pause, sleep for 0.5 seconds, then send back a message saying we paused.
     30
     31        * TestWebKitAPI/mac/PlatformUtilitiesMac.mm:
     32        (TestWebKitAPI::Util::sleep): Added. Calls through to usleep.
     33        * TestWebKitAPI/win/PlatformUtilitiesWin.cpp:
     34        (TestWebKitAPI::Util::sleep): Added. Calls through to ::Sleep.
     35
     36        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     37        * TestWebKitAPI/win/TestWebKitAPI.vcproj:
     38        * TestWebKitAPI/win/TestWebKitAPIInjectedBundle.vcproj:
     39        Added new files.
     40
    1412011-03-01  Andras Becsi  <abecsi@webkit.org>
    242
  • trunk/Tools/TestWebKitAPI/PlatformUtilities.h

    r73336 r80001  
    3737void run(bool* done);
    3838
     39void sleep(double seconds);
     40
    3941WKContextRef createContextForInjectedBundleTest(const std::string&, WKTypeRef userData = 0);
    4042
     
    4850WKRetainPtr<WKStringRef> toWK(const char* utf8String);
    4951
    50 
    5152template<typename T> static inline WKRetainPtr<T> adoptWK(T item)
    5253{
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r79966 r80001  
    5353                C0ADBE8312FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */; };
    5454                C0ADBE9612FCA79B00D2C129 /* simple-form.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C0ADBE8412FCA6B600D2C129 /* simple-form.html */; };
     55                C0BD669D131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */; };
     56                C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */; };
    5557/* End PBXBuildFile section */
    5658
     
    150152                C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RestoreSessionStateContainingFormData.cpp; sourceTree = "<group>"; };
    151153                C0ADBE8412FCA6B600D2C129 /* simple-form.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "simple-form.html"; sourceTree = "<group>"; };
     154                C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly.cpp; sourceTree = "<group>"; };
     155                C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResponsivenessTimerDoesntFireEarly_Bundle.cpp; sourceTree = "<group>"; };
    152156/* End PBXFileReference section */
    153157
     
    269273                                BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */,
    270274                                333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */,
     275                                C0BD669C131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp */,
     276                                C0BD669E131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp */,
    271277                                C0ADBE8212FCA6AA00D2C129 /* RestoreSessionStateContainingFormData.cpp */,
    272278                                C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */,
     
    423429                                1ADBEFAE130C689C00D61D19 /* ForceRepaint.cpp in Sources */,
    424430                                4BFDFFA9131477770061F24B /* HitTestResultNodeHandle.cpp in Sources */,
     431                                C0BD669D131D3CF700E18F2A /* ResponsivenessTimerDoesntFireEarly.cpp in Sources */,
    425432                        );
    426433                        runOnlyForDeploymentPostprocessing = 0;
     
    437444                                BCB68042126FBFF100642A61 /* DocumentStartUserScriptAlertCrash_Bundle.cpp in Sources */,
    438445                                4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */,
     446                                C0BD669F131D3CFF00E18F2A /* ResponsivenessTimerDoesntFireEarly_Bundle.cpp in Sources */,
    439447                        );
    440448                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp

    r80000 r80001  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef PlatformUtilities_h
    27 #define PlatformUtilities_h
     26#include "InjectedBundleTest.h"
    2827
    29 #include <WebKit2/WebKit2.h>
    30 #include <WebKit2/WKRetainPtr.h>
    31 #include <string>
     28#include "PlatformUtilities.h"
    3229
    3330namespace TestWebKitAPI {
    34 namespace Util {
    3531
    36 // Runs a platform runloop until the 'done' is true.
    37 void run(bool* done);
     32class ResponsivenessTimerDoesntFireEarlyTest : public InjectedBundleTest {
     33public:
     34    ResponsivenessTimerDoesntFireEarlyTest(const std::string& identifier);
    3835
    39 WKContextRef createContextForInjectedBundleTest(const std::string&, WKTypeRef userData = 0);
     36private:
     37    virtual void didReceiveMessage(WKBundleRef, WKStringRef messageName, WKTypeRef messageBody);
     38};
    4039
    41 WKStringRef createInjectedBundlePath();
    42 WKURLRef createURLForResource(const char* resource, const char* extension);
    43 WKURLRef URLForNonExistentResource();
     40static InjectedBundleTest::Register<ResponsivenessTimerDoesntFireEarlyTest> registrar("ResponsivenessTimerDoesntFireEarlyTest");
    4441
    45 bool isKeyDown(WKNativeEventPtr);
    46 
    47 std::string toSTD(WKStringRef string);
    48 WKRetainPtr<WKStringRef> toWK(const char* utf8String);
    49 
    50 
    51 template<typename T> static inline WKRetainPtr<T> adoptWK(T item)
     42ResponsivenessTimerDoesntFireEarlyTest::ResponsivenessTimerDoesntFireEarlyTest(const std::string& identifier)
     43    : InjectedBundleTest(identifier)
    5244{
    53     return WKRetainPtr<T>(AdoptWK, item);
    5445}
    5546
    56 } // namespace Util
     47void ResponsivenessTimerDoesntFireEarlyTest::didReceiveMessage(WKBundleRef bundle, WKStringRef messageName, WKTypeRef)
     48{
     49    if (!WKStringIsEqualToUTF8CString(messageName, "BrieflyPause"))
     50        return;
     51
     52    // The responsiveness timer is a 3-second timer. Pausing for 0.5 seconds should not cause it to fire.
     53    Util::sleep(0.5);
     54
     55    WKBundlePostMessage(bundle, Util::toWK("DidBrieflyPause").get(), 0);
     56}
     57
    5758} // namespace TestWebKitAPI
    58 
    59 #endif // PlatformUtilities_h
  • trunk/Tools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm

    r70352 r80001  
    4040}
    4141
     42void sleep(double seconds)
     43{
     44    usleep(seconds * 1000000);
     45}
     46
    4247WKStringRef createInjectedBundlePath()
    4348{
  • trunk/Tools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp

    r79938 r80001  
    5151}
    5252
     53void sleep(double seconds)
     54{
     55    ::Sleep(seconds * 1000);
     56}
     57
    5358RetainPtr<CFStringRef> cf(const char* utf8String)
    5459{
  • trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj

    r79966 r80001  
    473473                                </File>
    474474                                <File
     475                                        RelativePath="..\Tests\WebKit2\ResponsivenessTimerDoesntFireEarly.cpp"
     476                                        >
     477                                </File>
     478                                <File
    475479                                        RelativePath="..\Tests\WebKit2\RestoreSessionStateContainingFormData.cpp"
    476480                                        >
  • trunk/Tools/TestWebKitAPI/win/TestWebKitAPIInjectedBundle.vcproj

    r79966 r80001  
    412412                                        >
    413413                                </File>
     414                                <File
     415                                        RelativePath="..\Tests\WebKit2\ResponsivenessTimerDoesntFireEarly_Bundle.cpp"
     416                                        >
     417                                </File>
    414418                        </Filter>
    415419                </Filter>
Note: See TracChangeset for help on using the changeset viewer.