| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/error_console/error_console.h" | 5 #include "chrome/browser/extensions/error_console/error_console.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/extensions/extension_browsertest.h" | 12 #include "chrome/browser/extensions/extension_browsertest.h" |
| 13 #include "chrome/browser/extensions/extension_toolbar_model.h" | 13 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
| 18 #include "extensions/browser/extension_error.h" | 18 #include "extensions/browser/extension_error.h" |
| 19 #include "extensions/common/constants.h" | 19 #include "extensions/common/constants.h" |
| 20 #include "extensions/common/error_utils.h" | 20 #include "extensions/common/error_utils.h" |
| 21 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
| 22 #include "extensions/common/extension_urls.h" | 22 #include "extensions/common/extension_urls.h" |
| 23 #include "extensions/common/feature_switch.h" | |
| 24 #include "extensions/common/manifest_constants.h" | 23 #include "extensions/common/manifest_constants.h" |
| 25 #include "net/test/embedded_test_server/embedded_test_server.h" | 24 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 28 | 27 |
| 29 using base::string16; | 28 using base::string16; |
| 30 using base::UTF8ToUTF16; | 29 using base::UTF8ToUTF16; |
| 31 | 30 |
| 32 namespace extensions { | 31 namespace extensions { |
| 33 | 32 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 ACTION_NAVIGATE, | 191 ACTION_NAVIGATE, |
| 193 // Simulate a browser action click. | 192 // Simulate a browser action click. |
| 194 ACTION_BROWSER_ACTION, | 193 ACTION_BROWSER_ACTION, |
| 195 // Navigate to the new tab page. | 194 // Navigate to the new tab page. |
| 196 ACTION_NEW_TAB, | 195 ACTION_NEW_TAB, |
| 197 // Do nothing (errors will be caused by a background script, | 196 // Do nothing (errors will be caused by a background script, |
| 198 // or by a manifest/loading warning). | 197 // or by a manifest/loading warning). |
| 199 ACTION_NONE | 198 ACTION_NONE |
| 200 }; | 199 }; |
| 201 | 200 |
| 202 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | |
| 203 ExtensionBrowserTest::SetUpInProcessBrowserTestFixture(); | |
| 204 | |
| 205 // We need to enable the ErrorConsole FeatureSwitch in order to collect | |
| 206 // errors. | |
| 207 FeatureSwitch::error_console()->SetOverrideValue( | |
| 208 FeatureSwitch::OVERRIDE_ENABLED); | |
| 209 } | |
| 210 | |
| 211 virtual void SetUpOnMainThread() OVERRIDE { | 201 virtual void SetUpOnMainThread() OVERRIDE { |
| 212 ExtensionBrowserTest::SetUpOnMainThread(); | 202 ExtensionBrowserTest::SetUpOnMainThread(); |
| 213 | 203 |
| 214 // Errors are only kept if we have Developer Mode enabled. | 204 // Errors are only kept if we have Developer Mode enabled. |
| 215 profile()->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode, true); | 205 profile()->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode, true); |
| 216 | 206 |
| 217 error_console_ = ErrorConsole::Get(profile()); | 207 error_console_ = ErrorConsole::Get(profile()); |
| 218 CHECK(error_console_); | 208 CHECK(error_console_); |
| 219 | 209 |
| 220 test_data_dir_ = test_data_dir_.AppendASCII("error_console"); | 210 test_data_dir_ = test_data_dir_.AppendASCII("error_console"); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 const Extension* extension = NULL; | 535 const Extension* extension = NULL; |
| 546 LoadExtensionAndCheckErrors( | 536 LoadExtensionAndCheckErrors( |
| 547 "bad_extension_page", | 537 "bad_extension_page", |
| 548 kNoFlags, | 538 kNoFlags, |
| 549 1, // One error: the page will load JS which has a reference error. | 539 1, // One error: the page will load JS which has a reference error. |
| 550 ACTION_NEW_TAB, | 540 ACTION_NEW_TAB, |
| 551 &extension); | 541 &extension); |
| 552 } | 542 } |
| 553 | 543 |
| 554 } // namespace extensions | 544 } // namespace extensions |
| OLD | NEW |