Bug 143286 - Expand test infrastructure to support scrolling tests (Part 1)
Summary: Expand test infrastructure to support scrolling tests (Part 1)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on:
Blocks: 143684
  Show dependency treegraph
 
Reported: 2015-03-31 17:25 PDT by Brent Fulgham
Modified: 2015-04-24 11:13 PDT (History)
10 users (show)

See Also:


Attachments
Patch (134.05 KB, patch)
2015-03-31 17:59 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (130.92 KB, patch)
2015-03-31 18:04 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (130.92 KB, patch)
2015-03-31 18:08 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (131.47 KB, patch)
2015-03-31 18:15 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-mavericks (644.44 KB, application/zip)
2015-03-31 18:54 PDT, Build Bot
no flags Details
Patch (167.56 KB, patch)
2015-04-02 20:46 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (No longer based on global state) (164.84 KB, patch)
2015-04-02 21:02 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-mavericks (514.69 KB, application/zip)
2015-04-02 21:49 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews107 for mac-mavericks-wk2 (567.93 KB, application/zip)
2015-04-02 21:53 PDT, Build Bot
no flags Details
Patch (167.66 KB, patch)
2015-04-03 09:29 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (167.75 KB, patch)
2015-04-03 09:31 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (Revised to correct test failure) (167.77 KB, patch)
2015-04-03 09:56 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-mavericks (525.92 KB, application/zip)
2015-04-03 10:48 PDT, Build Bot
no flags Details
Patch (Revised for non-Mac build failures, and documenting a test problem found by this work). (168.55 KB, patch)
2015-04-03 11:16 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (38.65 KB, patch)
2015-04-03 18:00 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-mavericks (536.20 KB, application/zip)
2015-04-03 18:52 PDT, Build Bot
no flags Details
Patch (39.35 KB, patch)
2015-04-06 08:59 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (39.73 KB, patch)
2015-04-06 09:40 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (Correct iOS build) (39.79 KB, patch)
2015-04-06 10:21 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch Part 1: (Version has Another iOS fix) (39.75 KB, patch)
2015-04-06 11:33 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (39.55 KB, patch)
2015-04-10 13:23 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Wrong Bug! (38.54 KB, patch)
2015-04-23 17:23 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Wrong Bug! (39.32 KB, patch)
2015-04-24 09:00 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Wrong Bug (39.30 KB, patch)
2015-04-24 10:27 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2015-03-31 17:25:20 PDT
Our scrolling tests currently rely on large timeouts to ensure that tests work properly. This is because we need to wait to check our final DOM state until any scroll-generated animations complete. For example, we need to wait until any rubber banding or scroll-snap animations complete before we can determine if the scroll gesture moved us to the proper location.

This change adds a new test EventSender object method called "callAfterScrollingCompletes". This new method will be called when the scroll animations are finished, greatly reducing the need for arbitrary timeouts.
Comment 1 Radar WebKit Bug Importer 2015-03-31 17:26:24 PDT
<rdar://problem/20375516>
Comment 2 Brent Fulgham 2015-03-31 17:59:24 PDT
Created attachment 249873 [details]
Patch
Comment 3 Brent Fulgham 2015-03-31 18:04:37 PDT
Created attachment 249875 [details]
Patch
Comment 4 Brent Fulgham 2015-03-31 18:08:31 PDT
Created attachment 249876 [details]
Patch
Comment 5 Brent Fulgham 2015-03-31 18:15:19 PDT
Created attachment 249878 [details]
Patch
Comment 6 Brent Fulgham 2015-03-31 18:20:15 PDT
The first question for reviewers is whether implementing this as a Singleton is the right approach.

I initially tried to have this be a member of the MainFrame. However, making the various ScrollController instances (which do not generally have visibility of their containing objects) was going to involve threading a lot of MainFrame arguments through various create functions.
Comment 7 Simon Fraser (smfr) 2015-03-31 18:31:22 PDT
Comment on attachment 249878 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=249878&action=review

> Source/WebCore/page/WheelEventTestTrigger.cpp:62
> +    setTestNotificationCallback([=](void) {
> +        JSObjectCallAsFunction(context, functionCallback, nullptr, 0, nullptr, nullptr);
> +        JSValueUnprotect(context, functionCallback);
> +    });
> +}

I don't think we should have test code like this compiled into webcore all the time.

