OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/web/web_state/js/crw_js_early_script_manager.h" | 5 #import "ios/web/web_state/js/crw_js_early_script_manager.h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #import "ios/web/public/test/crw_test_js_injection_receiver.h" | 8 #import "ios/web/public/test/crw_test_js_injection_receiver.h" |
9 #include "ios/web/public/web_client.h" | 9 #include "ios/web/public/web_client.h" |
10 #import "ios/web/web_state/js/page_script_util.h" | 10 #import "ios/web/web_state/js/page_script_util.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 }; | 36 }; |
37 | 37 |
38 // Tests that CRWJSEarlyScriptManager's content is the same as returned by | 38 // Tests that CRWJSEarlyScriptManager's content is the same as returned by |
39 // web::GetEarlyPageScript. | 39 // web::GetEarlyPageScript. |
40 TEST_F(CRWJSEarlyScriptManagerTest, Content) { | 40 TEST_F(CRWJSEarlyScriptManagerTest, Content) { |
41 NSString* injectionContent = [earlyScriptManager_ staticInjectionContent]; | 41 NSString* injectionContent = [earlyScriptManager_ staticInjectionContent]; |
42 NSString* earlyScript = GetEarlyPageScript([receiver_ webViewType]); | 42 NSString* earlyScript = GetEarlyPageScript([receiver_ webViewType]); |
43 // |earlyScript| is a substring of |injectionContent|. The latter wraps the | 43 // |earlyScript| is a substring of |injectionContent|. The latter wraps the |
44 // former with "if (typeof __gCrWeb !== 'object')" check to avoid multiple | 44 // former with "if (typeof __gCrWeb !== 'object')" check to avoid multiple |
45 // injections. | 45 // injections. |
46 EXPECT_NE(NSNotFound, [injectionContent rangeOfString:earlyScript].location); | 46 // TODO(justincohen): Cast indexOfObject to work around Xcode beta bugs. |
| 47 // Revisit in future betas where hopefully these types match again. |
| 48 // crbug.com/498825 |
| 49 EXPECT_NE(NSNotFound, |
| 50 static_cast<NSInteger>( |
| 51 [injectionContent rangeOfString:earlyScript].location)); |
47 } | 52 } |
48 | 53 |
49 } // namespace | 54 } // namespace |
50 } // namespace web | 55 } // namespace web |
OLD | NEW |