Index: ios/web/public/test/web_js_test.h |
diff --git a/ios/web/public/test/web_js_test.h b/ios/web/public/test/web_js_test.h |
index 3785b05ecebf4f475a51263d5ab19e870cd4b5c0..74550e4de0784e1929b62adaee6b0345717b43c1 100644 |
--- a/ios/web/public/test/web_js_test.h |
+++ b/ios/web/public/test/web_js_test.h |
@@ -20,7 +20,7 @@ |
class WebJsTest : public WebTestT { |
public: |
WebJsTest(NSArray* java_script_paths) |
- : java_script_paths_([java_script_paths copy]) {} |
+ : java_script_paths_([java_script_paths retain]) {} |
protected: |
// Loads |html| and inject JavaScripts at |javaScriptPaths_|. |
@@ -60,10 +60,11 @@ |
template <class WebTestT> |
void WebJsTest<WebTestT>::Inject() { |
- // Main web injection should have occured. |
- DCHECK_NSEQ(@"object", |
- WebTestT::EvaluateJavaScriptAsString(@"typeof __gCrWeb")); |
- |
+ // Wait until main web injection has occured. |
+ NSString* beacon = nil; |
+ do { |
+ beacon = WebTestT::EvaluateJavaScriptAsString(@"typeof __gCrWeb"); |
+ } while (![beacon isEqualToString:@"object"]); |
for (NSString* java_script_path in java_script_paths_.get()) { |
NSString* path = |
[base::mac::FrameworkBundle() pathForResource:java_script_path |