Bug 1352801 - Disable MDN tooltip feature in rule inspector. r=gl
☠☠ backed out by 28499f4d90d1 ☠ ☠
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 04 Apr 2017 11:12:26 +0200
changeset 352066 f74ec3b3a49a33a57a3790c59605a2422ef5c4d6
parent 352065 9cb7026d8afbf73b436451ce15875017b5e1ceb7
child 352067 28499f4d90d126b37eb50e9a068b03f8f4e9c700
push id40369
push userarchaeopteryx@coole-files.de
push dateSun, 09 Apr 2017 19:53:36 +0000
treeherderautoland@f74ec3b3a49a [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,37 +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,
--- 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);