Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: ios/web/public/test/js_test_util.mm

Issue 2286773002: [ios] Use new JS execution API in browsing data partitioning test. (Closed)
Patch Set: Make GetLocalStorageItem return id. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/web/public/test/js_test_util.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/public/test/js_test_util.h" 5 #import "ios/web/public/test/js_test_util.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #import "base/logging.h" 9 #import "base/logging.h"
10 #import "base/mac/scoped_nsobject.h" 10 #import "base/mac/scoped_nsobject.h"
(...skipping 19 matching lines...) Expand all
30 return [[result retain] autorelease]; 30 return [[result retain] autorelease];
31 } 31 }
32 32
33 id ExecuteJavaScript(CRWJSInjectionReceiver* receiver, NSString* script) { 33 id ExecuteJavaScript(CRWJSInjectionReceiver* receiver, NSString* script) {
34 base::scoped_nsobject<CRWJSInjectionManager> manager( 34 base::scoped_nsobject<CRWJSInjectionManager> manager(
35 [[CRWJSInjectionManager alloc] initWithReceiver:receiver]); 35 [[CRWJSInjectionManager alloc] initWithReceiver:receiver]);
36 return ExecuteJavaScript(manager, script); 36 return ExecuteJavaScript(manager, script);
37 } 37 }
38 38
39 id ExecuteJavaScript(WKWebView* web_view, NSString* script) { 39 id ExecuteJavaScript(WKWebView* web_view, NSString* script) {
40 return ExecuteJavaScript(web_view, script, nullptr);
41 }
42
43 id ExecuteJavaScript(WKWebView* web_view, NSString* script, NSError** error) {
40 __block base::scoped_nsobject<id> result; 44 __block base::scoped_nsobject<id> result;
41 __block bool completed = false; 45 __block bool completed = false;
42 [web_view evaluateJavaScript:script 46 [web_view evaluateJavaScript:script
43 completionHandler:^(id evaluation_result, NSError* error) { 47 completionHandler:^(id script_result, NSError* script_error) {
44 DCHECK(!error); 48 result.reset([script_result copy]);
45 result.reset([evaluation_result copy]); 49 if (error)
50 *error = [[script_error copy] autorelease];
46 completed = true; 51 completed = true;
47 }]; 52 }];
48 base::test::ios::WaitUntilCondition(^{ 53 base::test::ios::WaitUntilCondition(^{
49 return completed; 54 return completed;
50 }); 55 });
51 return [[result retain] autorelease]; 56 return [[result retain] autorelease];
52 } 57 }
53 58
54 } // namespace web 59 } // namespace web
55 60
OLDNEW
« no previous file with comments | « ios/web/public/test/js_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698