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

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

Issue 2503533003: [chromedriver] Retry alert handling if HandleJavaScriptDialog fails. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | 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 (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/chrome/javascript_dialog_manager.h" 5 #include "chrome/test/chromedriver/chrome/javascript_dialog_manager.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/test/chromedriver/chrome/devtools_client.h" 8 #include "chrome/test/chromedriver/chrome/devtools_client.h"
9 #include "chrome/test/chromedriver/chrome/status.h" 9 #include "chrome/test/chromedriver/chrome/status.h"
10 10
(...skipping 19 matching lines...) Expand all
30 Status JavaScriptDialogManager::HandleDialog(bool accept, 30 Status JavaScriptDialogManager::HandleDialog(bool accept,
31 const std::string* text) { 31 const std::string* text) {
32 if (!IsDialogOpen()) 32 if (!IsDialogOpen())
33 return Status(kNoAlertOpen); 33 return Status(kNoAlertOpen);
34 34
35 base::DictionaryValue params; 35 base::DictionaryValue params;
36 params.SetBoolean("accept", accept); 36 params.SetBoolean("accept", accept);
37 if (text) 37 if (text)
38 params.SetString("promptText", *text); 38 params.SetString("promptText", *text);
39 Status status = client_->SendCommand("Page.handleJavaScriptDialog", params); 39 Status status = client_->SendCommand("Page.handleJavaScriptDialog", params);
40 std::string msg = status.message();
41 // Retry handling the alert dialog if
42 // JavaScriptDialogManager::HandleJavaScriptDialog function fails.
samuong 2016/11/16 19:06:05 This comment doesn't add much, I don't think it's
gmanikpure 2016/11/16 20:22:40 ok.I will remove it.
43 if (status.IsError() && (msg.find("Could not handle JavaScript dialog") !=
44 std::string::npos)) {
samuong 2016/11/16 19:06:04 This isn't a very specific error message (it gets
gmanikpure 2016/11/16 20:22:40 Oh ok, the response received is :- "[38.955][DEBUG
samuong 2016/11/16 21:04:04 You can just check "status.IsError()", this should
gmanikpure 2016/11/16 21:26:45 Done.Please take a look.
45 status = client_->SendCommand("Page.handleJavaScriptDialog", params);
46 }
samuong 2016/11/16 19:06:04 nit: don't need braces for a single-line if body
gmanikpure 2016/11/16 20:22:40 oops, sorry. I had some logging statements inside
40 if (status.IsError()) 47 if (status.IsError())
41 return status; 48 return status;
42 49
43 // Remove a dialog from the queue. Need to check the queue is not empty here, 50 // Remove a dialog from the queue. Need to check the queue is not empty here,
44 // because it could have been cleared during waiting for the command 51 // because it could have been cleared during waiting for the command
45 // response. 52 // response.
46 if (unhandled_dialog_queue_.size()) 53 if (unhandled_dialog_queue_.size())
47 unhandled_dialog_queue_.pop_front(); 54 unhandled_dialog_queue_.pop_front();
48 return Status(kOk); 55 return Status(kOk);
49 } 56 }
(...skipping 13 matching lines...) Expand all
63 return Status(kUnknownError, "dialog event missing or invalid 'message'"); 70 return Status(kUnknownError, "dialog event missing or invalid 'message'");
64 71
65 unhandled_dialog_queue_.push_back(message); 72 unhandled_dialog_queue_.push_back(message);
66 } else if (method == "Page.javascriptDialogClosed") { 73 } else if (method == "Page.javascriptDialogClosed") {
67 // Inspector only sends this event when all dialogs have been closed. 74 // Inspector only sends this event when all dialogs have been closed.
68 // Clear the unhandled queue in case the user closed a dialog manually. 75 // Clear the unhandled queue in case the user closed a dialog manually.
69 unhandled_dialog_queue_.clear(); 76 unhandled_dialog_queue_.clear();
70 } 77 }
71 return Status(kOk); 78 return Status(kOk);
72 } 79 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698