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.
5 #include "chrome/browser/pdf/pdf_extension_test_util.h"
7 #include "content/public/test/browser_test_utils.h"
8 #include "grit/component_extension_resources.h"
9 #include "ui/base/resource/resource_bundle.h"
11 namespace pdf_extension_test_util
{
13 bool EnsurePDFHasLoaded(content::WebContents
* web_contents
) {
14 std::string scripting_api_js
=
15 ResourceBundle::GetSharedInstance()
16 .GetRawDataResource(IDR_PDF_PDF_SCRIPTING_API_JS
)
18 CHECK(content::ExecuteScript(web_contents
, scripting_api_js
));
20 bool load_success
= false;
21 CHECK(content::ExecuteScriptAndExtractBool(
23 "var scriptingAPI = new PDFScriptingAPI(window, "
24 " document.getElementsByTagName('embed')[0]);"
25 "scriptingAPI.setLoadCallback(function(success) {"
26 " window.domAutomationController.send(success);"
32 } // namespace pdf_extension_test_util