blob: 43bcec32608c0fb9b7f0a80af69206be4236dec8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "url/gurl.h"
using ExtensionsInternalsTest = extensions::ExtensionBrowserTest;
IN_PROC_BROWSER_TEST_F(ExtensionsInternalsTest,
TestExtensionsInternalsAreServed) {
// Install an extension that we can check for.
base::FilePath test_data_dir;
ASSERT_TRUE(base::PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
test_data_dir = test_data_dir.AppendASCII("extensions");
extensions::ChromeTestExtensionLoader loader(browser()->profile());
const extensions::Extension* extension =
loader.LoadExtension(test_data_dir.AppendASCII("good.crx")).get();
ASSERT_TRUE(extension);
// First, check that navigation succeeds.
GURL navigation_url("chrome://extensions-internals");
ui_test_utils::NavigateToURL(browser(), navigation_url);
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(web_contents);
EXPECT_EQ(navigation_url, web_contents->GetLastCommittedURL());
EXPECT_FALSE(web_contents->IsCrashed());
EXPECT_FALSE(web_contents->GetInterstitialPage());
// Look for a bit of JSON that has the extension's unique ID.
bool has_text = false;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
web_contents,
base::StringPrintf("window.domAutomationController.send("
"document.body.textContent && "
"document.body.textContent.indexOf("
"'\"id\": \"%s\"') >= 0);",
extension->id().c_str()),
&has_text));
EXPECT_TRUE(has_text);
}
|