Chromium Code Reviews| Index: ios/web/web_state/ui/crw_web_controller.mm |
| diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm |
| index 847c3a69eda9aae9ed46f97cf7d3793afc5ef224..b48615c6ee3d71fa2b7f31a2bcfbf267bd16a05b 100644 |
| --- a/ios/web/web_state/ui/crw_web_controller.mm |
| +++ b/ios/web/web_state/ui/crw_web_controller.mm |
| @@ -2523,9 +2523,21 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5; |
| // an umbrella manager). |
| if ([script length]) { |
| // Every injection except windowID requires windowID check. |
| - if (JSInjectionManagerClass != [CRWJSWindowIdManager class]) |
| + if (JSInjectionManagerClass != [CRWJSWindowIdManager class]) { |
| script = [self scriptByAddingWindowIDCheckForScript:script]; |
| - web::ExecuteJavaScript(_webView, script, nil); |
| + web::ExecuteJavaScript(_webView, script, nil); |
| + } else { |
| + web::ExecuteJavaScript(_webView, script, ^(id, NSError* error) { |
| + // TODO(crbug.com/628832): Refactor retry logic. |
| + if (error.code == WKErrorJavaScriptExceptionOccurred) { |
| + // This can happen if WKUserScript has not been injected yet. |
|
kkhorimoto
2016/07/18 18:29:36
There are other reasons why we can get an exceptio
Eugene But (OOO till 7-30)
2016/07/18 18:43:09
The other reason is a bug inside window_id.js, but
|
| + // Retry if that's the case, because windowID injection is critical |
| + // for the system to function. |
| + [_injectedScriptManagers removeObject:JSInjectionManagerClass]; |
| + [self injectWindowID]; |
| + } |
| + }); |
| + } |
| } |
| [_injectedScriptManagers addObject:JSInjectionManagerClass]; |
| } |