OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webdriver/session.h" | 5 #include "chrome/test/webdriver/session.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 current_target_.window_id, | 1473 current_target_.window_id, |
1474 path, | 1474 path, |
1475 &error)); | 1475 &error)); |
1476 if (error) | 1476 if (error) |
1477 return error; | 1477 return error; |
1478 if (!file_util::ReadFileToString(path, png)) | 1478 if (!file_util::ReadFileToString(path, png)) |
1479 return new Error(kUnknownError, "Could not read screenshot file"); | 1479 return new Error(kUnknownError, "Could not read screenshot file"); |
1480 return NULL; | 1480 return NULL; |
1481 } | 1481 } |
1482 | 1482 |
| 1483 Error* Session::GetBrowserConnectionState(bool* online) { |
| 1484 std::string jscript = base::StringPrintf( |
| 1485 "return (%s).apply(null, arguments);", atoms::IS_ONLINE); |
| 1486 base::ListValue no_args; |
| 1487 Value* unscoped_value = NULL; |
| 1488 Error* error = ExecuteScript(jscript, |
| 1489 &no_args, |
| 1490 &unscoped_value); |
| 1491 scoped_ptr<base::Value> value(unscoped_value); |
| 1492 if (error) |
| 1493 return error; |
| 1494 if (!value->GetAsBoolean(online)) |
| 1495 return new Error(kUnknownError, |
| 1496 "IS_ONLINE script returned non-boolean: " + |
| 1497 JsonStringify(value.get())); |
| 1498 return NULL; |
| 1499 } |
| 1500 |
| 1501 Error* Session::GetAppCacheStatus(int* status) { |
| 1502 std::string jscript = base::StringPrintf( |
| 1503 "return (%s).apply(null, arguments);", atoms::GET_APPCACHE_STATUS); |
| 1504 base::ListValue no_args; |
| 1505 Value* unscoped_value = NULL; |
| 1506 Error* error = ExecuteScript(jscript, |
| 1507 &no_args, |
| 1508 &unscoped_value); |
| 1509 scoped_ptr<base::Value> value(unscoped_value); |
| 1510 if (error) |
| 1511 return error; |
| 1512 if (!value->GetAsInteger(status)) |
| 1513 return new Error(kUnknownError, |
| 1514 "GET_APPCACHE_STATUS script returned non-integer: " + |
| 1515 JsonStringify(value.get())); |
| 1516 return NULL; |
| 1517 } |
| 1518 |
1483 } // namespace webdriver | 1519 } // namespace webdriver |
OLD | NEW |