Bug 719021 - Saving an empty new style sheet does not display the file name upon saving. r=paul
authorCedric Vivier <cedricv@neonux.com>
Wed, 25 Jan 2012 07:59:00 +0100
changeset 86729 7571ade2acbf0bfc1f23aa126383f505b3700d57
parent 86667 e758551e3924f8928b624655b968a0029dee9cbd
child 86730 d5ceec63ef0ab5026d471ead9a81a1e536957232
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaul
bugs719021
milestone12.0a1
Bug 719021 - Saving an empty new style sheet does not display the file name upon saving. r=paul --- browser/devtools/styleeditor/StyleEditor.jsm | 6 ++++-- .../styleeditor/test/browser_styleeditor_new.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) --- browser/devtools/styleeditor/StyleEditor.jsm | 6 ++++-- .../styleeditor/test/browser_styleeditor_new.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-)
browser/devtools/styleeditor/StyleEditor.jsm
browser/devtools/styleeditor/test/browser_styleeditor_new.js
--- a/browser/devtools/styleeditor/StyleEditor.jsm
+++ b/browser/devtools/styleeditor/StyleEditor.jsm
@@ -353,17 +353,16 @@ StyleEditor.prototype = {
    * Load style sheet source into the editor, asynchronously.
    * "Load" handler triggers when complete.
    *
    * @see addActionListener
    */
   load: function SE_load()
   {
     if (!this._styleSheet) {
-      this._flags.push(StyleEditorFlags.NEW);
       this._appendNewStyleSheet();
     }
     this._loadSource();
   },
 
   /**
    * Get a user-friendly name for the style sheet.
    *
@@ -863,19 +862,22 @@ StyleEditor.prototype = {
     let style = document.createElement("style");
     style.setAttribute("type", "text/css");
     if (aText) {
       style.appendChild(document.createTextNode(aText));
     }
     parent.appendChild(style);
 
     this._styleSheet = document.styleSheets[document.styleSheets.length - 1];
-    this._flags.push(aText ? StyleEditorFlags.IMPORTED : StyleEditorFlags.NEW);
     if (aText) {
       this._onSourceLoad(aText);
+      this._flags.push(StyleEditorFlags.IMPORTED);
+    } else {
+      this._flags.push(StyleEditorFlags.NEW);
+      this._flags.push(StyleEditorFlags.UNSAVED);
     }
   },
 
   /**
    * Signal an error to the user.
    *
    * @param string aErrorCode
    *        String name for the localized error property in the string bundle.
--- a/browser/devtools/styleeditor/test/browser_styleeditor_new.js
+++ b/browser/devtools/styleeditor/test/browser_styleeditor_new.js
@@ -56,18 +56,18 @@ function testEditorAdded(aChrome, aEdito
 
   let listener = {
     onAttach: function (aEditor) {
       waitForFocus(function () {
         ok(aEditor.isLoaded,
            "new editor is loaded when attached");
         ok(aEditor.hasFlag("new"),
            "new editor has NEW flag");
-        ok(!aEditor.hasFlag("unsaved"),
-           "new editor does not have UNSAVED flag");
+        ok(aEditor.hasFlag("unsaved"),
+           "new editor has UNSAVED flag");
 
         ok(aEditor.inputElement,
            "new editor has an input element attached");
 
         ok(aEditor.sourceEditor.hasFocus(),
            "new editor has focus");
 
         let summary = aChrome.getSummaryElementForEditor(aEditor);