blob: b4a35501592fb5fcd3d1edb98bf22ca1d51faec3 [file] [log] [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_TEST_JS_TEST_UTIL_INTERNAL_H_
#define IOS_WEB_TEST_JS_TEST_UTIL_INTERNAL_H_
#import <Foundation/Foundation.h>
#import <WebKit/WebKit.h>
namespace web {
namespace test {
// NOTE: The following accept a pointer to a `WKContentWorld`. However, tests
// should generally not deal with raw WKContentWorlds. Instead, prefer
// specifying the associated JavaScriptFeature instance using
// WebTestWithWebState::ExecuteJavaScriptForFeature.
// Synchronously executes `script` in `content_world` and waits for the
// execution to complete.
void ExecuteJavaScriptInWebViewAndWorld(WKWebView* web_view,
WKContentWorld* content_world,
NSString* script);
// Synchronously executes `script` in `content_world` and returns result.
[[nodiscard]] id ExecuteJavaScript(WKWebView* web_view,
WKContentWorld* content_world,
NSString* script);
// Executes `script` in `content_world` as an asynchronous JavaScript function,
// waits for execution to complete, and returns the result.
[[nodiscard]] id ExecuteAsyncJavaScript(WKWebView* web_view,
WKContentWorld* content_world,
NSString* script);
} // namespace test
} // namespace web
#endif // IOS_WEB_TEST_JS_TEST_UTIL_INTERNAL_H_