| Index: ios/web/web_state/js/crw_js_window_id_manager_unittest.mm
|
| diff --git a/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm b/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm
|
| index a6655fbb46a62a85c7008fae7baaba05380a7d3f..41463aa61cb67fa90bd35956674fcc704cde62d1 100644
|
| --- a/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm
|
| +++ b/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm
|
| @@ -6,18 +6,26 @@
|
|
|
| #import <WebKit/WebKit.h>
|
|
|
| +#include "ios/web/public/test/fakes/test_browser_state.h"
|
| #import "ios/web/public/test/js_test_util.h"
|
| #import "ios/web/web_state/js/page_script_util.h"
|
| #import "testing/gtest_mac.h"
|
| +#import "testing/platform_test.h"
|
|
|
| namespace web {
|
|
|
| +// Test fixture for testing CRWJSWindowIDManager class.
|
| +class JSWindowIDManagerTest : public PlatformTest {
|
| + protected:
|
| + TestBrowserState browser_state_;
|
| +};
|
| +
|
| // Tests that window ID injection by a second manager results in a different
|
| // window ID.
|
| -TEST(JSWindowIDManagerTest, WindowIDDifferentManager) {
|
| +TEST_F(JSWindowIDManagerTest, WindowIDDifferentManager) {
|
| // Inject the first manager.
|
| WKWebView* web_view = [[[WKWebView alloc] init] autorelease];
|
| - ExecuteJavaScript(web_view, GetEarlyPageScript());
|
| + ExecuteJavaScript(web_view, GetEarlyPageScript(&browser_state_));
|
|
|
| CRWJSWindowIDManager* manager =
|
| [[[CRWJSWindowIDManager alloc] initWithWebView:web_view] autorelease];
|
| @@ -27,7 +35,7 @@ TEST(JSWindowIDManagerTest, WindowIDDifferentManager) {
|
|
|
| // Inject the second manager.
|
| WKWebView* web_view2 = [[[WKWebView alloc] init] autorelease];
|
| - ExecuteJavaScript(web_view2, GetEarlyPageScript());
|
| + ExecuteJavaScript(web_view2, GetEarlyPageScript(&browser_state_));
|
|
|
| CRWJSWindowIDManager* manager2 =
|
| [[[CRWJSWindowIDManager alloc] initWithWebView:web_view2] autorelease];
|
| @@ -40,9 +48,9 @@ TEST(JSWindowIDManagerTest, WindowIDDifferentManager) {
|
| }
|
|
|
| // Tests that injecting multiple times creates a new window ID.
|
| -TEST(JSWindowIDManagerTest, MultipleInjections) {
|
| +TEST_F(JSWindowIDManagerTest, MultipleInjections) {
|
| WKWebView* web_view = [[[WKWebView alloc] init] autorelease];
|
| - ExecuteJavaScript(web_view, GetEarlyPageScript());
|
| + ExecuteJavaScript(web_view, GetEarlyPageScript(&browser_state_));
|
|
|
| // First injection.
|
| CRWJSWindowIDManager* manager =
|
| @@ -61,7 +69,7 @@ TEST(JSWindowIDManagerTest, MultipleInjections) {
|
| }
|
|
|
| // Tests that injection will retry if |window.__gCrWeb| is not present.
|
| -TEST(JSWindowIDManagerTest, InjectionRetry) {
|
| +TEST_F(JSWindowIDManagerTest, InjectionRetry) {
|
| WKWebView* web_view = [[[WKWebView alloc] init] autorelease];
|
|
|
| CRWJSWindowIDManager* manager =
|
| @@ -71,7 +79,7 @@ TEST(JSWindowIDManagerTest, InjectionRetry) {
|
| EXPECT_FALSE(ExecuteJavaScript(web_view, @"window.__gCrWeb"));
|
|
|
| // Now inject window.__gCrWeb and check if window ID injection retried.
|
| - ExecuteJavaScript(web_view, GetEarlyPageScript());
|
| + ExecuteJavaScript(web_view, GetEarlyPageScript(&browser_state_));
|
| EXPECT_NSEQ([manager windowID],
|
| ExecuteJavaScript(web_view, @"window.__gCrWeb.windowId"));
|
| }
|
|
|