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