OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/test/webdriver/commands/session_with_id.h" | |
6 | |
7 #include <sstream> | |
8 #include <string> | |
9 | |
10 #include "base/values.h" | |
11 #include "chrome/app/chrome_command_ids.h" | |
12 #include "chrome/common/chrome_constants.h" | |
13 #include "chrome/test/webdriver/commands/response.h" | |
14 #include "chrome/test/webdriver/webdriver_session.h" | |
15 | |
16 namespace webdriver { | |
17 | |
18 SessionWithID::SessionWithID(const std::vector<std::string>& path_segments, | |
19 const base::DictionaryValue* const parameters) | |
20 : WebDriverCommand(path_segments, parameters) {} | |
21 | |
22 SessionWithID::~SessionWithID() {} | |
23 | |
24 bool SessionWithID::DoesGet() { | |
25 return true; | |
26 } | |
27 | |
28 bool SessionWithID::DoesDelete() { | |
29 return true; | |
30 } | |
31 | |
32 void SessionWithID::ExecuteGet(Response* const response) { | |
33 base::DictionaryValue* temp_value = new base::DictionaryValue(); | |
34 | |
35 // Standard capabilities defined at | |
36 // http://code.google.com/p/selenium/wiki/JsonWireProtocol#Capabilities_JSON_O
bject | |
37 temp_value->SetString("browserName", "chrome"); | |
38 temp_value->SetString("version", session_->GetBrowserVersion()); | |
39 | |
40 #if defined(OS_WIN) | |
41 temp_value->SetString("platform", "windows"); | |
42 #elif defined(OS_MACOSX) | |
43 temp_value->SetString("platform", "mac"); | |
44 #elif defined(OS_CHROMEOS) | |
45 temp_value->SetString("platform", "chromeos"); | |
46 #elif defined(OS_LINUX) | |
47 temp_value->SetString("platform", "linux"); | |
48 #else | |
49 temp_value->SetString("platform", "unknown"); | |
50 #endif | |
51 | |
52 temp_value->SetBoolean("javascriptEnabled", true); | |
53 temp_value->SetBoolean("takesScreenshot", true); | |
54 temp_value->SetBoolean("handlesAlerts", true); | |
55 temp_value->SetBoolean("databaseEnabled", false); | |
56 temp_value->SetBoolean("locationContextEnabled", false); | |
57 temp_value->SetBoolean("applicationCacheEnabled", false); | |
58 temp_value->SetBoolean("browserConnectionEnabled", false); | |
59 temp_value->SetBoolean("cssSelectorsEnabled", true); | |
60 temp_value->SetBoolean("webStorageEnabled", true); | |
61 temp_value->SetBoolean("rotatable", false); | |
62 temp_value->SetBoolean("acceptSslCerts", false); | |
63 // Even when ChromeDriver does not OS-events, the input simulation produces | |
64 // the same effect for most purposes (except IME). | |
65 temp_value->SetBoolean("nativeEvents", true); | |
66 | |
67 // Custom non-standard session info. | |
68 temp_value->SetWithoutPathExpansion( | |
69 "chrome.chromedriverVersion", | |
70 new base::StringValue(chrome::kChromeVersion)); | |
71 | |
72 response->SetValue(temp_value); | |
73 } | |
74 | |
75 void SessionWithID::ExecuteDelete(Response* const response) { | |
76 // Session manages its own lifetime, so do not call delete. | |
77 session_->Terminate(); | |
78 } | |
79 | |
80 bool SessionWithID::ShouldRunPreAndPostCommandHandlers() { | |
81 return false; | |
82 } | |
83 | |
84 } // namespace webdriver | |
OLD | NEW |