Bug 1703411 - Update browser_ext_themes_findbar.js to check that prev/next border colors are unchanged when a theme is applied if Proton is enabled. r=Gijs
authorJared Wein <jwein@mozilla.com>
Wed, 07 Apr 2021 14:42:39 +0000
changeset 574827 a5049f34129eeb1904a4dcbbec13485f868bdca7
parent 574826 cc8b64f3831b7fb8d5d8fbff8ab5659ded8fd485
child 574828 ca08f26c61065818b460dbd3c256775ea743e025
push id38355
push userabutkovits@mozilla.com
push dateWed, 07 Apr 2021 21:25:27 +0000
treeherdermozilla-central@b740f950e497 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1703411
milestone89.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1703411 - Update browser_ext_themes_findbar.js to check that prev/next border colors are unchanged when a theme is applied if Proton is enabled. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D111111
toolkit/components/extensions/test/browser/browser_ext_themes_findbar.js
--- a/toolkit/components/extensions/test/browser/browser_ext_themes_findbar.js
+++ b/toolkit/components/extensions/test/browser/browser_ext_themes_findbar.js
@@ -1,13 +1,53 @@
 "use strict";
 
 // This test checks whether applied WebExtension themes that attempt to change
 // the toolbar and toolbar_field properties also theme the findbar.
 
+function getBorderColors(element) {
+  let computedStyle = window.getComputedStyle(element);
+  let {
+    borderLeftColor,
+    borderRightColor,
+    borderTopColor,
+    borderBottomColor,
+  } = computedStyle;
+  return {
+    borderLeftColor,
+    borderRightColor,
+    borderTopColor,
+    borderBottomColor,
+  };
+}
+
+function testBorderColorsUnchanged(element, expected) {
+  let computedStyle = window.getComputedStyle(element);
+  Assert.equal(
+    computedStyle.borderLeftColor,
+    expected.borderLeftColor,
+    "Element left border color should be unchanged."
+  );
+  Assert.equal(
+    computedStyle.borderRightColor,
+    expected.borderRightColor,
+    "Element right border color should be unchanged."
+  );
+  Assert.equal(
+    computedStyle.borderTopColor,
+    expected.borderTopColor,
+    "Element top border color should be unchanged."
+  );
+  Assert.equal(
+    computedStyle.borderBottomColor,
+    expected.borderBottomColor,
+    "Element bottom border color should be unchanged."
+  );
+}
+
 add_task(async function test_support_toolbar_properties_on_findbar() {
   const TOOLBAR_COLOR = "#ff00ff";
   const TOOLBAR_TEXT_COLOR = "#9400ff";
   const ACCENT_COLOR_INACTIVE = "#ffff00";
   // The TabContextMenu initializes its strings only on a focus or mouseover event.
   // Calls focus event on the TabContextMenu early in the test.
   gBrowser.selectedTab.focus();
   let extension = ExtensionTestUtils.loadExtension({
@@ -56,16 +96,21 @@ add_task(async function test_support_too
     "Findbar background changed in inactive window."
   );
   await BrowserTestUtils.closeWindow(window2);
 
   await extension.unload();
 });
 
 add_task(async function test_support_toolbar_field_properties_on_findbar() {
+  let findbar_prev_button = gFindBar.getElement("find-previous");
+  let findbar_next_button = gFindBar.getElement("find-next");
+  let prev_button_orig_borders = getBorderColors(findbar_prev_button);
+  let next_button_orig_borders = getBorderColors(findbar_next_button);
+
   const TOOLBAR_FIELD_COLOR = "#ff00ff";
   const TOOLBAR_FIELD_TEXT_COLOR = "#9400ff";
   const TOOLBAR_FIELD_BORDER_COLOR = "#ffffff";
   // The TabContextMenu initializes its strings only on a focus or mouseover event.
   // Calls focus event on the TabContextMenu early in the test.
   gBrowser.selectedTab.focus();
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
@@ -81,38 +126,39 @@ add_task(async function test_support_too
     },
   });
 
   await extension.startup();
   await gBrowser.getFindBar();
 
   let findbar_textbox = gFindBar.getElement("findbar-textbox");
 
-  let findbar_prev_button = gFindBar.getElement("find-previous");
-
-  let findbar_next_button = gFindBar.getElement("find-next");
-
   info(
     "Checking findbar textbox background is set as toolbar field background color"
   );
   Assert.equal(
     window.getComputedStyle(findbar_textbox).backgroundColor,
     hexToCSS(TOOLBAR_FIELD_COLOR),
     "Findbar textbox background color should be the same as toolbar field color."
   );
 
   info("Checking findbar textbox color is set as toolbar field text color");
   Assert.equal(
     window.getComputedStyle(findbar_textbox).color,
     hexToCSS(TOOLBAR_FIELD_TEXT_COLOR),
     "Findbar textbox text color should be the same as toolbar field text color."
   );
   testBorderColor(findbar_textbox, TOOLBAR_FIELD_BORDER_COLOR);
-  testBorderColor(findbar_prev_button, TOOLBAR_FIELD_BORDER_COLOR);
-  testBorderColor(findbar_next_button, TOOLBAR_FIELD_BORDER_COLOR);
+  if (!gProton) {
+    testBorderColor(findbar_prev_button, TOOLBAR_FIELD_BORDER_COLOR);
+    testBorderColor(findbar_next_button, TOOLBAR_FIELD_BORDER_COLOR);
+  } else {
+    testBorderColorsUnchanged(findbar_prev_button, prev_button_orig_borders);
+    testBorderColorsUnchanged(findbar_next_button, next_button_orig_borders);
+  }
 
   await extension.unload();
 });
 
 // Test that theme properties are *not* applied with a theme_frame (see bug 1506913)
 add_task(async function test_toolbar_properties_on_findbar_with_theme_frame() {
   const TOOLBAR_COLOR = "#ff00ff";
   const TOOLBAR_TEXT_COLOR = "#9400ff";