diff --git a/browser/base/content/test/forms/browser_selectpopup_colors.js b/browser/base/content/test/forms/browser_selectpopup_colors.js index a197d4ea9f0a..d88093df2cb3 100644 --- a/browser/base/content/test/forms/browser_selectpopup_colors.js +++ b/browser/base/content/test/forms/browser_selectpopup_colors.js @@ -91,6 +91,15 @@ const DISABLED_OPTGROUP_AND_OPTIONS = ' ' + ""; +const SELECT_CHANGES_COLOR_ON_FOCUS = + "" + + ""; + function getSystemColor(color) { // Need to convert system color to RGB color. let textarea = document.createElementNS("http://www.w3.org/1999/xhtml", "textarea"); @@ -279,3 +288,12 @@ add_task(function* test_disabled_optgroup_and_options() { yield testSelectColors(DISABLED_OPTGROUP_AND_OPTIONS, 17, {skipSelectColorTest: true}); }); + +add_task(function* test_disabled_optgroup_and_options() { + let options = { + selectColor: "rgb(0, 0, 0)", + selectBgColor: "rgb(255, 165, 0)" + }; + + yield testSelectColors(SELECT_CHANGES_COLOR_ON_FOCUS, 2, options); +}); diff --git a/toolkit/modules/SelectContentHelper.jsm b/toolkit/modules/SelectContentHelper.jsm index 85e376ccba7e..5101ec53ae31 100644 --- a/toolkit/modules/SelectContentHelper.jsm +++ b/toolkit/modules/SelectContentHelper.jsm @@ -94,9 +94,11 @@ this.SelectContentHelper.prototype = { showDropDown() { this.element.openInParentProcess = true; let rect = this._getBoundingContentRect(); + DOMUtils.addPseudoClassLock(this.element, ":focus"); let computedStyles = getComputedStyles(this.element); this._selectBackgroundColor = computedStyles.backgroundColor; this._selectColor = computedStyles.color; + DOMUtils.clearPseudoClassLocks(this.element); this.global.sendAsyncMessage("Forms:ShowDropDown", { direction: computedStyles.direction, isOpenedViaTouch: this.isOpenedViaTouch, @@ -124,6 +126,14 @@ this.SelectContentHelper.prototype = { _update() { // The