Skip to content
Permalink
Browse files
Web Automation: add SPI to mark an existing NSEvent as synthesized fo…
…r automation

https://bugs.webkit.org/show_bug.cgi?id=157221
<rdar://problem/26019356>

Reviewed by Timothy Hatcher.

In cases where an NSEvent is duplicated, clients need to re-mark an NSEvent
as synthesized for automation if the original NSEvent was marked as such.

* UIProcess/API/Cocoa/_WKAutomationSession.h:
* UIProcess/API/Cocoa/_WKAutomationSession.mm:
(-[_WKAutomationSession markEventAsSynthesizedForAutomation:]):
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Cocoa/WebAutomationSessionCocoa.mm:
(WebKit::WebAutomationSession::sendSynthesizedEventsToPage):
(WebKit::WebAutomationSession::markEventAsSynthesizedForAutomation):


Canonical link: https://commits.webkit.org/175320@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200280 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
burg committed Apr 30, 2016
1 parent 2c1b26e commit eace62777d9adecf370835f557fa23c8c002e8ab
@@ -1,3 +1,22 @@
2016-04-29 Brian Burg <bburg@apple.com>

Web Automation: add SPI to mark an existing NSEvent as synthesized for automation
https://bugs.webkit.org/show_bug.cgi?id=157221
<rdar://problem/26019356>

Reviewed by Timothy Hatcher.

In cases where an NSEvent is duplicated, clients need to re-mark an NSEvent
as synthesized for automation if the original NSEvent was marked as such.

* UIProcess/API/Cocoa/_WKAutomationSession.h:
* UIProcess/API/Cocoa/_WKAutomationSession.mm:
(-[_WKAutomationSession markEventAsSynthesizedForAutomation:]):
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Cocoa/WebAutomationSessionCocoa.mm:
(WebKit::WebAutomationSession::sendSynthesizedEventsToPage):
(WebKit::WebAutomationSession::markEventAsSynthesizedForAutomation):

2016-04-29 Brian Burg <bburg@apple.com>

Web Automation: use a magic eventNumber as a fallback for detecting NSEvents synthesized for automation
@@ -42,6 +42,7 @@ WK_CLASS_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA)

#if !TARGET_OS_IPHONE
- (BOOL)wasEventSynthesizedForAutomation:(NSEvent *)event;
- (void)markEventAsSynthesizedForAutomation:(NSEvent *)event;
#endif

@end
@@ -88,6 +88,11 @@ - (BOOL)wasEventSynthesizedForAutomation:(NSEvent *)event
{
return _session->wasEventSynthesizedForAutomation(event);
}

- (void)markEventAsSynthesizedForAutomation:(NSEvent *)event
{
_session->markEventAsSynthesizedForAutomation(event);
}
#endif

#pragma mark WKObject protocol implementation
@@ -122,6 +122,7 @@ class WebAutomationSession final : public API::ObjectImpl<API::Object::Type::Aut
void deleteAllCookies(Inspector::ErrorString&, const String& browsingContextHandle, Ref<DeleteAllCookiesCallback>&&) override;
#if USE(APPKIT)
bool wasEventSynthesizedForAutomation(NSEvent *);
void markEventAsSynthesizedForAutomation(NSEvent *);
#endif

private:
@@ -51,11 +51,16 @@
NSWindow *window = page.platformWindow();

for (NSEvent *event in eventsToSend) {
objc_setAssociatedObject(event, &synthesizedAutomationEventAssociatedObjectKey, m_sessionIdentifier, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
markEventAsSynthesizedForAutomation(event);
[window sendEvent:event];
}
}

void WebAutomationSession::markEventAsSynthesizedForAutomation(NSEvent *event)
{
objc_setAssociatedObject(event, &synthesizedAutomationEventAssociatedObjectKey, m_sessionIdentifier, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

bool WebAutomationSession::wasEventSynthesizedForAutomation(NSEvent *event)
{
NSString *senderSessionIdentifier = objc_getAssociatedObject(event, &synthesizedAutomationEventAssociatedObjectKey);

0 comments on commit eace627

Please sign in to comment.