| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/webdriver_session.h" | 5 #include "chrome/test/webdriver/webdriver_session.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 "}"; | 658 "}"; |
| 659 return SwitchToFrameWithJavaScriptLocatedFrame( | 659 return SwitchToFrameWithJavaScriptLocatedFrame( |
| 660 script, CreateListValueFrom(name_or_id)); | 660 script, CreateListValueFrom(name_or_id)); |
| 661 } | 661 } |
| 662 | 662 |
| 663 Error* Session::SwitchToFrameWithIndex(int index) { | 663 Error* Session::SwitchToFrameWithIndex(int index) { |
| 664 // We cannot simply index into window.frames because we need to know the | 664 // We cannot simply index into window.frames because we need to know the |
| 665 // tagName of the frameElement. If child frame N is from another domain, then | 665 // tagName of the frameElement. If child frame N is from another domain, then |
| 666 // the following will run afoul of the same origin policy: | 666 // the following will run afoul of the same origin policy: |
| 667 // window.frames[N].frameElement; | 667 // window.frames[N].frameElement; |
| 668 // Instead of indexing window.frames, we use a an XPath expression to index | 668 // Instead of indexing window.frames, we use an XPath expression to index |
| 669 // into the list of all IFRAME and FRAME elements on the page - if we find | 669 // into the list of all IFRAME and FRAME elements on the page - if we find |
| 670 // something, then that XPath expression can be used as the new frame's XPath. | 670 // something, then that XPath expression can be used as the new frame's XPath. |
| 671 std::string script = | 671 std::string script = |
| 672 "function(index) {" | 672 "function(index) {" |
| 673 " var xpathIndex = '[' + (index + 1) + ']';" | 673 " var xpathIndex = '[' + (index + 1) + ']';" |
| 674 " var xpath = '(/html/body//iframe|/html/frameset/frame)' + " | 674 " var xpath = '(/html/body//iframe|/html/frameset/frame)' + " |
| 675 " xpathIndex;" | 675 " xpathIndex;" |
| 676 " return document.evaluate(xpath, document, null, " | 676 " return document.evaluate(xpath, document, null, " |
| 677 " XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;" | 677 " XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;" |
| 678 "}"; | 678 "}"; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 Error* error = NULL; | 783 Error* error = NULL; |
| 784 RunSessionTask(base::Bind( | 784 RunSessionTask(base::Bind( |
| 785 &Automation::SetViewBounds, | 785 &Automation::SetViewBounds, |
| 786 base::Unretained(automation_.get()), | 786 base::Unretained(automation_.get()), |
| 787 window, | 787 window, |
| 788 bounds, | 788 bounds, |
| 789 &error)); | 789 &error)); |
| 790 return error; | 790 return error; |
| 791 } | 791 } |
| 792 | 792 |
| 793 Error* Session::MaximizeWindow(const WebViewId& window) { |
| 794 Error* error = NULL; |
| 795 RunSessionTask(base::Bind( |
| 796 &Automation::Maximize, |
| 797 base::Unretained(automation_.get()), |
| 798 window, |
| 799 &error)); |
| 800 return error; |
| 801 } |
| 802 |
| 793 Error* Session::GetAlertMessage(std::string* text) { | 803 Error* Session::GetAlertMessage(std::string* text) { |
| 794 Error* error = NULL; | 804 Error* error = NULL; |
| 795 RunSessionTask(base::Bind( | 805 RunSessionTask(base::Bind( |
| 796 &Automation::GetAppModalDialogMessage, | 806 &Automation::GetAppModalDialogMessage, |
| 797 base::Unretained(automation_.get()), | 807 base::Unretained(automation_.get()), |
| 798 text, | 808 text, |
| 799 &error)); | 809 &error)); |
| 800 return error; | 810 return error; |
| 801 } | 811 } |
| 802 | 812 |
| (...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 capabilities_.local_state->GetWithoutPathExpansion(*iter, &value); | 1921 capabilities_.local_state->GetWithoutPathExpansion(*iter, &value); |
| 1912 Error* error = SetPreference(*iter, false /* is_user_pref */, | 1922 Error* error = SetPreference(*iter, false /* is_user_pref */, |
| 1913 value->DeepCopy()); | 1923 value->DeepCopy()); |
| 1914 if (error) | 1924 if (error) |
| 1915 return error; | 1925 return error; |
| 1916 } | 1926 } |
| 1917 return NULL; | 1927 return NULL; |
| 1918 } | 1928 } |
| 1919 | 1929 |
| 1920 } // namespace webdriver | 1930 } // namespace webdriver |
| OLD | NEW |