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

Side by Side Diff: chrome/test/chromedriver/session_commands.cc

Issue 15393005: [chromedriver] Remove unnecessary round trips to Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/test/chromedriver/session_commands.h" 5 #include "chrome/test/chromedriver/session_commands.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 Session* session, 282 Session* session,
283 const base::DictionaryValue& params, 283 const base::DictionaryValue& params,
284 scoped_ptr<base::Value>* value) { 284 scoped_ptr<base::Value>* value) {
285 double ms; 285 double ms;
286 if (!params.GetDouble("ms", &ms) || ms < 0) 286 if (!params.GetDouble("ms", &ms) || ms < 0)
287 return Status(kUnknownError, "'ms' must be a non-negative number"); 287 return Status(kUnknownError, "'ms' must be a non-negative number");
288 session->implicit_wait = static_cast<int>(ms); 288 session->implicit_wait = static_cast<int>(ms);
289 return Status(kOk); 289 return Status(kOk);
290 } 290 }
291 291
292 Status ExecuteAlertCommand(
293 const SessionCommand& alert_command,
294 Session* session,
295 const base::DictionaryValue& params,
296 scoped_ptr<base::Value>* value) {
297 WebView* web_view = NULL;
298 Status status = session->GetTargetWindow(&web_view);
299 if (status.IsError())
300 return status;
301
302 status = web_view->ConnectIfNecessary();
303 if (status.IsError())
304 return status;
305
306 status = web_view->WaitForPendingNavigations(session->GetCurrentFrameId());
307 if (status.IsError() && status.code() != kUnexpectedAlertOpen)
308 return status;
309
310 return alert_command.Run(session, params, value);
311 }
312
313 Status ExecuteGetAlert(
314 Session* session,
315 const base::DictionaryValue& params,
316 scoped_ptr<base::Value>* value) {
317 bool is_open;
318 Status status = session->chrome->IsJavaScriptDialogOpen(&is_open);
319 if (status.IsError())
320 return status;
321 value->reset(base::Value::CreateBooleanValue(is_open));
322 return Status(kOk);
323 }
324
325 Status ExecuteGetAlertText(
326 Session* session,
327 const base::DictionaryValue& params,
328 scoped_ptr<base::Value>* value) {
329 std::string message;
330 Status status = session->chrome->GetJavaScriptDialogMessage(&message);
331 if (status.IsError())
332 return status;
333 value->reset(base::Value::CreateStringValue(message));
334 return Status(kOk);
335 }
336
337 Status ExecuteSetAlertValue(
338 Session* session,
339 const base::DictionaryValue& params,
340 scoped_ptr<base::Value>* value) {
341 std::string text;
342 if (!params.GetString("text", &text))
343 return Status(kUnknownError, "missing or invalid 'text'");
344
345 bool is_open;
346 Status status = session->chrome->IsJavaScriptDialogOpen(&is_open);
347 if (status.IsError())
348 return status;
349 if (!is_open)
350 return Status(kNoAlertOpen);
351
352 session->prompt_text.reset(new std::string(text));
353 return Status(kOk);
354 }
355
356 Status ExecuteAcceptAlert(
357 Session* session,
358 const base::DictionaryValue& params,
359 scoped_ptr<base::Value>* value) {
360 Status status = session->chrome->HandleJavaScriptDialog(
361 true, session->prompt_text.get());
362 session->prompt_text.reset();
363 return status;
364 }
365
366 Status ExecuteDismissAlert(
367 Session* session,
368 const base::DictionaryValue& params,
369 scoped_ptr<base::Value>* value) {
370 Status status = session->chrome->HandleJavaScriptDialog(
371 false, session->prompt_text.get());
372 session->prompt_text.reset();
373 return status;
374 }
375
376 Status ExecuteIsLoading( 292 Status ExecuteIsLoading(
377 Session* session, 293 Session* session,
378 const base::DictionaryValue& params, 294 const base::DictionaryValue& params,
379 scoped_ptr<base::Value>* value) { 295 scoped_ptr<base::Value>* value) {
380 WebView* web_view = NULL; 296 WebView* web_view = NULL;
381 Status status = session->GetTargetWindow(&web_view); 297 Status status = session->GetTargetWindow(&web_view);
382 if (status.IsError()) 298 if (status.IsError())
383 return status; 299 return status;
384 300
385 status = web_view->ConnectIfNecessary(); 301 status = web_view->ConnectIfNecessary();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 472 }
557 std::string error_msg; 473 std::string error_msg;
558 base::FilePath upload; 474 base::FilePath upload;
559 Status status = UnzipSoleFile(upload_dir, zip_data, &upload); 475 Status status = UnzipSoleFile(upload_dir, zip_data, &upload);
560 if (status.IsError()) 476 if (status.IsError())
561 return Status(kUnknownError, "unable to unzip 'file'", status); 477 return Status(kUnknownError, "unable to unzip 'file'", status);
562 478
563 value->reset(new base::StringValue(upload.value())); 479 value->reset(new base::StringValue(upload.value()));
564 return Status(kOk); 480 return Status(kOk);
565 } 481 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/session_commands.h ('k') | chrome/test/chromedriver/window_commands.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698