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 @@ ...@@ -28,6 +28,7 @@
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
#include "extensions/common/switches.h" #include "extensions/common/switches.h"
#include "extensions/common/value_builder.h" #include "extensions/common/value_builder.h"
#include "extensions/test/test_extension_dir.h"
namespace extensions { namespace extensions {
...@@ -57,6 +58,10 @@ class DebuggerApiTest : public ExtensionApiTest { ...@@ -57,6 +58,10 @@ class DebuggerApiTest : public ExtensionApiTest {
// A basic extension with the debugger permission. // A basic extension with the debugger permission.
scoped_refptr<const Extension> extension_; 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) { void DebuggerApiTest::SetUpCommandLine(base::CommandLine* command_line) {
...@@ -67,16 +72,17 @@ void DebuggerApiTest::SetUpCommandLine(base::CommandLine* command_line) { ...@@ -67,16 +72,17 @@ void DebuggerApiTest::SetUpCommandLine(base::CommandLine* command_line) {
void DebuggerApiTest::SetUpOnMainThread() { void DebuggerApiTest::SetUpOnMainThread() {
ExtensionApiTest::SetUpOnMainThread(); ExtensionApiTest::SetUpOnMainThread();
extension_ = test_extension_dir_.WriteManifest(
ExtensionBuilder() R"({
.SetManifest( "name": "debugger",
DictionaryBuilder() "version": "0.1",
.Set("name", "debugger") "manifest_version": 2,
.Set("version", "0.1") "permissions": ["debugger"]
.Set("manifest_version", 2) })");
.Set("permissions", ListBuilder().Append("debugger").Build()) test_extension_dir_.WriteFile(FILE_PATH_LITERAL("test_file.html"),
.Build()) "<html>Hello world!</html>");
.Build(); extension_ = LoadExtension(test_extension_dir_.UnpackedPath());
ASSERT_TRUE(extension_);
} }
testing::AssertionResult DebuggerApiTest::RunAttachFunction( testing::AssertionResult DebuggerApiTest::RunAttachFunction(
...@@ -169,19 +175,15 @@ IN_PROC_BROWSER_TEST_F(DebuggerApiTest, ...@@ -169,19 +175,15 @@ IN_PROC_BROWSER_TEST_F(DebuggerApiTest,
const Extension* another_extension = LoadExtension(path); const Extension* another_extension = LoadExtension(path);
ASSERT_TRUE(another_extension); ASSERT_TRUE(another_extension);
GURL other_ext_url = GURL other_ext_url = another_extension->GetResourceURL("popup.html");
GURL(base::StringPrintf("chrome-extension://%s/popup.html",
another_extension->id().c_str()));
// This extension should not be able to access another extension. // This extension should not be able to access another extension.
EXPECT_TRUE(RunAttachFunction( EXPECT_TRUE(RunAttachFunction(
other_ext_url, manifest_errors::kCannotAccessExtensionUrl)); other_ext_url, manifest_errors::kCannotAccessExtensionUrl));
// This extension *should* be able to debug itself. // This extension *should* be able to debug itself.
EXPECT_TRUE(RunAttachFunction( EXPECT_TRUE(RunAttachFunction(extension()->GetResourceURL("test_file.html"),
GURL(base::StringPrintf("chrome-extension://%s/foo.html", std::string()));
extension()->id().c_str())),
std::string()));
// Append extensions on chrome urls switch. The extension should now be able // Append extensions on chrome urls switch. The extension should now be able
// to debug any extension. // 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