Commit cfaf5dcf authored by hcarmona's avatar hcarmona Committed by Commit bot

Enable extensions error button test that was failing on stable.

Error buttons should not be visible in stable.
Error buttons should be visible in dev.

BUG=463245

Review URL: https://codereview.chromium.org/1132493004

Cr-Commit-Position: refs/heads/master@{#329465}
parent dbcc99df
...@@ -169,9 +169,13 @@ void ErrorConsole::RemoveObserver(Observer* observer) { ...@@ -169,9 +169,13 @@ void ErrorConsole::RemoveObserver(Observer* observer) {
} }
bool ErrorConsole::IsEnabledForChromeExtensionsPage() const { bool ErrorConsole::IsEnabledForChromeExtensionsPage() const {
return profile_->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode) && if (!profile_->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode))
(FeatureSwitch::error_console()->IsEnabled() || return false; // Only enabled in developer mode.
GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV); if (GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV &&
!FeatureSwitch::error_console()->IsEnabled())
return false; // Restricted to dev channel or opt-in.
return true;
} }
bool ErrorConsole::IsEnabledForAppsDeveloperTools() const { bool ErrorConsole::IsEnabledForAppsDeveloperTools() const {
......
...@@ -34,7 +34,7 @@ using extensions::Extension; ...@@ -34,7 +34,7 @@ using extensions::Extension;
using extensions::TestManagementPolicyProvider; using extensions::TestManagementPolicyProvider;
ExtensionSettingsUIBrowserTest::ExtensionSettingsUIBrowserTest() ExtensionSettingsUIBrowserTest::ExtensionSettingsUIBrowserTest()
: profile_(NULL), : profile_(nullptr),
policy_provider_(TestManagementPolicyProvider::PROHIBIT_MODIFY_STATUS | policy_provider_(TestManagementPolicyProvider::PROHIBIT_MODIFY_STATUS |
TestManagementPolicyProvider::MUST_REMAIN_ENABLED | TestManagementPolicyProvider::MUST_REMAIN_ENABLED |
TestManagementPolicyProvider::MUST_REMAIN_INSTALLED) { TestManagementPolicyProvider::MUST_REMAIN_INSTALLED) {
...@@ -90,6 +90,11 @@ void ExtensionSettingsUIBrowserTest::SetAutoConfirmUninstall() { ...@@ -90,6 +90,11 @@ void ExtensionSettingsUIBrowserTest::SetAutoConfirmUninstall() {
extensions::ManagementUninstallFunctionBase::SetAutoConfirmForTest(true); extensions::ManagementUninstallFunctionBase::SetAutoConfirmForTest(true);
} }
void ExtensionSettingsUIBrowserTest::EnableErrorConsole() {
error_console_override_.reset(new extensions::FeatureSwitch::ScopedOverride(
extensions::FeatureSwitch::error_console(), true));
}
class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt {
public: public:
explicit MockAutoConfirmExtensionInstallPrompt( explicit MockAutoConfirmExtensionInstallPrompt(
...@@ -107,7 +112,7 @@ class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { ...@@ -107,7 +112,7 @@ class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt {
const Extension* ExtensionSettingsUIBrowserTest::InstallUnpackedExtension( const Extension* ExtensionSettingsUIBrowserTest::InstallUnpackedExtension(
const base::FilePath& path) { const base::FilePath& path) {
if (path.empty()) if (path.empty())
return NULL; return nullptr;
Profile* profile = GetProfile(); Profile* profile = GetProfile();
ExtensionService* service = ExtensionService* service =
...@@ -143,7 +148,7 @@ const Extension* ExtensionSettingsUIBrowserTest::InstallExtension( ...@@ -143,7 +148,7 @@ const Extension* ExtensionSettingsUIBrowserTest::InstallExtension(
base::FilePath crx_path = path; base::FilePath crx_path = path;
DCHECK(crx_path.Extension() == FILE_PATH_LITERAL(".crx")); DCHECK(crx_path.Extension() == FILE_PATH_LITERAL(".crx"));
if (crx_path.empty()) if (crx_path.empty())
return NULL; return nullptr;
scoped_refptr<extensions::CrxInstaller> installer( scoped_refptr<extensions::CrxInstaller> installer(
extensions::CrxInstaller::Create(service, install_ui.Pass())); extensions::CrxInstaller::Create(service, install_ui.Pass()));
...@@ -180,10 +185,10 @@ const Extension* ExtensionSettingsUIBrowserTest::InstallExtension( ...@@ -180,10 +185,10 @@ const Extension* ExtensionSettingsUIBrowserTest::InstallExtension(
iter != errors->end(); ++iter) iter != errors->end(); ++iter)
VLOG(1) << *iter; VLOG(1) << *iter;
return NULL; return nullptr;
} }
if (!observer_->WaitForExtensionViewsToLoad()) if (!observer_->WaitForExtensionViewsToLoad())
return NULL; return nullptr;
return service->GetExtensionById(last_loaded_extension_id(), false); return service->GetExtensionById(last_loaded_extension_id(), false);
} }
...@@ -6,9 +6,11 @@ ...@@ -6,9 +6,11 @@
#define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_BROWSERTEST_H_ #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_SETTINGS_BROWSERTEST_H_
#include "chrome/browser/extensions/extension_test_notification_observer.h" #include "chrome/browser/extensions/extension_test_notification_observer.h"
#include "chrome/common/extensions/features/feature_channel.h"
#include "chrome/test/base/web_ui_browser_test.h" #include "chrome/test/base/web_ui_browser_test.h"
#include "extensions/browser/test_management_policy.h" #include "extensions/browser/test_management_policy.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/feature_switch.h"
class Profile; class Profile;
...@@ -40,6 +42,9 @@ class ExtensionSettingsUIBrowserTest : public WebUIBrowserTest { ...@@ -40,6 +42,9 @@ class ExtensionSettingsUIBrowserTest : public WebUIBrowserTest {
void SetAutoConfirmUninstall(); void SetAutoConfirmUninstall();
// Enables the error console so errors are displayed in the extensions page.
void EnableErrorConsole();
private: private:
bool WaitForExtensionViewsToLoad(); bool WaitForExtensionViewsToLoad();
const extensions::Extension* InstallUnpackedExtension( const extensions::Extension* InstallUnpackedExtension(
...@@ -56,6 +61,9 @@ class ExtensionSettingsUIBrowserTest : public WebUIBrowserTest { ...@@ -56,6 +61,9 @@ class ExtensionSettingsUIBrowserTest : public WebUIBrowserTest {
base::FilePath test_data_dir_; base::FilePath test_data_dir_;
// Used to enable the error console.
scoped_ptr<extensions::FeatureSwitch::ScopedOverride> error_console_override_;
DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsUIBrowserTest); DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsUIBrowserTest);
}; };
......
...@@ -7,9 +7,11 @@ ...@@ -7,9 +7,11 @@
GEN('#include "chrome/browser/ui/webui/extensions/' + GEN('#include "chrome/browser/ui/webui/extensions/' +
'extension_settings_browsertest.h"'); 'extension_settings_browsertest.h"');
// chrome/test/data/extensions/good.crx's extension ID. good.crx is loaded by // The id of the extension from |InstallGoodExtension|.
// ExtensionSettingsUIBrowserTest::InstallGoodExtension() in some of the tests. var GOOD_EXTENSION_ID = 'ldnnhddmnhbkjipkidpdiheffobcpfmf';
var GOOD_CRX_ID = 'ldnnhddmnhbkjipkidpdiheffobcpfmf';
// The id of the extension from |InstallErrorsExtension|.
var ERROR_EXTENSION_ID = 'pdlpifnclfacjobnmbpngemkalkjamnf';
/** /**
* Test C++ fixture for settings WebUI testing. * Test C++ fixture for settings WebUI testing.
...@@ -199,11 +201,11 @@ BasicExtensionSettingsWebUITest.prototype = { ...@@ -199,11 +201,11 @@ BasicExtensionSettingsWebUITest.prototype = {
var listener = new UpdateListener( var listener = new UpdateListener(
chrome.developerPrivate.EventType.UNLOADED, chrome.developerPrivate.EventType.UNLOADED,
function() { function() {
var node = getRequiredElement(GOOD_CRX_ID); var node = getRequiredElement(GOOD_EXTENSION_ID);
assertTrue(node.classList.contains('inactive-extension')); assertTrue(node.classList.contains('inactive-extension'));
this.nextStep(); this.nextStep();
}.bind(this)); }.bind(this));
chrome.management.setEnabled(GOOD_CRX_ID, false); chrome.management.setEnabled(GOOD_EXTENSION_ID, false);
}, },
/** @protected */ /** @protected */
...@@ -211,11 +213,11 @@ BasicExtensionSettingsWebUITest.prototype = { ...@@ -211,11 +213,11 @@ BasicExtensionSettingsWebUITest.prototype = {
var listener = new UpdateListener( var listener = new UpdateListener(
chrome.developerPrivate.EventType.LOADED, chrome.developerPrivate.EventType.LOADED,
function() { function() {
var node = getRequiredElement(GOOD_CRX_ID); var node = getRequiredElement(GOOD_EXTENSION_ID);
assertFalse(node.classList.contains('inactive-extension')); assertFalse(node.classList.contains('inactive-extension'));
this.nextStep(); this.nextStep();
}.bind(this)); }.bind(this));
chrome.management.setEnabled(GOOD_CRX_ID, true); chrome.management.setEnabled(GOOD_EXTENSION_ID, true);
}, },
/** @protected */ /** @protected */
...@@ -223,11 +225,11 @@ BasicExtensionSettingsWebUITest.prototype = { ...@@ -223,11 +225,11 @@ BasicExtensionSettingsWebUITest.prototype = {
var listener = new UpdateListener( var listener = new UpdateListener(
chrome.developerPrivate.EventType.UNINSTALLED, chrome.developerPrivate.EventType.UNINSTALLED,
function() { function() {
assertEquals(null, $(GOOD_CRX_ID)); assertEquals(null, $(GOOD_EXTENSION_ID));
this.nextStep(); this.nextStep();
}.bind(this)); }.bind(this));
chrome.test.runWithUserGesture(function() { chrome.test.runWithUserGesture(function() {
chrome.management.uninstall(GOOD_CRX_ID); chrome.management.uninstall(GOOD_EXTENSION_ID);
}); });
}, },
}; };
...@@ -271,33 +273,36 @@ TEST_F('BasicExtensionSettingsWebUITest', 'testNonEmptyExtensionList', ...@@ -271,33 +273,36 @@ TEST_F('BasicExtensionSettingsWebUITest', 'testNonEmptyExtensionList',
this.nextStep(); this.nextStep();
}); });
function AsyncExtensionSettingsWebUITest() {} function ErrorConsoleExtensionSettingsWebUITest() {}
AsyncExtensionSettingsWebUITest.prototype = { ErrorConsoleExtensionSettingsWebUITest.prototype = {
__proto__: ExtensionSettingsWebUITest.prototype, __proto__: ExtensionSettingsWebUITest.prototype,
/** @override */ /** @override */
testGenPreamble: function() { testGenPreamble: function() {
GEN(' EnableErrorConsole();');
GEN(' InstallGoodExtension();'); GEN(' InstallGoodExtension();');
GEN(' InstallErrorsExtension();'); GEN(' InstallErrorsExtension();');
}, },
}; };
// Still fails on CrWinClang tester. BUG=463245 TEST_F('ErrorConsoleExtensionSettingsWebUITest',
TEST_F('AsyncExtensionSettingsWebUITest', 'testErrorListButtonVisibility', function() {
'DISABLED_testErrorListButtonVisibility',
function() {
var testButtonVisibility = function() { var testButtonVisibility = function() {
var extensionList = $('extension-list-wrapper'); var extensionList = $('extension-list-wrapper');
// 2 extensions are loaded:
// The 'good' extension will have 0 errors wich means no error button.
// The 'bad' extension will have >3 manifest errors and <3 runtime errors.
// This means there will be a single error button.
var visibleButtons = extensionList.querySelectorAll( var visibleButtons = extensionList.querySelectorAll(
'.errors-link:not([hidden])'); '.errors-link:not([hidden])');
expectEquals(1, visibleButtons.length); expectEquals(1, visibleButtons.length);
if (visibleButtons.length > 0) {
var errorLink = $(ERROR_EXTENSION_ID).querySelector('.errors-link');
expectEquals(visibleButtons[0], errorLink);
var errorIcon = errorLink.querySelector('img');
expectTrue(errorIcon.classList.contains('extension-error-warning-icon'));
}
var hiddenButtons = extensionList.querySelectorAll('.errors-link[hidden]'); var hiddenButtons = extensionList.querySelectorAll('.errors-link[hidden]');
expectEquals(1, hiddenButtons.length); expectEquals(1, hiddenButtons.length);
...@@ -369,7 +374,7 @@ TEST_F('InstallGoodExtensionSettingsWebUITest', 'testAccessibility', ...@@ -369,7 +374,7 @@ TEST_F('InstallGoodExtensionSettingsWebUITest', 'testAccessibility',
TEST_F('InstallGoodExtensionSettingsWebUITest', 'showOptions', function() { TEST_F('InstallGoodExtensionSettingsWebUITest', 'showOptions', function() {
var showExtensionOptions = function() { var showExtensionOptions = function() {
var optionsOverlay = extensions.ExtensionOptionsOverlay.getInstance(); var optionsOverlay = extensions.ExtensionOptionsOverlay.getInstance();
optionsOverlay.setExtensionAndShow(GOOD_CRX_ID, 'GOOD!', '', optionsOverlay.setExtensionAndShow(GOOD_EXTENSION_ID, 'GOOD!', '',
this.nextStep.bind(this)); this.nextStep.bind(this));
// Preferred size changes don't happen in browser tests. Just fake it. // Preferred size changes don't happen in browser tests. Just fake it.
...@@ -412,7 +417,7 @@ OptionsDialogExtensionSettingsWebUITest.prototype = { ...@@ -412,7 +417,7 @@ OptionsDialogExtensionSettingsWebUITest.prototype = {
/** @override */ /** @override */
browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload + browsePreload: ExtensionSettingsWebUITest.prototype.browsePreload +
'?options=' + GOOD_CRX_ID, '?options=' + GOOD_EXTENSION_ID,
}; };
TEST_F('OptionsDialogExtensionSettingsWebUITest', 'testAccessibility', TEST_F('OptionsDialogExtensionSettingsWebUITest', 'testAccessibility',
......
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