| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 #import "ios/web/public/test/web_view_content_test_util.h" |
| 6 |
| 7 #import <Foundation/Foundation.h> |
| 8 |
| 9 #import "ios/web/public/test/web_view_interaction_test_util.h" |
| 10 |
| 11 namespace { |
| 12 // Script that returns document.body as a string. |
| 13 char kGetDocumentBodyJavaScript[] = |
| 14 "document.body ? document.body.textContent : null"; |
| 15 } |
| 16 |
| 17 namespace web { |
| 18 namespace test { |
| 19 |
| 20 bool WebViewContainingText(web::WebState* web_state, const std::string& text) { |
| 21 std::unique_ptr<base::Value> value = |
| 22 web::test::ExecuteJavaScript(web_state, kGetDocumentBodyJavaScript); |
| 23 std::string body; |
| 24 if (value && value->GetAsString(&body)) { |
| 25 return body.find(text) != std::string::npos; |
| 26 } |
| 27 return false; |
| 28 } |
| 29 |
| 30 } // namespace test |
| 31 } // namespace web |
| OLD | NEW |