OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/public/test/earl_grey/js_test_util.h" | 5 #import "ios/web/public/test/earl_grey/js_test_util.h" |
6 | 6 |
7 #import <EarlGrey/EarlGrey.h> | 7 #import <EarlGrey/EarlGrey.h> |
8 #import <WebKit/WebKit.h> | 8 #import <WebKit/WebKit.h> |
9 | 9 |
10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return [result autorelease]; | 77 return [result autorelease]; |
78 } | 78 } |
79 | 79 |
80 id ExecuteScriptOnInterstitial(WebState* web_state, NSString* script) { | 80 id ExecuteScriptOnInterstitial(WebState* web_state, NSString* script) { |
81 web::WebInterstitialImpl* interstitial = | 81 web::WebInterstitialImpl* interstitial = |
82 static_cast<web::WebInterstitialImpl*>(web_state->GetWebInterstitial()); | 82 static_cast<web::WebInterstitialImpl*>(web_state->GetWebInterstitial()); |
83 | 83 |
84 __block id script_result = nil; | 84 __block id script_result = nil; |
85 __block bool did_finish = false; | 85 __block bool did_finish = false; |
86 web::ExecuteScriptForTesting(interstitial, script, ^(id result, NSError*) { | 86 web::ExecuteScriptForTesting(interstitial, script, ^(id result, NSError*) { |
87 script_result = [[result copy] autorelease]; | 87 script_result = [result copy]; |
88 did_finish = true; | 88 did_finish = true; |
89 }); | 89 }); |
90 BOOL suceeded = WaitUntilConditionOrTimeout(kWaitForJSCompletionTimeout, ^{ | 90 BOOL suceeded = WaitUntilConditionOrTimeout(kWaitForJSCompletionTimeout, ^{ |
91 return did_finish; | 91 return did_finish; |
92 }); | 92 }); |
93 GREYAssert(suceeded, @"Script execution timed out"); | 93 GREYAssert(suceeded, @"Script execution timed out"); |
94 return script_result; | 94 return [script_result autorelease]; |
95 } | 95 } |
96 | 96 |
97 } // namespace web | 97 } // namespace web |
OLD | NEW |