Bug 1354336 - Require all browser_style elements to have the browser-style class r?mikedeboer
MozReview-Commit-ID: 6bQZDa3zZA3
--- a/browser/components/extensions/extension-mac.css
+++ b/browser/components/extensions/extension-mac.css
@@ -1,11 +1,11 @@
-button,
-select,
-input[type="checkbox"] + label::before {
+button.browser-style,
+select.browser-style,
+.browser-style > input[type="checkbox"] + label::before {
border-radius: 4px;
}
.panel-section-footer {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
overflow: hidden;
}
--- a/browser/components/extensions/extension.css
+++ b/browser/components/extensions/extension.css
@@ -1,19 +1,12 @@
/* stylelint-disable property-no-vendor-prefix */
/* stylelint-disable property-no-vendor-prefix */
-/* Base */
-button,
-select,
-option,
-input {
- -moz-appearance: none;
-}
-/* Variables */
+/* Global */
html,
body {
background: transparent;
box-sizing: border-box;
color: #222426;
cursor: default;
display: flex;
flex-direction: column;
@@ -23,349 +16,345 @@ body {
-moz-user-select: none;
}
body * {
box-sizing: border-box;
text-align: start;
}
+.browser-style {
+ -moz-appearance: none;
+ margin-bottom: 6px;
+ text-align: left;
+}
+
/* stylelint-disable property-no-vendor-prefix */
/* Buttons */
-button,
-select {
+button.browser-style,
+select.browser-style {
background-color: #fbfbfb;
border: 1px solid #b1b1b1;
box-shadow: 0 0 0 0 transparent;
font: caption;
height: 24px;
outline: 0 !important;
padding: 0 8px 0;
transition-duration: 250ms;
transition-property: box-shadow, border;
}
-select {
+select.browser-style {
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBkPSJNOCwxMkwzLDcsNCw2bDQsNCw0LTQsMSwxWiIgZmlsbD0iIzZBNkE2QSIgLz4KPC9zdmc+Cg==);
background-position: calc(100% - 4px) center;
background-repeat: no-repeat;
padding-inline-end: 24px;
text-overflow: ellipsis;
}
-label {
+label.browser-style-label {
font: caption;
}
-button::-moz-focus-inner {
+button.browser-style::-moz-focus-inner {
border: 0;
outline: 0;
}
/* Dropdowns */
-select {
+select.browser-style {
background-color: #fbfbfb;
border: 1px solid #b1b1b1;
box-shadow: 0 0 0 0 transparent;
font: caption;
height: 24px;
outline: 0 !important;
padding: 0 8px 0;
transition-duration: 250ms;
transition-property: box-shadow, border;
}
-select {
+select.browser-style {
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBkPSJNOCwxMkwzLDcsNCw2bDQsNCw0LTQsMSwxWiIgZmlsbD0iIzZBNkE2QSIgLz4KPC9zdmc+Cg==);
background-position: calc(100% - 4px) center;
background-repeat: no-repeat;
padding-inline-end: 24px;
text-overflow: ellipsis;
}
-select:-moz-focusring {
+select.browser-style:-moz-focusring {
color: transparent;
text-shadow: 0 0 0 #000;
}
-select:-moz-focusring * {
+select.browser-style:-moz-focusring * {
color: #000;
text-shadow: none;
}
-button.hover,
-select.hover {
+button.browser-style.hover,
+select.browser-style.hover {
background-color: #ebebeb;
border: 1px solid #b1b1b1;
}
-button.pressed,
-select.pressed {
+button.browser-style.pressed,
+select.browser-style.pressed {
background-color: #d4d4d4;
border: 1px solid #858585;
}
-button.disabled,
-select.disabled {
+button.browser-style.disabled,
+select.browser-style.disabled {
color: #999;
opacity: .5;
}
-button.focused,
-select.focused {
+button.browser-style.focused,
+select.browser-style.focused {
border-color: #fff;
box-shadow: 0 0 0 2px rgba(97, 181, 255, 0.75);
}
-button.default {
+button.browser-style.default {
background-color: #0996f8;
border-color: #0670cc;
color: #fff;
}
-button.default.hover {
+button.browser-style.default.hover {
background-color: #0670cc;
border-color: #005bab;
}
-button.default.pressed {
+button.browser-style.default.pressed {
background-color: #005bab;
border-color: #004480;
}
-button.default.focused {
+button.browser-style.default.focused {
border-color: #fff;
}
/* Radio Buttons */
-.radioItem {
- margin-bottom: 6px;
- text-align: left;
-}
-
-input[type="radio"] {
+.browser-style > input[type="radio"] {
display: none;
}
-input[type="radio"] + label {
+.browser-style > input[type="radio"] + label {
-moz-user-select: none;
}
-input[type="radio"] + label::before {
+.browser-style > input[type="radio"] + label::before {
background-color: #fff;
background-position: center;
border: 1px solid #b1b1b1;
border-radius: 50%;
content: "";
display: inline-block;
height: 16px;
margin-right: 6px;
vertical-align: text-top;
width: 16px;
}
-input[type="radio"]:hover + label::before,
-.radioItem.hover input[type="radio"]:not(active) + label::before {
+.browser-style > input[type="radio"]:hover + label::before,
+.browser-style.hover > input[type="radio"]:not(active) + label::before {
background-color: #fbfbfb;
border-color: #b1b1b1;
}
-input[type="radio"]:hover:active + label::before,
-.radioItem.pressed input[type="radio"]:not(active) + label::before {
+.browser-style > input[type="radio"]:hover:active + label::before,
+.browser-style.pressed > input[type="radio"]:not(active) + label::before {
background-color: #ebebeb;
border-color: #858585;
}
-input[type="radio"]:checked + label::before {
+.browser-style > input[type="radio"]:checked + label::before {
background-color: #0996f8;
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8Y2lyY2xlIGN4PSI4IiBjeT0iOCIgcj0iNCIgZmlsbD0iI2ZmZiIgLz4KPC9zdmc+Cg==);
border-color: #0670cc;
}
-input[type="radio"]:checked:hover + label::before,
-.radioItem.hover input[type="radio"]:checked:not(active) + label::before {
+.browser-style > input[type="radio"]:checked:hover + label::before,
+.browser-style.hover > input[type="radio"]:checked:not(active) + label::before {
background-color: #0670cc;
border-color: #005bab;
}
-input[type="radio"]:checked:hover:active + label::before,
-.radioItem.pressed input[type="radio"]:checked:not(active) + label::before {
+.browser-style > input[type="radio"]:checked:hover:active + label::before,
+.browser-style.pressed > input[type="radio"]:checked:not(active) + label::before {
background-color: #005bab;
border-color: #004480;
}
-.radioItem.disabled input[type="radio"] + label,
-.radioItem.disabled input[type="radio"]:hover + label,
-.radioItem.disabled input[type="radio"]:hover:active + label {
+.browser-style.disabled > input[type="radio"] + label,
+.browser-style.disabled > input[type="radio"]:hover + label,
+.browser-style.disabled > input[type="radio"]:hover:active + label {
color: #999;
opacity: .5;
}
-.radioItem.focused input[type="radio"] + label::before {
+.browser-style.focused > input[type="radio"] + label::before {
border-color: #0996f8;
box-shadow: 0 0 0 2px rgba(97, 181, 255, 0.75);
}
-.radioItem.focused input[type="radio"]:checked + label::before {
+.browser-style.focused > input[type="radio"]:checked + label::before {
border-color: #fff;
}
/* Checkboxes */
-.checkboxItem {
- margin-bottom: 6px;
- text-align: left;
-}
-
-input[type="checkbox"] {
+.browser-style > input[type="checkbox"] {
display: none;
}
-input[type="checkbox"] + label {
+.browser-style > input[type="checkbox"] + label {
-moz-user-select: none;
}
-input[type="checkbox"] + label::before {
+.browser-style > input[type="checkbox"] + label::before {
background-color: #fff;
background-position: center;
border: 1px solid #b1b1b1;
content: "";
display: inline-block;
height: 16px;
margin-right: 6px;
vertical-align: text-top;
width: 16px;
}
-input[type="checkbox"]:hover + label::before,
-.checkboxItem.hover input[type="checkbox"]:not(active) + label::before {
+.browser-style > input[type="checkbox"]:hover + label::before,
+.browser-style.hover > input[type="checkbox"]:not(active) + label::before {
background-color: #fbfbfb;
border-color: #b1b1b1;
}
-input[type="checkbox"]:hover:active + label::before,
-.checkboxItem.pressed input[type="checkbox"]:not(active) + label::before {
+.browser-style > input[type="checkbox"]:hover:active + label::before,
+.browser-style.pressed > input[type="checkbox"]:not(active) + label::before {
background-color: #ebebeb;
border-color: #858585;
}
-input[type="checkbox"]:checked + label::before {
+.browser-style > input[type="checkbox"]:checked + label::before {
background-color: #0996f8;
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBkPSJNNy43LDEyLjkgQzcuNCwxMy4zIDYuOCwxMy40IDYuNCwxMyBMMy4yLDkuOCBDMi44LDkuNCAyLjgsOC42IDMuMiw4LjIgQzMuNiw3LjggNC40LDcuOCA0LjgsOC4yIEw2LjksMTAuMyBMMTEuMSw0LjQgQzExLjUsMy45IDEyLjIsMy44IDEyLjcsNC4xIEMxMy4yLDQuNSAxMy4zLDUuMiAxMyw1LjcgTDcuNywxMi45IEw3LjcsMTIuOSBaIiBmaWxsPSIjZmZmIiAvPgo8L3N2Zz4K);
border-color: #0670cc;
}
-input[type="checkbox"]:checked:hover + label::before,
-.checkboxItem.hover input[type="checkbox"]:checked:not(active) + label::before {
+.browser-style > input[type="checkbox"]:checked:hover + label::before,
+.browser-style.hover > input[type="checkbox"]:checked:not(active) + label::before {
background-color: #0670cc;
border-color: #005bab;
}
-input[type="checkbox"]:checked:hover:active + label::before,
-.checkboxItem.pressed input[type="checkbox"]:checked:not(active) + label::before {
+.browser-style > input[type="checkbox"]:checked:hover:active + label::before,
+.browser-style.pressed > input[type="checkbox"]:checked:not(active) + label::before {
background-color: #005bab;
border-color: #004480;
}
-.checkboxItem.disabled input[type="checkbox"] + label,
-.checkboxItem.disabled input[type="checkbox"]:hover + label,
-.checkboxItem.disabled input[type="checkbox"]:hover:active + label {
+.browser-style.disabled > input[type="checkbox"] + label,
+.browser-style.disabled > input[type="checkbox"]:hover + label,
+.browser-style.disabled > input[type="checkbox"]:hover:active + label {
color: #999;
opacity: .5;
}
-.checkboxItem.focused input[type="checkbox"] + label::before {
+.browser-style.focused > input[type="checkbox"] + label::before {
border-color: #0996f8;
box-shadow: 0 0 0 2px rgba(97, 181, 255, 0.75);
}
-.checkboxItem.focused input[type="checkbox"]:checked + label::before {
+.browser-style.focused > input[type="checkbox"]:checked + label::before {
border-color: #fff;
}
/* Expander Button */
-button.expander {
+button.browser-style.expander {
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDE2IDE2Ij4KICA8cGF0aCBkPSJNOCwxMkwzLDcsNCw2bDQsNCw0LTQsMSwxWiIgZmlsbD0iIzZBNkE2QSIgLz4KPC9zdmc+Cg==);
background-position: center;
background-repeat: no-repeat;
height: 24px;
padding: 0;
width: 24px;
}
/* Interactive States */
-button:hover:not(.pressed):not(.disabled):not(.focused),
-select:hover:not(.pressed):not(.disabled):not(.focused) {
+button.browser-style:hover:not(.pressed):not(.disabled):not(.focused),
+select.browser-style:hover:not(.pressed):not(.disabled):not(.focused) {
background-color: #ebebeb;
border: 1px solid #b1b1b1;
}
-button:hover:active:not(.hover):not(.disabled):not(.focused),
-select:hover:active:not(.hover):not(.disabled):not(.focused) {
+button.browser-style:hover:active:not(.hover):not(.disabled):not(.focused),
+select.browser-style:hover:active:not(.hover):not(.disabled):not(.focused) {
background-color: #d4d4d4;
border: 1px solid #858585;
}
-button.default:hover:not(.pressed):not(.disabled):not(.focused) {
+button.browser-style.default:hover:not(.pressed):not(.disabled):not(.focused) {
background-color: #0670cc;
border-color: #005bab;
}
-button.default:hover:active:not(.hover):not(.disabled):not(.focused) {
+button.browser-style.default:hover:active:not(.hover):not(.disabled):not(.focused) {
background-color: #005bab;
border-color: #004480;
}
-button:focus:not(.disabled) {
+button.browser-style:focus:not(.disabled) {
border-color: #fff !important;
box-shadow: 0 0 0 2px rgba(97, 181, 255, 0.75);
}
/* Fields */
-input[type="text"],
-textarea {
+.browser-style > input[type="text"],
+textarea.browser-style {
background-color: #fff;
border: 1px solid #b1b1b1;
box-shadow: 0 0 0 0 rgba(97, 181, 255, 0);
font: caption;
padding: 0 6px 0;
transition-duration: 250ms;
transition-property: box-shadow;
}
-input[type="text"] {
+.browser-style > input[type="text"] {
height: 24px;
}
-input[type="text"].hover,
-textarea.hover {
+.browser-style > input[type="text"].hover,
+textarea.browser-style.hover {
border: 1px solid #858585;
}
-input[type="text"].disabled,
-textarea.disabled {
+.browser-style > input[type="text"].disabled,
+textarea.browser-style.disabled {
color: #999;
opacity: .5;
}
-input[type="text"].focused,
-textarea.focused {
+.browser-style > input[type="text"].focused,
+textarea.browser-style.focused {
border-color: #0996f8;
box-shadow: 0 0 0 2px rgba(97, 181, 255, 0.75);
}
/* Interactive States */
-input[type="text"]:not(disabled):hover,
-textarea:not(disabled):hover {
+.browser-style > input[type="text"]:not(disabled):hover,
+textarea.browser-style:not(disabled):hover {
border: 1px solid #858585;
}
-input[type="text"]:focus,
-input[type="text"]:focus:hover,
-textarea:focus,
-textarea:focus:hover {
+.browser-style > input[type="text"]:focus,
+.browser-style > input[type="text"]:focus:hover,
+textarea.browser-style:focus,
+textarea.browser-style:focus:hover {
border-color: #0996f8;
box-shadow: 0 0 0 2px rgba(97, 181, 255, 0.75);
}
/* stylelint-disable property-no-vendor-prefix */
.panel-section {
display: flex;
flex-direction: row;
@@ -465,17 +454,17 @@ textarea:focus:hover {
.panel-formElements-item label {
flex-shrink: 0;
margin-right: 6px;
text-align: right;
}
.panel-formElements-item input[type="text"],
-.panel-formElements-item select {
+.panel-formElements-item select.browser-style {
flex-grow: 1;
}
/* Panel Section - Footer */
.panel-section-footer {
background-color: rgba(0, 0, 0, 0.06);
border-top: 1px solid rgba(0, 0, 0, 0.15);
color: #1a1a1a;
@@ -551,22 +540,22 @@ textarea:focus:hover {
.panel-section-tabs-button:hover {
background-color: rgba(0, 0, 0, 0.06);
}
.panel-section-tabs-button:hover:active {
background-color: rgba(0, 0, 0, 0.1);
}
-.panel-section-tabs-button.selected {
+.panel-section-tabs-button.select.browser-styleed {
box-shadow: 0 -1px 0 #0670cc inset, 0 -4px 0 #0996f8 inset;
color: #0996f8;
}
-.panel-section-tabs-button.selected:hover {
+.panel-section-tabs-button.select.browser-styleed:hover {
color: #0670cc;
}
.panel-section-tabs-separator {
background-color: rgba(0, 0, 0, 0.1);
width: 1px;
z-index: 99;
}
--- a/browser/components/extensions/test/browser/browser_ext_optionsPage_browser_style.js
+++ b/browser/components/extensions/test/browser/browser_ext_optionsPage_browser_style.js
@@ -6,59 +6,103 @@ requestLongerTimeout(2);
async function testOptionsBrowserStyle(optionsUI, assertMessage) {
function optionsScript() {
browser.test.onMessage.addListener((msgName, optionsUI, assertMessage) => {
if (msgName !== "check-style") {
browser.test.notifyFail("options-ui-browser_style");
}
- let style = window.getComputedStyle(document.getElementById("button"));
- let buttonBackgroundColor = style.backgroundColor;
- let browserStyleBackgroundColor = "rgb(9, 150, 248)";
- if (!("browser_style" in optionsUI) || optionsUI.browser_style) {
- browser.test.assertEq(browserStyleBackgroundColor, buttonBackgroundColor, assertMessage);
- } else {
- browser.test.assertTrue(browserStyleBackgroundColor !== buttonBackgroundColor, assertMessage);
+ let browserStyle = !("browser_style" in optionsUI) || optionsUI.browser_style;
+
+ function verifyButton(buttonElement, expected) {
+ let buttonStyle = window.getComputedStyle(buttonElement);
+ let buttonBackgroundColor = buttonStyle.backgroundColor;
+ if (browserStyle && expected.hasBrowserStyleClass) {
+ browser.test.assertEq("rgb(9, 150, 248)", buttonBackgroundColor, assertMessage);
+ } else {
+ browser.test.assertTrue(buttonBackgroundColor !== "rgb(9, 150, 248)", assertMessage);
+ }
+ }
+
+ function verifyCheckboxOrRadio(type, element, expected) {
+ let style = window.getComputedStyle(element);
+ if (browserStyle && expected.hasBrowserStyleClass) {
+ browser.test.assertEq("none", style.display, `Expected ${type} item to be hidden`);
+ } else {
+ browser.test.assertTrue(style.display != "none", `Expected ${type} item to be visible`);
+ }
}
+ let normalButton = document.getElementById("normalButton");
+ let browserStyleButton = document.getElementById("browserStyleButton");
+ verifyButton(normalButton, {hasBrowserStyleClass: false});
+ verifyButton(browserStyleButton, {hasBrowserStyleClass: true});
+
+ let normalCheckbox1 = document.getElementById("normalCheckbox1");
+ let normalCheckbox2 = document.getElementById("normalCheckbox2");
+ let browserStyleCheckbox = document.getElementById("browserStyleCheckbox");
+ verifyCheckboxOrRadio("checkbox", normalCheckbox1, {hasBrowserStyleClass: false});
+ verifyCheckboxOrRadio("checkbox", normalCheckbox2, {hasBrowserStyleClass: false});
+ verifyCheckboxOrRadio("checkbox", browserStyleCheckbox, {hasBrowserStyleClass: true});
+
+ let normalRadio1 = document.getElementById("normalRadio1");
+ let normalRadio2 = document.getElementById("normalRadio2");
+ let browserStyleRadio = document.getElementById("browserStyleRadio");
+ verifyCheckboxOrRadio("radio", normalRadio1, {hasBrowserStyleClass: false});
+ verifyCheckboxOrRadio("radio", normalRadio2, {hasBrowserStyleClass: false});
+ verifyCheckboxOrRadio("radio", browserStyleRadio, {hasBrowserStyleClass: true});
+
browser.test.notifyPass("options-ui-browser_style");
});
browser.test.sendMessage("options-ui-ready");
}
let extension = ExtensionTestUtils.loadExtension({
useAddonManager: "temporary",
manifest: {
"permissions": ["tabs"],
"options_ui": optionsUI,
},
files: {
"options.html": `
<!DOCTYPE html>
<html>
- <button id="button" name="button" class="default">Default</button>
+ <button id="normalButton" name="button" class="default">Default</button>
+ <button id="browserStyleButton" name="button" class="browser-style default">Default</button>
+
+ <input id="normalCheckbox1" type="checkbox"/>
+ <input id="normalCheckbox2" type="checkbox"/><label>Checkbox</label>
+ <div class="browser-style">
+ <input id="browserStyleCheckbox" type="checkbox"><label for="browserStyleCheckbox">Checkbox</label>
+ </div>
+
+ <input id="normalRadio1" type="radio"/>
+ <input id="normalRadio2" type="radio"/><label>Radio</label>
+ <div class="browser-style">
+ <input id="browserStyleRadio" checked="" type="radio"><label for="browserStyleRadio">Radio</label>
+ </div>
+
<script src="options.js" type="text/javascript"></script>
</html>`,
"options.js": optionsScript,
},
background() {
browser.runtime.openOptionsPage();
},
});
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
await extension.startup();
await extension.awaitMessage("options-ui-ready");
extension.sendMessage("check-style", optionsUI, assertMessage);
await extension.awaitFinish("options-ui-browser_style");
-
await BrowserTestUtils.removeTab(tab);
await extension.unload();
}
add_task(async function test_options_without_setting_browser_style() {
await testOptionsBrowserStyle({
"page": "options.html",
--- a/browser/components/extensions/test/browser/browser_ext_sidebarAction_browser_style.js
+++ b/browser/components/extensions/test/browser/browser_ext_sidebarAction_browser_style.js
@@ -28,17 +28,17 @@ async function testSidebarBrowserStyle(s
"sidebar_action": sidebarAction,
},
useAddonManager: "temporary",
files: {
"panel.html": `
<!DOCTYPE html>
<html>
- <button id="button" name="button" class="default">Default</button>
+ <button id="button" name="button" class="browser-style default">Default</button>
<script src="panel.js" type="text/javascript"></script>
</html>`,
"panel.js": sidebarScript,
},
});
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);