Bug 1187914 - Part 2: Fix the display of the "Add New Rule" and "Copy" menu item in the rule and computed view r=bgrins
authorGabriel Luong <gabriel.luong@gmail.com>
Fri, 07 Aug 2015 18:14:35 -0700
changeset 256935 380be310da45a5b810ab47035588dbb2345cee9d
parent 256934 d39a9103cfb1cfc4ee8dbc62ef5adaaadb7058c3
child 256936 6e532fe19bb77bfa6965ffcd360d33bfc417ce41
push id29195
push userphilringnalda@gmail.com
push dateSun, 09 Aug 2015 01:37:55 +0000
treeherdermozilla-central@fd63d8ed9d2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1187914
milestone42.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 1187914 - Part 2: Fix the display of the "Add New Rule" and "Copy" menu item in the rule and computed view r=bgrins
browser/devtools/styleinspector/style-inspector-menu.js
browser/devtools/styleinspector/test/browser_ruleview_copy_styles.js
--- a/browser/devtools/styleinspector/style-inspector-menu.js
+++ b/browser/devtools/styleinspector/style-inspector-menu.js
@@ -215,40 +215,40 @@ StyleInspectorMenu.prototype = {
     this._updateCopyMenuItems();
 
     let showOrig = Services.prefs.getBoolPref(PREF_ORIG_SOURCES);
     this.menuitemSources.setAttribute("checked", showOrig);
 
     let enableMdnDocsTooltip = Services.prefs.getBoolPref(PREF_ENABLE_MDN_DOCS_TOOLTIP);
     this.menuitemShowMdnDocs.hidden = !(enableMdnDocsTooltip && this._isPropertyName());
 
+    this.menuitemAddRule.hidden = !this.isRuleView;
     this.menuitemAddRule.disabled = !(this.isRuleView && !this.inspector.selection.isAnonymousNode());
   },
 
   /**
    * Display the necessary copy context menu items depending on the clicked
    * node and selection in the rule view.
    */
   _updateCopyMenuItems: function() {
-    this.menuitemCopy.hidden = !this._hasTextSelected();
+    this.menuitemCopy.disabled = !this._hasTextSelected();
+
     this.menuitemCopyColor.hidden = !this._isColorPopup();
     this.menuitemCopyImageDataUrl.hidden = !this._isImageUrl();
     this.menuitemCopyUrl.hidden = !this._isImageUrl();
+    this.menuitemCopyRule.hidden = !this.isRuleView;
 
-    this.menuitemCopyRule.hidden = true;
     this.menuitemCopyLocation.hidden = true;
     this.menuitemCopyPropertyDeclaration.hidden = true;
     this.menuitemCopyPropertyName.hidden = true;
     this.menuitemCopyPropertyValue.hidden = true;
     this.menuitemCopySelector.hidden = true;
 
     this._clickedNodeInfo = this._getClickedNodeInfo();
     if (this.isRuleView && this._clickedNodeInfo) {
-      this.menuitemCopyRule.hidden = false;
-
       switch (this._clickedNodeInfo.type) {
         case overlays.VIEW_NODE_PROPERTY_TYPE :
           this.menuitemCopyPropertyDeclaration.hidden = false;
           this.menuitemCopyPropertyName.hidden = false;
           break;
         case overlays.VIEW_NODE_VALUE_TYPE :
           this.menuitemCopyPropertyDeclaration.hidden = false;
           this.menuitemCopyPropertyValue.hidden = false;
--- a/browser/devtools/styleinspector/test/browser_ruleview_copy_styles.js
+++ b/browser/devtools/styleinspector/test/browser_ruleview_copy_styles.js
@@ -191,17 +191,20 @@ add_task(function*() {
 });
 
 function* checkCopyStyle(view, node, menuItem, expectedPattern, hidden) {
   let onPopup = once(view._contextmenu._menupopup, "popupshown");
   EventUtils.synthesizeMouseAtCenter(node,
     {button: 2, type: "contextmenu"}, view.styleWindow);
   yield onPopup;
 
-  is(view._contextmenu.menuitemCopy.hidden, true, "Copy hidden is as expected: true");
+  ok(view._contextmenu.menuitemCopy.disabled,
+    "Copy disabled is as expected: true");
+  ok(!view._contextmenu.menuitemCopy.hidden,
+    "Copy hidden is as expected: false");
 
   is(view._contextmenu.menuitemCopyLocation.hidden,
      hidden.copyLocation,
      "Copy Location hidden attribute is as expected: " +
      hidden.copyLocation);
 
   is(view._contextmenu.menuitemCopyPropertyDeclaration.hidden,
      hidden.copyPropertyDeclaration,