OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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/browser/pdf/pdf_extension_test_util.h" |
| 6 |
| 7 #include "content/public/test/browser_test_utils.h" |
| 8 #include "grit/component_extension_resources.h" |
| 9 #include "ui/base/resource/resource_bundle.h" |
| 10 |
| 11 namespace pdf_extension_test_util { |
| 12 |
| 13 bool EnsurePDFHasLoaded(content::WebContents* web_contents) { |
| 14 std::string scripting_api_js = |
| 15 ResourceBundle::GetSharedInstance() |
| 16 .GetRawDataResource(IDR_PDF_PDF_SCRIPTING_API_JS) |
| 17 .as_string(); |
| 18 CHECK(content::ExecuteScript(web_contents, scripting_api_js)); |
| 19 |
| 20 bool load_success = false; |
| 21 CHECK(content::ExecuteScriptAndExtractBool( |
| 22 web_contents, |
| 23 "var scriptingAPI = new PDFScriptingAPI(window, " |
| 24 " document.getElementsByTagName('embed')[0]);" |
| 25 "scriptingAPI.setLoadCallback(function(success) {" |
| 26 " window.domAutomationController.send(success);" |
| 27 "});", |
| 28 &load_success)); |
| 29 return load_success; |
| 30 } |
| 31 |
| 32 } // namespace pdf_extension_test_util |
OLD | NEW |