-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathWKWebView+SEBEvaluateJavaScript.h
More file actions
30 lines (23 loc) · 1.09 KB
/
WKWebView+SEBEvaluateJavaScript.h
File metadata and controls
30 lines (23 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// WKWebView+SEBEvaluateJavaScript.h
// SafeExamBrowser
//
// Workaround for a crash in the Swift WebKit bindings on older macOS versions
// when the app is built with Xcode 16.3+. Routing all evaluateJavaScript calls
// through Objective-C avoids the faulty Swift stub.
//
#import <WebKit/WebKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKWebView (SEBEvaluateJavaScript)
/// Evaluate JavaScript, calling the optional completion handler with the result.
/// Pass nil for fire-and-forget calls.
- (void)seb_evaluateJavaScript:(NSString *)script
completionHandler:(void (^ _Nullable)(id _Nullable result, NSError * _Nullable error))completionHandler;
/// Evaluate JavaScript in a specific frame and content world (macOS 11 / iOS 14+).
- (void)seb_evaluateJavaScript:(NSString *)script
inFrame:(WKFrameInfo * _Nullable)frame
inContentWorld:(WKContentWorld *)contentWorld
completionHandler:(void (^ _Nullable)(id _Nullable result, NSError * _Nullable error))completionHandler
API_AVAILABLE(macos(11.0), ios(14.0));
@end
NS_ASSUME_NONNULL_END