Bug 1517187 - fix rulers and measure buttons to display state; r=jdescottes
authoryulia <ystartsev@mozilla.com>
Mon, 07 Jan 2019 11:13:28 +0000
changeset 509801 b70afc7d2c99eff0faa1835580cbd5f3388bbe0c
parent 509800 4b28aeacad99de8473b64b11974687b1afb87075
child 509802 1399a4ceda2e2f43d1db23aae19d52d8720a4a8d
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1517187
milestone66.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 1517187 - fix rulers and measure buttons to display state; r=jdescottes This fixes an issue with the buttons and also adds a test Differential Revision: https://phabricator.services.mozilla.com/D15730
devtools/client/definitions.js
devtools/client/framework/test/browser_toolbox_options_disable_buttons.js
--- a/devtools/client/definitions.js
+++ b/devtools/client/definitions.js
@@ -591,17 +591,21 @@ function createHighlightButton(highlight
       // Starting with FF63, higlighter's spec accept a null first argument.
       // Still pass an empty object to fake a domnode front in order to support old
       // servers.
       return highlighter.show({});
     },
     isChecked(toolbox) {
       // if the inspector doesn't exist, then the highlighter has not yet been connected
       // to the front end.
-      const inspectorFront = toolbox.target.getCachedFront("inspector");
+      // TODO: we are using target._inspector here, but we should be using
+      // target.getCachedFront. This is a temporary solution until the inspector no
+      // longer relies on the toolbox and can be destroyed the same way any other
+      // front would be. Related: #1487677
+      const inspectorFront = toolbox.target._inspector;
       if (!inspectorFront) {
         // initialize the inspector front asyncronously. There is a potential for buggy
         // behavior here, but we need to change how the buttons get data (have them
         // consume data from reducers rather than writing our own version) in order to
         // fix this properly.
         return false;
       }
       const highlighter = inspectorFront.getKnownHighlighter(highlighterName);
--- a/devtools/client/framework/test/browser_toolbox_options_disable_buttons.js
+++ b/devtools/client/framework/test/browser_toolbox_options_disable_buttons.js
@@ -16,16 +16,17 @@ var doc = null, toolbox = null, panelWin
 
 function test() {
   addTab(TEST_URL).then(async (tab) => {
     const target = await TargetFactory.forTab(tab);
     gDevTools.showToolbox(target)
       .then(testSelectTool)
       .then(testToggleToolboxButtons)
       .then(testPrefsAreRespectedWhenReopeningToolbox)
+      .then(testButtonStateOnClick)
       .then(cleanup, errorHandler);
   });
 }
 
 async function testPrefsAreRespectedWhenReopeningToolbox() {
   const target = await TargetFactory.forTab(gBrowser.selectedTab);
 
   return new Promise(resolve => {
@@ -74,16 +75,36 @@ function testPreferenceAndUIStateIsConsi
     const check = checkNodes.filter(node => node.id === tool.id)[0];
     if (check) {
       is(check.checked, isVisible,
         "Checkbox should be selected based on current pref for " + tool.id);
     }
   }
 }
 
+async function testButtonStateOnClick() {
+  const toolboxButtons = ["#command-button-rulers", "#command-button-measure"];
+  for (const toolboxButton of toolboxButtons) {
+    const button = doc.querySelector(toolboxButton);
+    if (button) {
+      const isChecked = waitUntil(() => button.classList.contains("checked"));
+
+      button.click();
+      await isChecked;
+      ok(button.classList.contains("checked"),
+        `Button for ${toolboxButton} can be toggled on`);
+
+      const isUnchecked = waitUntil(() => !button.classList.contains("checked"));
+      button.click();
+      await isUnchecked;
+      ok(!button.classList.contains("checked"),
+        `Button for ${toolboxButton} can be toggled off`);
+    }
+  }
+}
 function testToggleToolboxButtons() {
   const checkNodes = [...panelWin.document.querySelectorAll(
     "#enabled-toolbox-buttons-box input[type=checkbox]")];
 
   const visibleToolbarButtons = toolbox.toolbarButtons.filter(tool => tool.isVisible);
 
   const toolbarButtonNodes = [...doc.querySelectorAll(".command-button")];