Skip to content

Commit e81020a

Browse files
Throw Exception when test doesn't clean up HID Events properly
https://bugs.webkit.org/show_bug.cgi?id=166271 Patch by Megan Gardner <[email protected]> on 2016-12-20 Reviewed by Simon Fraser. Add in a check when UIScriptController is deleted to make sure that the HID event callback dictionary is empty. If it is not, and a HID event is hit, this will cause the program to crash without any good information. Crashes are race-y, and will still happen with malformed test, but the information will be much more helpful. * DumpRenderTree/ios/UIScriptControllerIOS.mm: (WTR::UIScriptController::checkForClean): * TestRunnerShared/UIScriptContext/UIScriptContext.cpp: (UIScriptContext::~UIScriptContext): * TestRunnerShared/UIScriptContext/UIScriptController.cpp: (WTR::UIScriptController::checkForClean): * TestRunnerShared/UIScriptContext/UIScriptController.h: * WebKitTestRunner/ios/HIDEventGenerator.h: * WebKitTestRunner/ios/HIDEventGenerator.mm: (-[HIDEventGenerator checkHIDCallbacksClear]): * WebKitTestRunner/ios/TestControllerIOS.mm: * WebKitTestRunner/ios/UIScriptControllerIOS.mm: (WTR::UIScriptController::checkForClean): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@210048 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent c2fe277 commit e81020a

File tree

9 files changed

+51
-0
lines changed

9 files changed

+51
-0
lines changed

Tools/ChangeLog

+26
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
2016-12-20 Megan Gardner <[email protected]>
2+
3+
Throw Exception when test doesn't clean up HID Events properly
4+
https://bugs.webkit.org/show_bug.cgi?id=166271
5+
6+
Reviewed by Simon Fraser.
7+
8+
Add in a check when UIScriptController is deleted to make sure that the HID event
9+
callback dictionary is empty. If it is not, and a HID event is hit, this will cause
10+
the program to crash without any good information. Crashes are race-y, and will still
11+
happen with malformed test, but the information will be much more helpful.
12+
13+
* DumpRenderTree/ios/UIScriptControllerIOS.mm:
14+
(WTR::UIScriptController::checkForClean):
15+
* TestRunnerShared/UIScriptContext/UIScriptContext.cpp:
16+
(UIScriptContext::~UIScriptContext):
17+
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
18+
(WTR::UIScriptController::checkForClean):
19+
* TestRunnerShared/UIScriptContext/UIScriptController.h:
20+
* WebKitTestRunner/ios/HIDEventGenerator.h:
21+
* WebKitTestRunner/ios/HIDEventGenerator.mm:
22+
(-[HIDEventGenerator checkHIDCallbacksClear]):
23+
* WebKitTestRunner/ios/TestControllerIOS.mm:
24+
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
25+
(WTR::UIScriptController::checkForClean):
26+
127
2016-12-20 Andy Estes <[email protected]>
228

329
[Cocoa] REGRESSION (r209558): Calling decisionHandler multiple times in webView:decidePolicyForNavigationAction:decisionHandler: leads to a crash

Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
extern DumpRenderTreeWebScrollView *gWebScrollView;
3838

3939
namespace WTR {
40+
41+
void UIScriptController::checkForOutstandingCallbacks()
42+
{
43+
}
4044

4145
void UIScriptController::doAsyncTask(JSValueRef callback)
4246
{

Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ UIScriptContext::UIScriptContext(UIScriptContextDelegate& delegate)
5252

5353
UIScriptContext::~UIScriptContext()
5454
{
55+
m_controller->checkForOutstandingCallbacks();
5556
m_controller->contextDestroyed();
5657
}
5758

Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ UIScriptController::UIScriptController(UIScriptContext& context)
3737
{
3838
}
3939

40+
#if !PLATFORM(IOS)
41+
void UIScriptController::checkForOutstandingCallbacks()
42+
{
43+
}
44+
#endif
45+
4046
void UIScriptController::contextDestroyed()
4147
{
4248
m_context = nullptr;

Tools/TestRunnerShared/UIScriptContext/UIScriptController.h

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class UIScriptController : public JSWrappable {
4747
}
4848

4949
void contextDestroyed();
50+
void checkForOutstandingCallbacks();
5051

5152
void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
5253

Tools/WebKitTestRunner/ios/HIDEventGenerator.h

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ extern NSString* const HIDEventPhaseCanceled;
9898
- (void)sendEventStream:(NSDictionary *)eventInfo completionBlock:(void (^)(void))completionBlock;
9999

100100
- (void)markerEventReceived:(IOHIDEventRef)event;
101+
- (BOOL)checkForOutstandingCallbacks;
101102

102103
// Keyboard
103104
- (void)keyPress:(NSString *)character completionBlock:(void (^)(void))completionBlock;

Tools/WebKitTestRunner/ios/HIDEventGenerator.mm

+5
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,11 @@ - (void)markerEventReceived:(IOHIDEventRef)event
769769
}
770770
}
771771

772+
- (BOOL)checkForOutstandingCallbacks
773+
{
774+
return !([_eventCallbacks count] > 0);
775+
}
776+
772777
static inline bool shouldWrapWithShiftKeyEventForCharacter(NSString *key)
773778
{
774779
if (key.length != 1)

Tools/WebKitTestRunner/ios/TestControllerIOS.mm

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#import "config.h"
2727
#import "TestController.h"
2828

29+
#import "HIDEventGenerator.h"
2930
#import "PlatformWebView.h"
3031
#import "TestInvocation.h"
3132
#import "TestRunnerWKWebView.h"

Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
@"height": @(rect.size.height)
5454
};
5555
}
56+
57+
void UIScriptController::checkForOutstandingCallbacks()
58+
{
59+
if (![[HIDEventGenerator sharedHIDEventGenerator] checkForOutstandingCallbacks])
60+
[NSException raise:@"WebKitTestRunnerTestProblem" format:@"The test completed before all synthesized events had been handled. Perhaps you're calling notifyDone() too early?"];
61+
}
5662

5763
void UIScriptController::doAsyncTask(JSValueRef callback)
5864
{

0 commit comments

Comments
 (0)