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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 518583003: Don't take a fake UGI every time we execute Javascript. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix styling Created 6 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 | « content/public/browser/render_frame_host.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/public/test/browser_test_utils.h" 5 #include "content/public/test/browser_test_utils.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // |render_frame_host|. If |result| is not NULL, stores the value that the 102 // |render_frame_host|. If |result| is not NULL, stores the value that the
103 // evaluation of the script in |result|. Returns true on success. 103 // evaluation of the script in |result|. Returns true on success.
104 bool ExecuteScriptHelper(RenderFrameHost* render_frame_host, 104 bool ExecuteScriptHelper(RenderFrameHost* render_frame_host,
105 const std::string& original_script, 105 const std::string& original_script,
106 scoped_ptr<base::Value>* result) { 106 scoped_ptr<base::Value>* result) {
107 // TODO(jcampan): we should make the domAutomationController not require an 107 // TODO(jcampan): we should make the domAutomationController not require an
108 // automation id. 108 // automation id.
109 std::string script = 109 std::string script =
110 "window.domAutomationController.setAutomationId(0);" + original_script; 110 "window.domAutomationController.setAutomationId(0);" + original_script;
111 DOMOperationObserver dom_op_observer(render_frame_host->GetRenderViewHost()); 111 DOMOperationObserver dom_op_observer(render_frame_host->GetRenderViewHost());
112 render_frame_host->ExecuteJavaScript(base::UTF8ToUTF16(script)); 112 render_frame_host->ExecuteJavaScriptForTests(base::UTF8ToUTF16(script));
113 std::string json; 113 std::string json;
114 if (!dom_op_observer.WaitAndGetResponse(&json)) { 114 if (!dom_op_observer.WaitAndGetResponse(&json)) {
115 DLOG(ERROR) << "Cannot communicate with DOMOperationObserver."; 115 DLOG(ERROR) << "Cannot communicate with DOMOperationObserver.";
116 return false; 116 return false;
117 } 117 }
118 118
119 // Nothing more to do for callers that ignore the returned JS value. 119 // Nothing more to do for callers that ignore the returned JS value.
120 if (!result) 120 if (!result)
121 return true; 121 return true;
122 122
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 726 }
727 // The queue should not be empty, unless we were quit because of a timeout. 727 // The queue should not be empty, unless we were quit because of a timeout.
728 if (message_queue_.empty()) 728 if (message_queue_.empty())
729 return false; 729 return false;
730 *message = message_queue_.front(); 730 *message = message_queue_.front();
731 message_queue_.pop(); 731 message_queue_.pop();
732 return true; 732 return true;
733 } 733 }
734 734
735 } // namespace content 735 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/render_frame_host.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698