It feels like this WheelEventTestTrigger thing should be some kind of delegate that's only hooked up during testing.
Comment 8 Build Bot 2015-03-31 18:54:13 PDT
Comment on attachment 249878 [details]
Patch

Attachment 249878 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5761338848575488

New failing tests:
scrollbars/scrollevent-iframe-no-scrolling-wheel.html
Comment 9 Build Bot 2015-03-31 18:54:16 PDT
Created attachment 249880 [details]
Archive of layout-test-results from ews101 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 10 Brent Fulgham 2015-04-01 09:46:29 PDT
Note: This test failure indicates that the test doesn't work as expected -- the event handler is actually not locating a valid target NSView to process the event! That is not new with this change -- we can now just see that the test is not working properly.
Comment 11 Brent Fulgham 2015-04-02 20:46:01 PDT
Created attachment 250035 [details]
Patch
Comment 12 Brent Fulgham 2015-04-02 21:02:08 PDT
Created attachment 250036 [details]
Patch (No longer based on global state)
Comment 13 Brent Fulgham 2015-04-02 21:07:18 PDT
Comment on attachment 250036 [details]
Patch (No longer based on global state)

Revised version of the patch that tracks test state on the MainFrame, but only when the test system registers to monitor wheel events.
Comment 14 Build Bot 2015-04-02 21:49:33 PDT
Comment on attachment 250036 [details]
Patch (No longer based on global state)

Attachment 250036 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/4823346982158336

Number of test failures exceeded the failure limit.
Comment 15 Build Bot 2015-04-02 21:49:38 PDT
Created attachment 250038 [details]
Archive of layout-test-results from ews100 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 16 Build Bot 2015-04-02 21:53:34 PDT
Comment on attachment 250036 [details]
Patch (No longer based on global state)

Attachment 250036 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/6009453941882880

Number of test failures exceeded the failure limit.
Comment 17 Build Bot 2015-04-02 21:53:38 PDT
Created attachment 250039 [details]
Archive of layout-test-results from ews107 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 18 Brent Fulgham 2015-04-02 22:08:35 PDT
Comment on attachment 250036 [details]
Patch (No longer based on global state)

Looks like it's hitting some assertions I added to check for missing MainFram attachment. There must be another code path for constructing scroll animators I need to handle.
Comment 19 Brent Fulgham 2015-04-03 09:29:35 PDT
Created attachment 250078 [details]
Patch
Comment 20 Brent Fulgham 2015-04-03 09:31:55 PDT
Created attachment 250079 [details]
Patch
Comment 21 Brent Fulgham 2015-04-03 09:56:42 PDT
Created attachment 250083 [details]
Patch (Revised to correct test failure)
Comment 22 Brent Fulgham 2015-04-03 09:57:37 PDT
Comment on attachment 250083 [details]
Patch (Revised to correct test failure)

Corrected cause of 'fast/forms/search/search-scroll-hidden-decoration-container-crash.html' failure.
Comment 23 Build Bot 2015-04-03 10:48:21 PDT
Comment on attachment 250083 [details]
Patch (Revised to correct test failure)

Attachment 250083 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5320753788485632

New failing tests:
scrollbars/scrollevent-iframe-no-scrolling-wheel.html
Comment 24 Build Bot 2015-04-03 10:48:26 PDT
Created attachment 250089 [details]
Archive of layout-test-results from ews100 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 25 Brent Fulgham 2015-04-03 11:16:45 PDT
Created attachment 250090 [details]
Patch (Revised for non-Mac build failures, and documenting a test problem found by this work).
Comment 26 Brent Fulgham 2015-04-03 11:18:27 PDT
Comment on attachment 250090 [details]
Patch (Revised for non-Mac build failures, and documenting a test problem found by this work).

Correct the build errors encountered on iOS/EFL/GTK. Also mark the WK1 version of "scrollbars/scrollevent-iframe-no-scrolling-wheel.html" as failing. This is not a bug caused by this patch; the test is already wrong, the patch just added logging that identified the problem.
Comment 27 Brent Fulgham 2015-04-03 18:00:00 PDT
Created attachment 250112 [details]
Patch
Comment 28 Build Bot 2015-04-03 18:52:07 PDT
Comment on attachment 250112 [details]
Patch

Attachment 250112 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/6490975409012736

