Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / pdf / pdf_extension_test_util.cc
blob2d992422b82de2bbec4d574437cc7f50dc87ac82
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)
17 .as_string();
18 CHECK(content::ExecuteScript(web_contents, scripting_api_js));
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;
32 } // namespace pdf_extension_test_util