OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/run_loop.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "content/public/browser/devtools_agent_host.h" | 15 #include "content/public/browser/devtools_agent_host.h" |
15 #include "content/public/browser/javascript_dialog_manager.h" | 16 #include "content/public/browser/javascript_dialog_manager.h" |
16 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
19 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
20 #include "content/public/test/content_browser_test.h" | 21 #include "content/public/test/content_browser_test.h" |
21 #include "content/public/test/content_browser_test_utils.h" | 22 #include "content/public/test/content_browser_test_utils.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if (params) | 121 if (params) |
121 command.Set(kParamsParam, params.release()); | 122 command.Set(kParamsParam, params.release()); |
122 | 123 |
123 std::string json_command; | 124 std::string json_command; |
124 base::JSONWriter::Write(command, &json_command); | 125 base::JSONWriter::Write(command, &json_command); |
125 agent_host_->DispatchProtocolMessage(this, json_command); | 126 agent_host_->DispatchProtocolMessage(this, json_command); |
126 // Some messages are dispatched synchronously. | 127 // Some messages are dispatched synchronously. |
127 // Only run loop if we are not finished yet. | 128 // Only run loop if we are not finished yet. |
128 if (in_dispatch_ && wait) { | 129 if (in_dispatch_ && wait) { |
129 waiting_for_command_result_id_ = last_sent_id_; | 130 waiting_for_command_result_id_ = last_sent_id_; |
130 base::MessageLoop::current()->Run(); | 131 base::RunLoop().Run(); |
131 } | 132 } |
132 in_dispatch_ = false; | 133 in_dispatch_ = false; |
133 } | 134 } |
134 | 135 |
135 bool HasValue(const std::string& path) { | 136 bool HasValue(const std::string& path) { |
136 base::Value* value = 0; | 137 base::Value* value = 0; |
137 return result_->Get(path, &value); | 138 return result_->Get(path, &value); |
138 } | 139 } |
139 | 140 |
140 bool HasListItem(const std::string& path_to_list, | 141 bool HasListItem(const std::string& path_to_list, |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 shell()->web_contents()->SetDelegate(&dialog_manager); | 579 shell()->web_contents()->SetDelegate(&dialog_manager); |
579 SendCommand("Page.enable", nullptr, true); | 580 SendCommand("Page.enable", nullptr, true); |
580 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); | 581 std::unique_ptr<base::DictionaryValue> params(new base::DictionaryValue()); |
581 params->SetString("expression", "alert('alert')"); | 582 params->SetString("expression", "alert('alert')"); |
582 SendCommand("Runtime.evaluate", std::move(params), false); | 583 SendCommand("Runtime.evaluate", std::move(params), false); |
583 WaitForNotification("Page.javascriptDialogOpening"); | 584 WaitForNotification("Page.javascriptDialogOpening"); |
584 dialog_manager.Handle(); | 585 dialog_manager.Handle(); |
585 } | 586 } |
586 | 587 |
587 } // namespace content | 588 } // namespace content |
OLD | NEW |