New failing tests:
scrollbars/scrollevent-iframe-no-scrolling-wheel.html
Comment 29 Build Bot 2015-04-03 18:52:11 PDT
Created attachment 250114 [details]
Archive of layout-test-results from ews101 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 30 Brent Fulgham 2015-04-06 08:59:28 PDT
Created attachment 250207 [details]
Patch
Comment 31 Brent Fulgham 2015-04-06 09:40:51 PDT
Created attachment 250208 [details]
Patch
Comment 32 Brent Fulgham 2015-04-06 10:21:55 PDT
Created attachment 250209 [details]
Patch (Correct iOS build)
Comment 33 Brent Fulgham 2015-04-06 11:33:47 PDT
Created attachment 250214 [details]
Patch Part 1: (Version has Another iOS fix)
Comment 34 Simon Fraser (smfr) 2015-04-10 11:52:17 PDT
Comment on attachment 250214 [details]
Patch Part 1: (Version has Another iOS fix)

View in context: https://bugs.webkit.org/attachment.cgi?id=250214&action=review

> Source/WebCore/page/MainFrame.cpp:53
> +    , m_testTrigger(nullptr)

No need to initialize a unique_ptr.

> Source/WebCore/page/MainFrame.cpp:129
> +WheelEventTestTrigger* MainFrame::testTrigger()

const ?

> Source/WebCore/page/MainFrame.cpp:138
> +WheelEventTestTrigger* MainFrame::initializeTestTrigger()
> +{
> +    m_testTrigger = std::make_unique<WheelEventTestTrigger>();
> +
> +    return m_testTrigger.get();

This is susceptible to doing the wrong thing if called more than once. Maybe ensureTestTrigger()?

> Source/WebCore/page/WheelEventTestTrigger.cpp:33
> +#include <JavaScriptCore/JSObjectRef.h>
> +#include <JavaScriptCore/JSRetainPtr.h>

Do you still need these?

> Source/WebCore/page/WheelEventTestTrigger.cpp:63
> +    std::lock_guard<std::mutex> lock(m_testTriggerMutex);
> +    m_testNotificationCallback = WTF::move(functionCallback);
> +    
> +    if (!m_testTriggerTimer.isActive())
> +        m_testTriggerTimer.startRepeating(1.0 / 60.0);
> +}

