Commit 2e14c65d authored by Nasko Oskov's avatar Nasko Oskov Committed by Commit Bot

Update DebuggerApiTest to navigate to real file.

The DebuggerNotAllowedOnOtherExtensionPages test navigates to non-existing
URL and threfore results in an error. This CL fixes it to succeed and
unblock isolating error pages.

Bug: 838161
Change-Id: I38a8bb656fab0992d9343ba39a2c5f3da497c7fb
Reviewed-on: https://chromium-review.googlesource.com/1117262
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570851}
parent 3c3ae54d
......@@ -28,6 +28,7 @@
#include "extensions/common/manifest_constants.h"
#include "extensions/common/switches.h"
#include "extensions/common/value_builder.h"
#include "extensions/test/test_extension_dir.h"
namespace extensions {
......@@ -57,6 +58,10 @@ class DebuggerApiTest : public ExtensionApiTest {
// A basic extension with the debugger permission.
scoped_refptr<const Extension> extension_;
// A temporary directory in which to create and load from the
// |extension_|.
TestExtensionDir test_extension_dir_;
};
void DebuggerApiTest::SetUpCommandLine(base::CommandLine* command_line) {
......@@ -67,16 +72,17 @@ void DebuggerApiTest::SetUpCommandLine(base::CommandLine* command_line) {
void DebuggerApiTest::SetUpOnMainThread() {
ExtensionApiTest::SetUpOnMainThread();
extension_ =
ExtensionBuilder()
.SetManifest(
DictionaryBuilder()
.Set("name", "debugger")
.Set("version", "0.1")
.Set("manifest_version", 2)
.Set("permissions", ListBuilder().Append("debugger").Build())
.Build())
.Build();
test_extension_dir_.WriteManifest(
R"({
"name": "debugger",
"version": "0.1",
"manifest_version": 2,
"permissions": ["debugger"]
})");
test_extension_dir_.WriteFile(FILE_PATH_LITERAL("test_file.html"),
"<html>Hello world!</html>");
extension_ = LoadExtension(test_extension_dir_.UnpackedPath());
ASSERT_TRUE(extension_);
}
testing::AssertionResult DebuggerApiTest::RunAttachFunction(
......@@ -169,19 +175,15 @@ IN_PROC_BROWSER_TEST_F(DebuggerApiTest,
const Extension* another_extension = LoadExtension(path);
ASSERT_TRUE(another_extension);
GURL other_ext_url =
GURL(base::StringPrintf("chrome-extension://%s/popup.html",
another_extension->id().c_str()));
GURL other_ext_url = another_extension->GetResourceURL("popup.html");
// This extension should not be able to access another extension.
EXPECT_TRUE(RunAttachFunction(
other_ext_url, manifest_errors::kCannotAccessExtensionUrl));
// This extension *should* be able to debug itself.
EXPECT_TRUE(RunAttachFunction(
GURL(base::StringPrintf("chrome-extension://%s/foo.html",
extension()->id().c_str())),
std::string()));
EXPECT_TRUE(RunAttachFunction(extension()->GetResourceURL("test_file.html"),
std::string()));
// Append extensions on chrome urls switch. The extension should now be able
// to debug any extension.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment