Bug 1021202 - Turn @media sidebar on by default; r=bgrins
authorHeather Arthur <fayearthur@gmail.com>
Wed, 11 Jun 2014 13:14:52 -0700
changeset 188313 729f6c1413c7def708a58aeaab9068b20b0103ff
parent 188312 358904c14a9c884586948d05c0f9b79b50ff53d1
child 188314 e8cf4d699fa725a35e8e853746239fb23e8db373
push id26951
push useremorley@mozilla.com
push dateThu, 12 Jun 2014 14:07:43 +0000
treeherdermozilla-central@4f98802de6ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1021202
milestone33.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 1021202 - Turn @media sidebar on by default; r=bgrins
browser/app/profile/firefox.js
browser/devtools/styleeditor/test/browser_styleeditor_media_sidebar.js
browser/devtools/styleeditor/test/browser_styleeditor_media_sidebar_sourcemaps.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1338,17 +1338,17 @@ pref("devtools.scratchpad.recentFilesMax
 pref("devtools.scratchpad.showTrailingSpace", false);
 pref("devtools.scratchpad.enableCodeFolding", true);
 pref("devtools.scratchpad.enableAutocompletion", true);
 
 // Enable the Style Editor.
 pref("devtools.styleeditor.enabled", true);
 pref("devtools.styleeditor.source-maps-enabled", false);
 pref("devtools.styleeditor.autocompletion-enabled", true);
-pref("devtools.styleeditor.showMediaSidebar", false);
+pref("devtools.styleeditor.showMediaSidebar", true);
 
 // Enable the Shader Editor.
 pref("devtools.shadereditor.enabled", false);
 
 // Enable the Canvas Debugger.
 pref("devtools.canvasdebugger.enabled", false);
 
 // Enable the Web Audio Editor
--- a/browser/devtools/styleeditor/test/browser_styleeditor_media_sidebar.js
+++ b/browser/devtools/styleeditor/test/browser_styleeditor_media_sidebar.js
@@ -1,53 +1,68 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // https rather than chrome to improve coverage
 const TESTCASE_URI = TEST_BASE_HTTPS + "media-rules.html";
-const PREF = "devtools.styleeditor.showMediaSidebar";
+const MEDIA_PREF = "devtools.styleeditor.showMediaSidebar";
 
 const RESIZE = 300;
 const LABELS = ["not all", "all", "(max-width: 400px)"];
 const LINE_NOS = [2, 8, 20];
 
 waitForExplicitFinish();
 
 let test = asyncTest(function*() {
-  Services.prefs.setBoolPref(PREF, true);
-
   let {UI} = yield addTabAndOpenStyleEditors(2, null, TESTCASE_URI);
 
   is(UI.editors.length, 2, "correct number of editors");
 
   // Test first plain css editor
   let plainEditor = UI.editors[0];
   yield openEditor(plainEditor);
   testPlainEditor(plainEditor);
 
   // Test editor with @media rules
   let mediaEditor = UI.editors[1];
   yield openEditor(mediaEditor);
   testMediaEditor(mediaEditor);
 
+  // Test that sidebar hides when flipping pref
+  testShowHide(mediaEditor);
+
   // Test resizing and seeing @media matching state change
   let originalWidth = window.outerWidth;
   let originalHeight = window.outerHeight;
 
-  let onMatchesChange = listenForMatchesChange(UI);
+  let onMatchesChange = listenForMediaChange(UI);
   window.resizeTo(RESIZE, RESIZE);
   yield onMatchesChange;
 
   testMediaMatchChanged(mediaEditor);
 
   window.resizeTo(originalWidth, originalHeight);
-  Services.prefs.clearUserPref(PREF);
 });
 
+function* testShowHide(editor) {
+  let sidebarChange = listenForMediaChange(UI);
+  Services.prefs.setBoolPref(MEDIA_PREF, false);
+  yield sidebarChange;
+
+  let sidebar = editor.details.querySelector(".stylesheet-sidebar");
+  is(sidebar.hidden, true, "sidebar is hidden after flipping pref");
+
+  sidebarChange = listenForMediaChange(UI);
+  Services.prefs.clearUserPref(MEDIA_PREF);
+  yield sidebarChange;
+
+  is(sidebar.hidden, false, "sidebar is showing after flipping pref back");
+}
+
 function testPlainEditor(editor) {
   let sidebar = editor.details.querySelector(".stylesheet-sidebar");
   is(sidebar.hidden, true, "sidebar is hidden on editor without @media");
 }
 
 function testMediaEditor(editor) {
   let sidebar = editor.details.querySelector(".stylesheet-sidebar");
   is(sidebar.hidden, false, "sidebar is showing on editor with @media");
@@ -84,17 +99,17 @@ function testRule(rule, text, matches, l
 /* Helpers */
 
 function openEditor(editor) {
   getLinkFor(editor).click();
 
   return editor.getSourceEditor();
 }
 
-function listenForMatchesChange(UI) {
+function listenForMediaChange(UI) {
   let deferred = promise.defer();
   UI.once("media-list-changed", () => {
     deferred.resolve();
   })
   return deferred.promise;
 }
 
 function getLinkFor(editor) {
--- a/browser/devtools/styleeditor/test/browser_styleeditor_media_sidebar_sourcemaps.js
+++ b/browser/devtools/styleeditor/test/browser_styleeditor_media_sidebar_sourcemaps.js
@@ -1,39 +1,36 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // https rather than chrome to improve coverage
 const TESTCASE_URI = TEST_BASE_HTTPS + "media-rules-sourcemaps.html";
-const MEDIA_PREF = "devtools.styleeditor.showMediaSidebar";
 const MAP_PREF = "devtools.styleeditor.source-maps-enabled";
 
 const LABELS = ["screen and (max-width: 320px)",
                 "screen and (min-width: 1200px)"];
 const LINE_NOS = [4, 4];
 
 waitForExplicitFinish();
 
 let test = asyncTest(function*() {
-  Services.prefs.setBoolPref(MEDIA_PREF, true);
   Services.prefs.setBoolPref(MAP_PREF, true);
 
   let {UI} = yield addTabAndOpenStyleEditors(2, null, TESTCASE_URI);
 
   yield listenForMediaChange(UI);
 
   is(UI.editors.length, 1, "correct number of editors");
 
   // Test editor with @media rules
   let mediaEditor = UI.editors[0];
   yield openEditor(mediaEditor);
   testMediaEditor(mediaEditor);
 
-  Services.prefs.clearUserPref(MEDIA_PREF);
   Services.prefs.clearUserPref(MAP_PREF);
 });
 
 function testMediaEditor(editor) {
   let sidebar = editor.details.querySelector(".stylesheet-sidebar");
   is(sidebar.hidden, false, "sidebar is showing on editor with @media");
 
   let entries = [...sidebar.querySelectorAll(".media-rule-label")];