Seems odd to hold the lock over starting a timer. I think you need to be more explicit about what the lock is protecting (presumably just the m_deferTestTriggerReasons and callback? Or just m_deferTestTriggerReasons?

> Source/WebCore/page/WheelEventTestTrigger.cpp:92
> +    std::lock_guard<std::mutex> lock(m_testTriggerMutex);

Don't we use WTF::mutex etc?

> Source/WebCore/page/WheelEventTestTrigger.cpp:97
> +    if (m_testNotificationCallback)
> +        m_testNotificationCallback();

Do you really want to hold the lock over calling the callback?

> Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:577
> +void WKBundlePageMonitoringWheelEvents(WKBundlePageRef pageRef)

The name makes it sound like a getter "is the page monitoring wheel events?". Would be better as WKBundlePageStartMonitoringWheelEvents(), or WKBundlePageMonitoringScrollingSomething

> Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:588
> +void WKBundlePageRegisterTestNotificationCallback(WKBundlePageRef pageRef, WKBundlePageTestNotificationCallback callback, void* context)

What kind of test notification? Doesn't sound related to the previous thing; would be better as WKBundlePageRegisterScrollingSomethingCompletion
Comment 35 Brent Fulgham 2015-04-10 12:49:14 PDT
Comment on attachment 250214 [details]
Patch Part 1: (Version has Another iOS fix)

View in context: https://bugs.webkit.org/attachment.cgi?id=250214&action=review

>> Source/WebCore/page/MainFrame.cpp:53
>> +    , m_testTrigger(nullptr)
> 
> No need to initialize a unique_ptr.

OK!

>> Source/WebCore/page/MainFrame.cpp:129
>> +WheelEventTestTrigger* MainFrame::testTrigger()
> 
> const ?

OK!

>> Source/WebCore/page/MainFrame.cpp:138
>> +    return m_testTrigger.get();
> 
> This is susceptible to doing the wrong thing if called more than once. Maybe ensureTestTrigger()?

OK!

>> Source/WebCore/page/WheelEventTestTrigger.cpp:33
>> +#include <JavaScriptCore/JSRetainPtr.h>
> 
> Do you still need these?

Good point. I'll remove them.

>> Source/WebCore/page/WheelEventTestTrigger.cpp:63
>> +}
> 
> Seems odd to hold the lock over starting a timer. I think you need to be more explicit about what the lock is protecting (presumably just the m_deferTestTriggerReasons and callback? Or just m_deferTestTriggerReasons?

Yes. I think assignment of the callback should be protected as well, though maybe that's not as important.

I mainly want to avoid two threads trying to insert deferral reasons at the same time. It's probably not likely (or even possible) for two threads to update the notification callback, so maybe this lock isn't really warranted.

>> Source/WebCore/page/WheelEventTestTrigger.cpp:92
>> +    std::lock_guard<std::mutex> lock(m_testTriggerMutex);
> 
> Don't we use WTF::mutex etc?

Anders says use STL now.

>> Source/WebCore/page/WheelEventTestTrigger.cpp:97
>> +        m_testNotificationCallback();
> 
> Do you really want to hold the lock over calling the callback?

No.

>> Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:577
>> +void WKBundlePageMonitoringWheelEvents(WKBundlePageRef pageRef)
> 
> The name makes it sound like a getter "is the page monitoring wheel events?". Would be better as WKBundlePageStartMonitoringWheelEvents(), or WKBundlePageMonitoringScrollingSomething

OK. I like WKBundlePageStartMonitoringScrollOperations

>> Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:588
>> +void WKBundlePageRegisterTestNotificationCallback(WKBundlePageRef pageRef, WKBundlePageTestNotificationCallback callback, void* context)
> 
> What kind of test notification? Doesn't sound related to the previous thing; would be better as WKBundlePageRegisterScrollingSomethingCompletion

How about WKBundlePageRegisterScrollOperationCompletionCallback?
Comment 36 Brent Fulgham 2015-04-10 13:23:11 PDT
Created attachment 250529 [details]
Patch
Comment 37 Simon Fraser (smfr) 2015-04-13 10:52:50 PDT
Comment on attachment 250529 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=250529&action=review

> Source/WebCore/page/WheelEventTestTrigger.cpp:53
> +void WheelEventTestTrigger::setTestNotificationCallback(std::function<void()> functionCallback)

This name doesn't imply that it's going to start a timer, so perhaps a better name?

> Source/WebCore/page/WheelEventTestTrigger.cpp:55
> +    { // Limit scope of mutex

I don't think the comment is necessary.

> Source/WebCore/page/WheelEventTestTrigger.cpp:70
> +    auto it = m_deferTestTriggerReasons.find(key);
> +    if (it == m_deferTestTriggerReasons.end()) {
> +        m_deferTestTriggerReasons.add(key, std::set<DeferTestTriggerReason>());
> +        it = m_deferTestTriggerReasons.find(key);

You should just call add() and look at the AddResult.

> Source/WebCore/page/WheelEventTestTrigger.cpp:86
> +        m_deferTestTriggerReasons.remove(key);

Can't you remove with the it, to avoid another hash lookup?

> Source/WebCore/page/WheelEventTestTrigger.cpp:93
> +    { // Limit scope of mutex

No need for comment.

> Source/WebCore/page/WheelEventTestTrigger.h:54
> +    void deferTestsForReason(void* key, DeferTestTriggerReason);

Very unclear what the void* key should be here. Maybe a typedef with a better name? Can it be any token that just has to match the one passed to removeTestDeferralForReason?
Comment 38 Brent Fulgham 2015-04-13 17:06:16 PDT
Committed r182768: <http://trac.webkit.org/changeset/182768>
Comment 39 Brent Fulgham 2015-04-23 17:23:09 PDT
Reopening to attach new patch.
Comment 40 Brent Fulgham 2015-04-23 17:23:11 PDT
Created attachment 251515 [details]
Wrong Bug!
Comment 41 WebKit Commit Bot 2015-04-23 17:24:40 PDT
Attachment 251515 [details] did not pass style-queue:


ERROR: Source/WebCore/page/scrolling/ThreadedScrollingTree.h:61:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/page/scrolling/ScrollingTree.h:140:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/platform/ScrollAnimator.h:121:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
Total errors found: 3 in 28 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 42 Brent Fulgham 2015-04-24 09:00:43 PDT
Created attachment 251552 [details]
Wrong Bug!
Comment 43 Brent Fulgham 2015-04-24 10:27:28 PDT
Created attachment 251556 [details]
Wrong Bug
Comment 44 Brent Fulgham 2015-04-24 11:13:14 PDT
This was accidentally reopened when I used the wrong bug number in my patch.