Bug 1352801 - Disable MDN tooltip feature in rule inspector. r=gl
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sun, 09 Apr 2017 21:53:18 +0200
changeset 352073 bd4e6fe9b545d1dd47cc2519b020c6e52829f2e8
parent 352072 daddaedcf97f28f1dd06c52528b5fa2f163bd2d8
child 352074 7241e9e495e48da17650a79c08efeac09e8be1f9
push id40373
push userarchaeopteryx@coole-files.de
push dateSun, 09 Apr 2017 22:31:38 +0000
treeherderautoland@bd4e6fe9b545 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1352801
milestone55.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 1352801 - Disable MDN tooltip feature in rule inspector. r=gl MozReview-Commit-ID: 6QOi9yqKcVH
devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-01.js
devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-03.js
devtools/client/preferences/devtools.js
--- a/devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-01.js
+++ b/devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-01.js
@@ -16,38 +16,81 @@
 
 "use strict";
 
 /**
  * The test document tries to confuse the context menu
  * code by having a tag called "padding" and a property
  * value called "margin".
  */
+
+const { PrefObserver } = require("devtools/client/shared/prefs");
+const PREF_ENABLE_MDN_DOCS_TOOLTIP =
+  "devtools.inspector.mdnDocsTooltip.enabled";
+
 const TEST_URI = `
   <html>
     <head>
       <style>
         padding {font-family: margin;}
       </style>
     </head>
 
     <body>
       <padding>MDN tooltip testing</padding>
     </body>
   </html>
 `;
 
 add_task(function* () {
+  info("Ensure the pref is true to begin with");
+  let initial = Services.prefs.getBoolPref(PREF_ENABLE_MDN_DOCS_TOOLTIP);
+  if (initial != true) {
+    yield setBooleanPref(PREF_ENABLE_MDN_DOCS_TOOLTIP, true);
+  }
+
   yield addTab("data:text/html;charset=utf8," + encodeURIComponent(TEST_URI));
   let {inspector, view} = yield openRuleView();
   yield selectNode("padding", inspector);
   yield testMdnContextMenuItemVisibility(view);
+
+  info("Ensure the pref is reset to its initial value");
+  let eventual = Services.prefs.getBoolPref(PREF_ENABLE_MDN_DOCS_TOOLTIP);
+  if (eventual != initial) {
+    yield setBooleanPref(PREF_ENABLE_MDN_DOCS_TOOLTIP, initial);
+  }
 });
 
 /**
+ * Set a boolean pref, and wait for the pref observer to
+ * trigger, so that code listening for the pref change
+ * has had a chance to update itself.
+ *
+ * @param pref {string} Name of the pref to change
+ * @param state {boolean} Desired value of the pref.
+ *
+ * Note that if the pref already has the value in `state`,
+ * then the prefObserver will not trigger. So you should only
+ * call this function if you know the pref's current value is
+ * not `state`.
+ */
+function* setBooleanPref(pref, state) {
+  let oncePrefChanged = defer();
+  let prefObserver = new PrefObserver("devtools.");
+  prefObserver.on(pref, oncePrefChanged.resolve);
+
+  info("Set the pref " + pref + " to: " + state);
+  Services.prefs.setBoolPref(pref, state);
+
+  info("Wait for prefObserver to call back so the UI can update");
+  yield oncePrefChanged.promise;
+  prefObserver.off(pref, oncePrefChanged.resolve);
+}
+
+/**
  * Tests that the MDN context menu item is shown when it should be,
  * and hidden when it should be.
  *   - iterate through every node in the rule view
  *   - set that node as popupNode (the node that the context menu
  *   is shown for)
  *   - update the context menu's state
  *   - test that the MDN context menu item is hidden, or not,
  *   depending on popupNode
--- a/devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-03.js
+++ b/devtools/client/inspector/rules/test/browser_rules_context-menu-show-mdn-docs-03.js
@@ -28,17 +28,17 @@ const TEST_DOC = `
     </body>
   </html>
 `;
 
 add_task(function* () {
   info("Ensure the pref is true to begin with");
   let initial = Services.prefs.getBoolPref(PREF_ENABLE_MDN_DOCS_TOOLTIP);
   if (initial != true) {
-    setBooleanPref(PREF_ENABLE_MDN_DOCS_TOOLTIP, true);
+    yield setBooleanPref(PREF_ENABLE_MDN_DOCS_TOOLTIP, true);
   }
 
   yield addTab("data:text/html;charset=utf8," + encodeURIComponent(TEST_DOC));
 
   let {inspector, view} = yield openRuleView();
   yield selectNode("div", inspector);
   yield testMdnContextMenuItemVisibility(view, true);
 
@@ -54,17 +54,17 @@ add_task(function* () {
   yield testMdnContextMenuItemVisibility(view, false);
 
   yield setBooleanPref(PREF_ENABLE_MDN_DOCS_TOOLTIP, true);
   yield testMdnContextMenuItemVisibility(view, true);
 
   info("Ensure the pref is reset to its initial value");
   let eventual = Services.prefs.getBoolPref(PREF_ENABLE_MDN_DOCS_TOOLTIP);
   if (eventual != initial) {
-    setBooleanPref(PREF_ENABLE_MDN_DOCS_TOOLTIP, initial);
+    yield setBooleanPref(PREF_ENABLE_MDN_DOCS_TOOLTIP, initial);
   }
 });
 
 /**
  * Set a boolean pref, and wait for the pref observer to
  * trigger, so that code listening for the pref change
  * has had a chance to update itself.
  *
--- a/devtools/client/preferences/devtools.js
+++ b/devtools/client/preferences/devtools.js
@@ -57,17 +57,17 @@ pref("devtools.inspector.remote", false)
 pref("devtools.inspector.show_pseudo_elements", false);
 // The default size for image preview tooltips in the rule-view/computed-view/markup-view
 pref("devtools.inspector.imagePreviewTooltipSize", 300);
 // Enable user agent style inspection in rule-view
 pref("devtools.inspector.showUserAgentStyles", false);
 // Show all native anonymous content (like controls in <video> tags)
 pref("devtools.inspector.showAllAnonymousContent", false);
 // Enable the MDN docs tooltip
-pref("devtools.inspector.mdnDocsTooltip.enabled", true);
+pref("devtools.inspector.mdnDocsTooltip.enabled", false);
 // Enable the new color widget
 pref("devtools.inspector.colorWidget.enabled", false);
 
 // Enable the Font Inspector
 pref("devtools.fontinspector.enabled", true);
 
 // Enable the Layout View
 pref("devtools.layoutview.enabled", false);