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

Unified Diff: chrome/test/chromedriver/window_commands.cc

Issue 1022543002: [chromedriver] Implement DELETE NetworkConditions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Retrieving network conditions after deleting them raises an exception Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/chromedriver/window_commands.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/window_commands.cc
diff --git a/chrome/test/chromedriver/window_commands.cc b/chrome/test/chromedriver/window_commands.cc
index 000cec03670647e38e5bf3c0d4cfef30c4c99916..51ae0706a8b0d835b5fd87dd10b83ecdada4831e 100644
--- a/chrome/test/chromedriver/window_commands.cc
+++ b/chrome/test/chromedriver/window_commands.cc
@@ -930,6 +930,29 @@ Status ExecuteSetNetworkConditions(
*session->overridden_network_conditions);
}
+Status ExecuteDeleteNetworkConditions(
+ Session* session,
+ WebView* web_view,
+ const base::DictionaryValue& params,
+ scoped_ptr<base::Value>* value) {
+ // Chrome does not have any command to stop overriding network conditions, so
+ // we just override the network conditions with the "No throttling" preset.
+ NetworkConditions* network_conditions = new NetworkConditions();
samuong 2015/03/23 20:23:45 Won't this leak? Why not allocate on the stack?
+ // Get conditions from preset list.
+ Status status = FindPresetNetwork("No throttling", network_conditions);
+ if (status.IsError())
+ return status;
+
+ status = web_view->OverrideNetworkConditions(*network_conditions);
+ if (status.IsError())
+ return status;
+
+ // After we've successfully overridden the network conditions with
+ // "No throttling", we can delete them from |session|.
+ session->overridden_network_conditions.reset();
+ return status;
+}
+
Status ExecuteTakeHeapSnapshot(
Session* session,
WebView* web_view,
« no previous file with comments | « chrome/test/chromedriver/window_commands.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698