Chromium Code Reviews| Index: ios/web/web_state/js/crw_js_window_id_manager_unittest.mm |
| diff --git a/ios/web/public/web_state/js/crw_js_window_id_manager_unittest.mm b/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm |
| similarity index 74% |
| rename from ios/web/public/web_state/js/crw_js_window_id_manager_unittest.mm |
| rename to ios/web/web_state/js/crw_js_window_id_manager_unittest.mm |
| index 4abc76abdda1b41e179327ff3ff3147262ec8a47..301d25078c3bd9be9c8ff9d0fc7818180a69c96c 100644 |
| --- a/ios/web/public/web_state/js/crw_js_window_id_manager_unittest.mm |
| +++ b/ios/web/web_state/js/crw_js_window_id_manager_unittest.mm |
| @@ -10,6 +10,19 @@ |
| #import "testing/gtest_mac.h" |
| #include "testing/platform_test.h" |
| +// Test Window ID Manager with the ability to bypass hasBeenInjected check in |
| +// the inject method. |
| +@interface CRWTestJSWindowIdManager : CRWJSWindowIdManager |
| +// Inject script, bypassing hasBeenInjected check. |
| +- (void)forceInject; |
| +@end |
| + |
| +@implementation CRWTestJSWindowIdManager |
| +- (void)forceInject { |
|
Eugene But (OOO till 7-30)
2015/05/09 16:40:37
The fact that second injection does not happen is
Jackie Quinn
2015/05/11 18:21:33
Just changing the beacon won't do anything for WKW
Jackie Quinn
2015/05/12 17:04:38
As discussed offline, changing the presence beacon
|
| + [[self receiver] injectScript:[self injectionContent] forClass:[self class]]; |
| +} |
| +@end |
| + |
| namespace { |
| class JSWindowIDManagerTest : public PlatformTest { |
| @@ -17,7 +30,8 @@ class JSWindowIDManagerTest : public PlatformTest { |
| void SetUp() override { |
| PlatformTest::SetUp(); |
| receiver_.reset([[CRWTestJSInjectionReceiver alloc] init]); |
| - manager_.reset([[CRWJSWindowIdManager alloc] initWithReceiver:receiver_]); |
| + manager_.reset( |
| + [[CRWTestJSWindowIdManager alloc] initWithReceiver:receiver_]); |
| web::SetWebClient(&web_client_); |
| } |
| void TearDown() override { |
| @@ -27,20 +41,19 @@ class JSWindowIDManagerTest : public PlatformTest { |
| // Required for CRWJSWindowIdManager creation. |
| base::scoped_nsobject<CRWTestJSInjectionReceiver> receiver_; |
| // Testable CRWJSWindowIdManager. |
| - base::scoped_nsobject<CRWJSWindowIdManager> manager_; |
| + base::scoped_nsobject<CRWTestJSWindowIdManager> manager_; |
| // WebClient required for getting early page script, which must be injected |
| // before CRWJSWindowIdManager. |
| web::WebClient web_client_; |
| }; |
| -// TODO(jyquinn): enable this test (crbug.com/465898). |
| -TEST_F(JSWindowIDManagerTest, DISABLED_WindowID) { |
| +TEST_F(JSWindowIDManagerTest, WindowID) { |
|
Eugene But (OOO till 7-30)
2015/05/09 16:40:37
NIT: Let's take a chance to add a comment for this
Jackie Quinn
2015/05/12 17:04:37
Done.
|
| EXPECT_TRUE(manager_.get()); |
| [manager_ inject]; |
| NSString* windowID = [manager_ windowId]; |
| EXPECT_EQ(32U, [windowID length]); |
| // Inject a second time to check that the ID is different. |
| - [manager_ inject]; |
| + [manager_ forceInject]; |
| NSString* windowID2 = [manager_ windowId]; |
| EXPECT_FALSE([windowID isEqualToString:windowID2]); |
| } |