- Revision
- 210048
- Author
- commit-qu...@webkit.org
- Date
- 2016-12-20 17:10:28 -0800 (Tue, 20 Dec 2016)
Log Message
Throw Exception when test doesn't clean up HID Events properly
https://bugs.webkit.org/show_bug.cgi?id=166271
Patch by Megan Gardner <megan_gard...@apple.com> 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):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (210047 => 210048)
--- trunk/Tools/ChangeLog 2016-12-21 00:29:36 UTC (rev 210047)
+++ trunk/Tools/ChangeLog 2016-12-21 01:10:28 UTC (rev 210048)
@@ -1,3 +1,29 @@
+2016-12-20 Megan Gardner <megan_gard...@apple.com>
+
+ Throw Exception when test doesn't clean up HID Events properly
+ https://bugs.webkit.org/show_bug.cgi?id=166271
+
+ 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):
+
2016-12-20 Andy Estes <aes...@apple.com>
[Cocoa] REGRESSION (r209558): Calling decisionHandler multiple times in webView:decidePolicyForNavigationAction:decisionHandler: leads to a crash
Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (210047 => 210048)
--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm 2016-12-21 00:29:36 UTC (rev 210047)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm 2016-12-21 01:10:28 UTC (rev 210048)
@@ -37,6 +37,10 @@
extern DumpRenderTreeWebScrollView *gWebScrollView;
namespace WTR {
+
+void UIScriptController::checkForOutstandingCallbacks()
+{
+}
void UIScriptController::doAsyncTask(JSValueRef callback)
{
Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp (210047 => 210048)
--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp 2016-12-21 00:29:36 UTC (rev 210047)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptContext.cpp 2016-12-21 01:10:28 UTC (rev 210048)
@@ -52,6 +52,7 @@
UIScriptContext::~UIScriptContext()
{
+ m_controller->checkForOutstandingCallbacks();
m_controller->contextDestroyed();
}
Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (210047 => 210048)
--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp 2016-12-21 00:29:36 UTC (rev 210047)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp 2016-12-21 01:10:28 UTC (rev 210048)
@@ -37,6 +37,12 @@
{
}
+#if !PLATFORM(IOS)
+void UIScriptController::checkForOutstandingCallbacks()
+{
+}
+#endif
+
void UIScriptController::contextDestroyed()
{
m_context = nullptr;
Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (210047 => 210048)
--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h 2016-12-21 00:29:36 UTC (rev 210047)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h 2016-12-21 01:10:28 UTC (rev 210048)
@@ -47,6 +47,7 @@
}
void contextDestroyed();
+ void checkForOutstandingCallbacks();
void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception);
Modified: trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.h (210047 => 210048)
--- trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.h 2016-12-21 00:29:36 UTC (rev 210047)
+++ trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.h 2016-12-21 01:10:28 UTC (rev 210048)
@@ -98,6 +98,7 @@
- (void)sendEventStream:(NSDictionary *)eventInfo completionBlock:(void (^)(void))completionBlock;
- (void)markerEventReceived:(IOHIDEventRef)event;
+- (BOOL)checkForOutstandingCallbacks;
// Keyboard
- (void)keyPress:(NSString *)character completionBlock:(void (^)(void))completionBlock;
Modified: trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm (210047 => 210048)
--- trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm 2016-12-21 00:29:36 UTC (rev 210047)
+++ trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm 2016-12-21 01:10:28 UTC (rev 210048)
@@ -769,6 +769,11 @@
}
}
+- (BOOL)checkForOutstandingCallbacks
+{
+ return !([_eventCallbacks count] > 0);
+}
+
static inline bool shouldWrapWithShiftKeyEventForCharacter(NSString *key)
{
if (key.length != 1)
Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (210047 => 210048)
--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm 2016-12-21 00:29:36 UTC (rev 210047)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm 2016-12-21 01:10:28 UTC (rev 210048)
@@ -26,6 +26,7 @@
#import "config.h"
#import "TestController.h"
+#import "HIDEventGenerator.h"
#import "PlatformWebView.h"
#import "TestInvocation.h"
#import "TestRunnerWKWebView.h"
Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (210047 => 210048)
--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm 2016-12-21 00:29:36 UTC (rev 210047)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm 2016-12-21 01:10:28 UTC (rev 210048)
@@ -53,6 +53,12 @@
@"height": @(rect.size.height)
};
}
+
+void UIScriptController::checkForOutstandingCallbacks()
+{
+ if (![[HIDEventGenerator sharedHIDEventGenerator] checkForOutstandingCallbacks])
+ [NSException raise:@"WebKitTestRunnerTestProblem" format:@"The test completed before all synthesized events had been handled. Perhaps you're calling notifyDone() too early?"];
+}
void UIScriptController::doAsyncTask(JSValueRef callback)
{