Bug 795158 - Switch to Services.jsm: /editor/ui/: Services.prompt. r=mconley, r=IanN
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 05 Feb 2013 00:29:11 +0100
changeset 14800 e7f920afc8bd218f51fe5e49b66c95258b9663e7
parent 14799 8a508a9ee4856e4c7f539d66634017529a2b5c14
child 14801 c8d667fee51c287e243db21ff76c6701596741e0
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, IanN
bugs795158
Bug 795158 - Switch to Services.jsm: /editor/ui/: Services.prompt. r=mconley, r=IanN
editor/ui/composer/content/ComposerCommands.js
editor/ui/composer/content/editorUtilities.js
editor/ui/dialogs/content/EditorPublishProgress.js
--- a/editor/ui/composer/content/ComposerCommands.js
+++ b/editor/ui/composer/content/ComposerCommands.js
@@ -9,34 +9,34 @@ var gComposerJSCommandControllerID = 0;
 
 
 //-----------------------------------------------------------------------------------
 function SetupHTMLEditorCommands()
 {
   var commandTable = GetComposerCommandTable();
   if (!commandTable)
     return;
-  
+
   // Include everthing a text editor does
   SetupTextEditorCommands();
 
   //dump("Registering HTML editor commands\n");
 
   commandTable.registerCommand("cmd_renderedHTMLEnabler", nsDummyHTMLCommand);
 
   commandTable.registerCommand("cmd_grid",  nsGridCommand);
 
   commandTable.registerCommand("cmd_listProperties",  nsListPropertiesCommand);
   commandTable.registerCommand("cmd_pageProperties",  nsPagePropertiesCommand);
   commandTable.registerCommand("cmd_colorProperties", nsColorPropertiesCommand);
   commandTable.registerCommand("cmd_advancedProperties", nsAdvancedPropertiesCommand);
   commandTable.registerCommand("cmd_objectProperties",   nsObjectPropertiesCommand);
   commandTable.registerCommand("cmd_removeNamedAnchors", nsRemoveNamedAnchorsCommand);
   commandTable.registerCommand("cmd_editLink",        nsEditLinkCommand);
-  
+
   commandTable.registerCommand("cmd_form",          nsFormCommand);
   commandTable.registerCommand("cmd_inputtag",      nsInputTagCommand);
   commandTable.registerCommand("cmd_inputimage",    nsInputImageCommand);
   commandTable.registerCommand("cmd_textarea",      nsTextAreaCommand);
   commandTable.registerCommand("cmd_select",        nsSelectCommand);
   commandTable.registerCommand("cmd_button",        nsButtonCommand);
   commandTable.registerCommand("cmd_label",         nsLabelCommand);
   commandTable.registerCommand("cmd_fieldset",      nsFieldSetCommand);
@@ -76,19 +76,19 @@ function SetupHTMLEditorCommands()
   commandTable.registerCommand("cmd_ConvertToTable",     nsConvertToTable);
 }
 
 function SetupTextEditorCommands()
 {
   var commandTable = GetComposerCommandTable();
   if (!commandTable)
     return;
-  
+
   //dump("Registering plain text editor commands\n");
-  
+
   commandTable.registerCommand("cmd_find",       nsFindCommand);
   commandTable.registerCommand("cmd_findNext",   nsFindAgainCommand);
   commandTable.registerCommand("cmd_findPrev",   nsFindAgainCommand);
   commandTable.registerCommand("cmd_rewrap",     nsRewrapCommand);
   commandTable.registerCommand("cmd_spelling",   nsSpellingCommand);
   commandTable.registerCommand("cmd_validate",   nsValidateCommand);
   commandTable.registerCommand("cmd_checkLinks", nsCheckLinksCommand);
   commandTable.registerCommand("cmd_insertChars", nsInsertCharsCommand);
@@ -99,18 +99,18 @@ function SetupComposerWindowCommands()
   // Don't need to do this if already done
   if (gComposerWindowControllerID)
     return;
 
   // Create a command controller and register commands
   //   specific to Web Composer window (file-related commands, HTML Source...)
   //   We can't use the composer controller created on the content window else
   //     we can't process commands when in HTMLSource editor
-  // IMPORTANT: For each of these commands, the doCommand method 
-  //            must first call FinishHTMLSource() 
+  // IMPORTANT: For each of these commands, the doCommand method
+  //            must first call FinishHTMLSource()
   //            to go from HTML Source mode to any other edit mode
 
   var windowControllers = window.controllers;
 
   if (!windowControllers) return;
 
   var commandTable;
   var composerController;
@@ -176,30 +176,30 @@ function SetupComposerWindowCommands()
 }
 
 //-----------------------------------------------------------------------------------
 function GetComposerCommandTable()
 {
   var controller;
   if (gComposerJSCommandControllerID)
   {
-    try { 
+    try {
       controller = window.content.controllers.getControllerById(gComposerJSCommandControllerID);
     } catch (e) {}
   }
   if (!controller)
   {
     //create it
     controller = Components.classes["@mozilla.org/embedcomp/base-command-controller;1"].createInstance();
 
     var editorController = controller.QueryInterface(Components.interfaces.nsIControllerContext);
     editorController.init(null);
     editorController.setCommandContext(GetCurrentEditorElement());
     window.content.controllers.insertControllerAt(0, controller);
-  
+
     // Store the controller ID so we can be sure to get the right one later
     gComposerJSCommandControllerID = window.content.controllers.getControllerId(controller);
   }
 
   if (controller)
   {
     var interfaceRequestor = controller.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
     return interfaceRequestor.getInterface(Components.interfaces.nsIControllerCommandTable);
@@ -360,19 +360,19 @@ function pokeMultiStateUI(uiID, cmdParam
 
     var isMixed = cmdParams.getBooleanValue("state_mixed");
     var desiredAttrib;
     if (isMixed)
       desiredAttrib = "mixed";
     else {
       var valuetype = cmdParams.getValueType("state_attribute");
       if (valuetype == Components.interfaces.nsICommandParams.eStringType) {
-        desiredAttrib = cmdParams.getCStringValue("state_attribute");      
+        desiredAttrib = cmdParams.getCStringValue("state_attribute");
       } else {
-        desiredAttrib = cmdParams.getStringValue("state_attribute");      
+        desiredAttrib = cmdParams.getStringValue("state_attribute");
       }
 
     }
 
     var uiState = commandNode.getAttribute("state");
     if (desiredAttrib != uiState)
     {
       commandNode.setAttribute("state", desiredAttrib);
@@ -410,17 +410,17 @@ function PrintObject(obj)
   {
     if (i == "value")
       names += i + ": " + obj.value + "\n";
     else if (i == "id")
       names += i + ": " + obj.id + "\n";
     else
       names += i + "\n";
   }
-  
+
   dump(names + "-----------\n");
 }
 
 //-----------------------------------------------------------------------------------
 function PrintNodeID(id)
 {
   PrintObject(document.getElementById(id));
 }
@@ -471,18 +471,18 @@ var nsOpenCommand =
     if (fileType == "html")
       fp.appendFilters(nsIFilePicker.filterHTML);
     fp.appendFilters(nsIFilePicker.filterText);
     fp.appendFilters(nsIFilePicker.filterAll);
 
     /* doesn't handle *.shtml files */
     if (fp.show() == nsIFilePicker.returnCancel)
       return;
-  
-    // editPage checks for already open window and activates it. 
+
+    // editPage checks for already open window and activates it.
     if (fp.fileURL.spec) {
       SaveFilePickerDirectory(fp, fileType);
       editPage(fp.fileURL.spec, fileType);
     }
   }
 };
 
 // STRUCTURE TOOLBAR
@@ -511,17 +511,17 @@ var nsSaveCommand =
     //  when you first open a remote file.
     try {
       var docUrl = GetDocumentUrl();
       return IsDocumentEditable() &&
         (IsDocumentModified() || IsHTMLSourceChanged() ||
          IsUrlAboutBlank(docUrl) || GetScheme(docUrl) != "file");
     } catch (e) {return false;}
   },
-  
+
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     var result = false;
     var editor = GetCurrentEditor();
     if (editor)
@@ -586,17 +586,17 @@ var nsSaveAndChangeEncodingCommand =
   {
     return (IsDocumentEditable());
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
-  {    
+  {
     FinishHTMLSource();
     window.ok = false;
     window.exportToText = false;
     var oldTitle = GetDocumentTitle();
     window.openDialog("chrome://editor/content/EditorSaveAsCharset.xul","_blank", "chrome,close,titlebar,modal,resizable=yes");
 
     if (GetDocumentTitle() != oldTitle)
       UpdateWindowTitle();
@@ -630,17 +630,17 @@ var nsPublishCommand =
       try {
         var docUrl = GetDocumentUrl();
         return IsDocumentModified() || IsHTMLSourceChanged()
                || IsUrlAboutBlank(docUrl) || GetScheme(docUrl) == "file";
       } catch (e) {return false;}
     }
     return false;
   },
-  
+
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     if (GetCurrentEditor())
     {
       let docUrl = GetDocumentUrl();
@@ -661,17 +661,17 @@ var nsPublishCommand =
       }
 
       if (showPublishDialog || !publishData)
       {
         // Show the publish dialog
         publishData = {};
         window.ok = false;
         let oldTitle = GetDocumentTitle();
-        window.openDialog("chrome://editor/content/EditorPublish.xul","_blank", 
+        window.openDialog("chrome://editor/content/EditorPublish.xul","_blank",
                           "chrome,close,titlebar,modal", "", "", publishData);
         if (GetDocumentTitle() != oldTitle)
           UpdateWindowTitle();
 
         if (!window.ok)
           return false;
       }
       if (publishData)
@@ -685,30 +685,30 @@ var nsPublishCommand =
 }
 
 var nsPublishAsCommand =
 {
   isCommandEnabled: function(aCommand, dummy)
   {
     return (IsDocumentEditable());
   },
-  
+
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     if (GetCurrentEditor())
     {
       FinishHTMLSource();
 
       window.ok = false;
       var publishData = {};
       var oldTitle = GetDocumentTitle();
-      window.openDialog("chrome://editor/content/EditorPublish.xul","_blank", 
+      window.openDialog("chrome://editor/content/EditorPublish.xul","_blank",
                         "chrome,close,titlebar,modal", "", "", publishData);
       if (GetDocumentTitle() != oldTitle)
         UpdateWindowTitle();
 
       if (window.ok)
         return Publish(publishData);
     }
     return false;
@@ -752,17 +752,17 @@ function GetSuggestedFileName(aDocumentU
         GetCurrentEditor().documentCharacterSet, null);
       docURI = docURI.QueryInterface(Components.interfaces.nsIURL);
 
       // grab the file name
       let url = validateFileName(decodeURIComponent(docURI.fileBaseName));
       if (url)
         return url + extension;
     } catch(e) {}
-  } 
+  }
 
   // Check if there is a title we can use to generate a valid filename,
   // if we can't, use the default filename.
   var title = validateFileName(GetDocumentTitle()) ||
               GetString("untitledDefaultFilename");
   return title + extension;
 }
 
@@ -800,17 +800,17 @@ function PromptForSaveLocation(aDoSaveAs
   var suggestedFileName = GetSuggestedFileName(aDocumentURLString, aMIMEType);
   if (suggestedFileName)
     fp.defaultString = suggestedFileName;
 
   // set the file picker's current directory
   // assuming we have information needed (like prior saved location)
   try {
     var fileHandler = GetFileProtocolHandler();
-    
+
     var isLocalFile = true;
     try {
       let docURI = Services.io.newURI(aDocumentURLString, GetCurrentEditor().documentCharacterSet, null);
       isLocalFile = docURI.schemeIs("file");
     }
     catch (e) {}
 
     var parentLocation = null;
@@ -839,37 +839,36 @@ function PromptForSaveLocation(aDoSaveAs
   if (dialogResult.filepickerClick != nsIFilePicker.returnCancel)
   {
     // reset urlstring to new save location
     dialogResult.resultingURIString = fileHandler.getURLSpecFromFile(fp.file);
     dialogResult.resultingLocalFile = fp.file;
     SaveFilePickerDirectory(fp, aEditorType);
   }
   else if ("gFilePickerDirectory" in window && gFilePickerDirectory)
-    fp.displayDirectory = gFilePickerDirectory; 
+    fp.displayDirectory = gFilePickerDirectory;
 
   return dialogResult;
 }
 
 /**
  * If needed, prompt for document title and set the document title to the
  * preferred value.
  * @return true if the title was set up successfully;
  *         false if the user cancelled the title prompt
  */
 function PromptAndSetTitleIfNone()
 {
   if (GetDocumentTitle()) // we have a title; no need to prompt!
     return true;
 
-  var promptService = GetPromptService();
-  var result = {value:null};
-  var captionStr = GetString("DocumentTitle");
-  var msgStr = GetString("NeedDocTitle") + '\n' + GetString("DocTitleHelp");
-  var confirmed = promptService.prompt(window, captionStr, msgStr, result, null, {value:0});
+  let result = {value:null};
+  let captionStr = GetString("DocumentTitle");
+  let msgStr = GetString("NeedDocTitle") + '\n' + GetString("DocTitleHelp");
+  let confirmed = Services.prompt.prompt(window, captionStr, msgStr, result, null, {value:0});
   if (confirmed)
     SetDocumentTitle(TrimString(result.value));
 
   return confirmed;
 }
 
 var gPersistObj;
 
@@ -891,30 +890,30 @@ function OutputFileWithPersistAPI(editor
     var imeEditor = editor.QueryInterface(Components.interfaces.nsIEditorIMESupport);
     imeEditor.forceCompositionEnd();
     } catch (e) {}
 
   var isLocalFile = false;
   try {
     var tmp1 = aDestinationLocation.QueryInterface(Components.interfaces.nsIFile);
     isLocalFile = true;
-  } 
+  }
   catch (e) {
     try {
       var tmp = aDestinationLocation.QueryInterface(Components.interfaces.nsIURI);
       isLocalFile = tmp.schemeIs("file");
     }
     catch (e) {}
   }
 
   try {
     // we should supply a parent directory if/when we turn on functionality to save related documents
     var persistObj = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"].createInstance(webPersist);
     persistObj.progressListener = gEditorOutputProgressListener;
-    
+
     var wrapColumn = GetWrapColumn();
     var outputFlags = GetOutputFlags(aMimeType, wrapColumn);
 
     // for 4.x parity as well as improving readability of file locally on server
     // this will always send crlf for upload (http/ftp)
     if (!isLocalFile) // if we aren't saving locally then send both cr and lf
     {
       outputFlags |= webPersist.ENCODE_FLAGS_CR_LINEBREAKS | webPersist.ENCODE_FLAGS_LF_LINEBREAKS;
@@ -923,23 +922,23 @@ function OutputFileWithPersistAPI(editor
       // some servers can handle only one connection at a time
       // some day perhaps we can make this user-configurable per site?
       persistObj.persistFlags = persistObj.persistFlags | webPersist.PERSIST_FLAGS_SERIALIZE_OUTPUT;
     }
 
     // note: we always want to set the replace existing files flag since we have
     // already given user the chance to not replace an existing file (file picker)
     // or the user picked an option where the file is implicitly being replaced (save)
-    persistObj.persistFlags = persistObj.persistFlags 
+    persistObj.persistFlags = persistObj.persistFlags
                             | webPersist.PERSIST_FLAGS_NO_BASE_TAG_MODIFICATIONS
                             | webPersist.PERSIST_FLAGS_REPLACE_EXISTING_FILES
                             | webPersist.PERSIST_FLAGS_DONT_FIXUP_LINKS
                             | webPersist.PERSIST_FLAGS_DONT_CHANGE_FILENAMES
                             | webPersist.PERSIST_FLAGS_FIXUP_ORIGINAL_DOM;
-    persistObj.saveDocument(editorDoc, aDestinationLocation, aRelatedFilesParentDir, 
+    persistObj.saveDocument(editorDoc, aDestinationLocation, aRelatedFilesParentDir,
                             aMimeType, outputFlags, wrapColumn);
     gPersistObj = persistObj;
   }
   catch(e) { dump("caught an error, bail\n"); return false; }
 
   return true;
 }
 
@@ -986,27 +985,16 @@ const nsIWebBrowserPersist = Components.
 function GetWrapColumn()
 {
   try {
     return GetCurrentEditor().wrapWidth;
   } catch (e) {}
   return 0;
 }
 
-function GetPromptService()
-{
-  var promptService;
-  try {
-    promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
-    promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
-  }
-  catch (e) {}
-  return promptService;
-}
-
 const gShowDebugOutputStateChange = false;
 const gShowDebugOutputProgress = false;
 const gShowDebugOutputStatusChange = false;
 
 const gShowDebugOutputLocationChange = false;
 const gShowDebugOutputSecurityChange = false;
 
 const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
@@ -1023,17 +1011,17 @@ var gEditorOutputProgressListener =
     var editor = GetCurrentEditor();
 
     // Use this to access onStateChange flags
     var requestSpec;
     try {
       var channel = aRequest.QueryInterface(nsIChannel);
       requestSpec = StripUsernamePasswordFromURI(channel.URI);
     } catch (e) {
-      if ( gShowDebugOutputStateChange)
+      if (gShowDebugOutputStateChange)
         dump("***** onStateChange; NO REQUEST CHANNEL\n");
     }
 
     var pubSpec;
     if (gPublishData)
       pubSpec = gPublishData.publishUrl + gPublishData.docDir + gPublishData.filename;
 
     if (gShowDebugOutputStateChange)
@@ -1078,31 +1066,31 @@ var gEditorOutputProgressListener =
         var httpResponse = httpChannel.responseStatus;
         if (httpResponse < 200 || httpResponse >= 300)
           aStatus = httpResponse;   // not a real error but enough to pass check below
         else if (aStatus == kErrorBindingAborted)
           aStatus = 0;
 
         if (gShowDebugOutputStateChange)
           dump("http response is: "+httpResponse+"\n");
-      } 
-      catch(e) 
+      }
+      catch(e)
       {
         if (aStatus == kErrorBindingAborted)
           aStatus = 0;
       }
 
       // We abort publishing for all errors except if image src file is not found
       var abortPublishing = (aStatus != 0 && aStatus != kFileNotFound);
 
       // Notify progress dialog when we receive the STOP
-      //  notification for a file if there was an error 
+      //  notification for a file if there was an error
       //  or a successful finish
       //  (Check requestSpec to be sure message is for destination url)
-      if (aStatus != 0 
+      if (aStatus != 0
            || (requestSpec && requestSpec.indexOf(GetScheme(gPublishData.publishUrl)) == 0))
       {
         try {
           gProgressDialog.SetProgressFinished(GetFilename(requestSpec), aStatus);
         } catch(e) {}
       }
 
 
@@ -1115,17 +1103,17 @@ var gEditorOutputProgressListener =
         gCommandAfterPublishing = null;
 
         // Restore original document to undo image src url adjustments
         if (gRestoreDocumentSource)
         {
           try {
             editor.rebuildDocumentFromSource(gRestoreDocumentSource);
 
-            // Clear transaction cache since we just did a potentially 
+            // Clear transaction cache since we just did a potentially
             //  very large insert and this will eat up memory
             editor.transactionManager.clear();
           }
           catch (e) {}
         }
 
         // Notify progress dialog that we're finished
         //  and keep open to show error
@@ -1133,33 +1121,33 @@ var gEditorOutputProgressListener =
 
         // We don't want to change location or reset mod count, etc.
         return;
       }
 
       //XXX HACK: "file://" protocol is not supported in network code
       //    (bug 151867 filed to add this support, bug 151869 filed
       //     to remove this and other code in nsIWebBrowserPersist)
-      //    nsIWebBrowserPersist *does* copy the file(s), but we don't 
+      //    nsIWebBrowserPersist *does* copy the file(s), but we don't
       //    get normal onStateChange messages.
 
       // Case 1: If images are included, we get fairly normal
       //    STATE_START/STATE_STOP & STATE_IS_NETWORK messages associated with the image files,
       //    thus we must finish HTML file progress below
 
       // Case 2: If just HTML file is uploaded, we get STATE_START and STATE_STOP
-      //    notification with a null "requestSpec", and 
+      //    notification with a null "requestSpec", and
       //    the gPersistObj is destroyed before we get here!
       //    So create an new object so we can flow through normal processing below
       if (!requestSpec && GetScheme(gPublishData.publishUrl) == "file"
           && (!gPersistObj || gPersistObj.currentState == nsIWebBrowserPersist.PERSIST_STATE_FINISHED))
       {
         aStateFlags |= nsIWebProgressListener.STATE_IS_NETWORK;
         if (!gPersistObj)
-        {          
+        {
           gPersistObj =
           {
             result : aStatus,
             currentState : nsIWebBrowserPersist.PERSIST_STATE_FINISHED
           }
         }
       }
 
@@ -1266,26 +1254,26 @@ var gEditorOutputProgressListener =
     if (gShowDebugOutputStatusChange)
     {
       dump("***** onStatusChange: "+aMessage+"\n");
       try {
         var channel = aRequest.QueryInterface(nsIChannel);
         dump("*****        request: " + channel.URI.spec + "\n");
       }
       catch (e) { dump("          couldn't get request\n"); }
-      
+
       DumpDebugStatus(aStatus);
 
       if (gPersistObj)
       {
-        if(gPersistObj.currentState == gPersistObj.PERSIST_STATE_READY)
+        if (gPersistObj.currentState == gPersistObj.PERSIST_STATE_READY)
           dump(" Persister is ready to save data\n\n");
-        else if(gPersistObj.currentState == gPersistObj.PERSIST_STATE_SAVING)
+        else if (gPersistObj.currentState == gPersistObj.PERSIST_STATE_SAVING)
           dump(" Persister is saving data.\n\n");
-        else if(gPersistObj.currentState == gPersistObj.PERSIST_STATE_FINISHED)
+        else if (gPersistObj.currentState == gPersistObj.PERSIST_STATE_FINISHED)
           dump(" PERSISTER HAS FINISHED SAVING DATA\n\n\n");
       }
     }
   },
 
   onSecurityChange : function(aWebProgress, aRequest, state)
   {
     if (gShowDebugOutputSecurityChange)
@@ -1318,68 +1306,51 @@ var gEditorOutputProgressListener =
     AlertWithTitle(dialogTitle, text);
   },
   confirm : function(dlgTitle, text)
   {
     return ConfirmWithTitle(dlgTitle, text, null, null);
   },
   confirmCheck : function(dlgTitle, text, checkBoxLabel, checkObj)
   {
-    var promptServ = GetPromptService();
-    if (!promptServ)
-      return;
-
-    promptServ.confirmEx(window, dlgTitle, text, nsIPromptService.STD_OK_CANCEL_BUTTONS,
-                         "", "", "", checkBoxLabel, checkObj);
+    Services.prompt.confirmEx(window, dlgTitle, text, nsIPromptService.STD_OK_CANCEL_BUTTONS,
+                              "", "", "", checkBoxLabel, checkObj);
   },
   confirmEx : function(dlgTitle, text, btnFlags, btn0Title, btn1Title, btn2Title, checkBoxLabel, checkVal)
   {
-    var promptServ = GetPromptService();
-    if (!promptServ)
-     return 0;
-
-    return promptServ.confirmEx(window, dlgTitle, text, btnFlags,
-                        btn0Title, btn1Title, btn2Title,
-                        checkBoxLabel, checkVal);
+    return Services.prompt.confirmEx(window, dlgTitle, text, btnFlags,
+                                     btn0Title, btn1Title, btn2Title,
+                                     checkBoxLabel, checkVal);
   },
 
   /*************************************************************************
    * gEditorOutputProgressListener needs to implement both nsIPrompt       *
    * (providing alert) and nsIAuthPrompt (providing password saving).      *
    * Unfortunately, both interfaces specify prompt/promptPassword/         *
    * promptUsernameAndPassword, albeit with conflicting method signatures. *
    * Luckily, though, we only make use of their nsIAuthPrompt variants,    *
    * hence we can comment out the nsIPrompt ones here to avoid JavaScript  *
    * strict mode clutter. See bug 371174 for more information.             *
    *************************************************************************
   prompt : function(dlgTitle, text, inoutText, checkBoxLabel, checkObj)
   {
-    var promptServ = GetPromptService();
-    if (!promptServ)
-     return false;
-
-    return promptServ.prompt(window, dlgTitle, text, inoutText, checkBoxLabel, checkObj);
+    return Services.prompt.prompt(window, dlgTitle, text, inoutText, checkBoxLabel, checkObj);
   },
   promptPassword : function(dlgTitle, text, pwObj, checkBoxLabel, savePWObj)
   {
-
-    var promptServ = GetPromptService();
-    if (!promptServ)
-     return false;
-
     var ret = false;
     try {
-      // Note difference with nsIAuthPrompt::promptPassword, which has 
+      // Note difference with nsIAuthPrompt::promptPassword, which has
       // just "in" savePassword param, while nsIPrompt is "inout"
       // Initialize with user's previous preference for this site
       if (gPublishData)
         savePWObj.value = gPublishData.savePassword;
 
-      ret = promptServ.promptPassword(gProgressDialog ? gProgressDialog : window,
-                                      dlgTitle, text, pwObj, checkBoxLabel, savePWObj);
+      ret = Services.prompt.promptPassword(gProgressDialog ? gProgressDialog : window,
+                                           dlgTitle, text, pwObj, checkBoxLabel, savePWObj);
 
       if (!ret)
         setTimeout(CancelPublishing, 0);
 
       if (ret && gPublishData)
         UpdateUsernamePasswordFromPrompt(gPublishData, gPublishData.username, pwObj.value, savePWObj.value);
     } catch(e) {}
 
@@ -1392,33 +1363,24 @@ var gEditorOutputProgressListener =
       setTimeout(CancelPublishing, 0);
 
     return ret;
   },
    *************************************************************************/
 
   select : function(dlgTitle, text, count, selectList, outSelection)
   {
-    var promptServ = GetPromptService();
-    if (!promptServ)
-      return false;
-
-    return promptServ.select(window, dlgTitle, text, count, selectList, outSelection);
+    return Services.prompt.select(window, dlgTitle, text, count, selectList, outSelection);
   },
 
 // nsIAuthPrompt
   prompt : function(dlgTitle, text, pwrealm, savePW, defaultText, result)
   {
-    var promptServ = GetPromptService();
-    if (!promptServ)
-      return false;
-
-    var savePWObj = {value:savePW};
-    var ret = promptServ.prompt(gProgressDialog ? gProgressDialog : window,
-                                dlgTitle, text, defaultText, pwrealm, savePWObj);
+    var ret = Services.prompt.prompt(gProgressDialog ? gProgressDialog : window,
+                                     dlgTitle, text, defaultText, pwrealm, savePWObj);
     if (!ret)
       setTimeout(CancelPublishing, 0);
     return ret;
   },
 
   promptUsernameAndPassword : function(dlgTitle, text, pwrealm, savePW, userObj, pwObj)
   {
     var ret = PromptUsernameAndPassword(dlgTitle, text, savePW, userObj, pwObj);
@@ -1426,31 +1388,27 @@ var gEditorOutputProgressListener =
       setTimeout(CancelPublishing, 0);
     return ret;
   },
 
   promptPassword : function(dlgTitle, text, pwrealm, savePW, pwObj)
   {
     var ret = false;
     try {
-      var promptServ = GetPromptService();
-      if (!promptServ)
-        return false;
-
-      // Note difference with nsIPrompt::promptPassword, which has 
+      // Note difference with nsIPrompt::promptPassword, which has
       // "inout" savePassword param, while nsIAuthPrompt is just "in"
       // Also nsIAuth doesn't supply "checkBoxLabel"
       // Initialize with user's previous preference for this site
       var savePWObj = {value:savePW};
       // Initialize with user's previous preference for this site
       if (gPublishData)
         savePWObj.value = gPublishData.savePassword;
 
-      ret = promptServ.promptPassword(gProgressDialog ? gProgressDialog : window,
-                                      dlgTitle, text, pwObj, GetString("SavePassword"), savePWObj);
+      ret = Services.prompt.promptPassword(gProgressDialog ? gProgressDialog : window,
+                                           dlgTitle, text, pwObj, GetString("SavePassword"), savePWObj);
 
       if (!ret)
         setTimeout(CancelPublishing, 0);
 
       if (ret && gPublishData)
         UpdateUsernamePasswordFromPrompt(gPublishData, gPublishData.username, pwObj.value, savePWObj.value);
     } catch(e) {}
 
@@ -1462,35 +1420,32 @@ function PromptUsernameAndPassword(dlgTi
 {
   // HTTP prompts us twice even if user Cancels from 1st attempt!
   // So never put up dialog if there's no publish data
   if (!gPublishData)
     return false
 
   var ret = false;
   try {
-    var promptServ = GetPromptService();
-    if (!promptServ)
-      return false;
 
     var savePWObj = {value:savePW};
 
     // Initialize with user's previous preference for this site
     if (gPublishData)
     {
       // HTTP put uses this dialog if either username or password is bad,
       //   so prefill username input field with the previous value for modification
       savePWObj.value = gPublishData.savePassword;
       if (!userObj.value)
         userObj.value = gPublishData.username;
     }
 
-    ret = promptServ.promptUsernameAndPassword(gProgressDialog ? gProgressDialog : window, 
-                                               dlgTitle, text, userObj, pwObj, 
-                                               GetString("SavePassword"), savePWObj);
+    ret = Services.prompt.promptUsernameAndPassword(gProgressDialog ? gProgressDialog : window,
+                                                    dlgTitle, text, userObj, pwObj,
+                                                    GetString("SavePassword"), savePWObj);
     if (ret && gPublishData)
       UpdateUsernamePasswordFromPrompt(gPublishData, userObj.value, pwObj.value, savePWObj.value);
 
   } catch (e) {}
 
   return ret;
 }
 
@@ -1572,18 +1527,18 @@ function DumpDebugStatus(aStatus)
     dump("***** status is " + aStatus + "\n");
 }
 
 // Update any data that the user supplied in a prompt dialog
 function UpdateUsernamePasswordFromPrompt(publishData, username, password, savePassword)
 {
   if (!publishData)
     return;
-  
-  // Set flag to save publish data after publishing if it changed in dialog 
+
+  // Set flag to save publish data after publishing if it changed in dialog
   //  and the "SavePassword" checkbox was checked
   //  or we already had site data for this site
   // (Thus we don't automatically create a site until user brings up Publish As dialog)
   publishData.savePublishData = (gPublishData.username != username || gPublishData.password != password)
                                 && (savePassword || !publishData.notInSiteData);
 
   publishData.username = username;
   publishData.password = password;
@@ -1623,17 +1578,17 @@ function SaveDocument(aSaveAs, aSaveCopy
     throw Components.results.NS_ERROR_NOT_INITIALIZED;
 
   var editorDoc = editor.document;
   if (!editorDoc)
     throw Components.results.NS_ERROR_NOT_INITIALIZED;
 
   // if we don't have the right editor type bail (we handle text and html)
   var editorType = GetCurrentEditorType();
-  if (editorType != "text" && editorType != "html" 
+  if (editorType != "text" && editorType != "html"
       && editorType != "htmlmail" && editorType != "textmail")
     throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
 
   var saveAsTextFile = IsSupportedTextMimeType(aMimeType);
 
   // check if the file is to be saved is a format we don't understand; if so, bail
   if (aMimeType != kHTMLMimeType && aMimeType != kXHTMLMimeType && !saveAsTextFile)
     throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
@@ -1650,62 +1605,62 @@ function SaveDocument(aSaveAs, aSaveCopy
 
   var replacing = !aSaveAs;
   var titleChanged = false;
   var doUpdateURI = false;
   var tempLocalFile = null;
 
   if (mustShowFileDialog)
   {
-	  try {
-	    // Prompt for title if we are saving to HTML
-	    if (!saveAsTextFile && (editorType == "html"))
-	    {
-	      var userContinuing = PromptAndSetTitleIfNone(); // not cancel
-	      if (!userContinuing)
-	        return false;
-	    }
-
-	    var dialogResult = PromptForSaveLocation(saveAsTextFile, editorType, aMimeType, urlstring);
-	    if (dialogResult.filepickerClick == nsIFilePicker.returnCancel)
-	      return false;
-
-	    replacing = (dialogResult.filepickerClick == nsIFilePicker.returnReplace);
-	    urlstring = dialogResult.resultingURIString;
-	    tempLocalFile = dialogResult.resultingLocalFile;
- 
+    try {
+      // Prompt for title if we are saving to HTML
+      if (!saveAsTextFile && (editorType == "html"))
+      {
+        var userContinuing = PromptAndSetTitleIfNone(); // not cancel
+        if (!userContinuing)
+          return false;
+      }
+
+      var dialogResult = PromptForSaveLocation(saveAsTextFile, editorType, aMimeType, urlstring);
+      if (dialogResult.filepickerClick == nsIFilePicker.returnCancel)
+        return false;
+
+      replacing = (dialogResult.filepickerClick == nsIFilePicker.returnReplace);
+      urlstring = dialogResult.resultingURIString;
+      tempLocalFile = dialogResult.resultingLocalFile;
+
       // update the new URL for the webshell unless we are saving a copy
       if (!aSaveCopy)
         doUpdateURI = true;
     } catch (e) {
        Components.utils.reportError(e);
-       return false; 
+       return false;
     }
   } // mustShowFileDialog
 
   var success = true;
   try {
-    // if somehow we didn't get a local file but we did get a uri, 
+    // if somehow we didn't get a local file but we did get a uri,
     // attempt to create the localfile if it's a "file" url
     var docURI;
     if (!tempLocalFile)
     {
       docURI = Services.io.newURI(urlstring, editor.documentCharacterSet, null);
-      
+
       if (docURI.schemeIs("file"))
       {
         var fileHandler = GetFileProtocolHandler();
         tempLocalFile = fileHandler.getFileFromURLSpec(urlstring).QueryInterface(Components.interfaces.nsILocalFile);
       }
     }
 
     // this is the location where the related files will go
     var relatedFilesDir = null;
-    
-    // Only change links or move files if pref is set 
+
+    // Only change links or move files if pref is set
     // and we are saving to a new location
     if (Services.prefs.getBoolPref("editor.save_associated_files") && aSaveAs)
     {
       try {
         if (tempLocalFile)
         {
           // if we are saving to the same parent directory, don't set relatedFilesDir
           // grab old location, chop off file
@@ -1824,17 +1779,17 @@ function Publish(publishData)
   if (gShowDebugOutputStateChange)
   {
     dump("\n *** publishData: PublishUrl="+publishData.publishUrl+", BrowseUrl="+publishData.browseUrl+
       ", Username="+publishData.username+", Dir="+publishData.docDir+
       ", Filename="+publishData.filename+"\n");
     dump(" * gPublishData.docURI.spec w/o pass="+StripPassword(gPublishData.docURI.spec)+", PublishOtherFiles="+gPublishData.publishOtherFiles+"\n");
   }
 
-  // XXX Missing username will make FTP fail 
+  // XXX Missing username will make FTP fail
   // and it won't call us for prompt dialog (bug 132320)
   // (It does prompt if just password is missing)
   // So we should do the prompt ourselves before trying to publish
   if (GetScheme(publishData.publishUrl) == "ftp" && !publishData.username)
   {
     var message = GetString("PromptFTPUsernamePassword").replace(/%host%/, GetHost(publishData.publishUrl));
     var savePWobj = {value:publishData.savePassword};
     var userObj = {value:publishData.username};
@@ -1849,17 +1804,17 @@ function Publish(publishData)
     if (gPublishData.otherFilesURI)
     {
       gPublishData.otherFilesURI.username = publishData.username;
       gPublishData.otherFilesURI.password = publishData.password;
     }
   }
 
   try {
-    // We launch dialog as a dependent 
+    // We launch dialog as a dependent
     // Don't allow editing document!
     SetDocumentEditable(false);
 
     // Start progress monitoring
     gProgressDialog =
       window.openDialog("chrome://editor/content/EditorPublishProgress.xul", "_blank",
                         "chrome,dependent,titlebar", gPublishData, gPersistObj);
 
@@ -1879,42 +1834,42 @@ function StartPublishing()
   {
     gRestoreDocumentSource = null;
 
     // Save backup document since nsIWebBrowserPersist changes image src urls
     // but we only need to do this if publishing images and other related files
     if (gPublishData.otherFilesURI)
     {
       try {
-        gRestoreDocumentSource = 
+        gRestoreDocumentSource =
           editor.outputToString(editor.contentsMIMEType, kOutputEncodeW3CEntities);
       } catch (e) {}
     }
 
-    OutputFileWithPersistAPI(editor.document, 
-                             gPublishData.docURI, gPublishData.otherFilesURI, 
+    OutputFileWithPersistAPI(editor.document,
+                             gPublishData.docURI, gPublishData.otherFilesURI,
                              editor.contentsMIMEType);
     return gPersistObj;
   }
   return null;
 }
 
 function CancelPublishing()
 {
   try {
     gPersistObj.cancelSave();
     gProgressDialog.SetProgressStatusCancel();
   } catch (e) {}
 
-  // If canceling publishing do not do any commands after this    
+  // If canceling publishing do not do any commands after this
   gCommandAfterPublishing = null;
 
   if (gProgressDialog)
   {
-    // Close Progress dialog 
+    // Close Progress dialog
     // (this will call FinishPublishing())
     gProgressDialog.CloseDialog();
   }
   else
     FinishPublishing();
 }
 
 function FinishPublishing()
@@ -1938,17 +1893,17 @@ function CreateURIFromPublishData(publis
 {
   if (!publishData || !publishData.publishUrl)
     return null;
 
   var URI;
   try {
     var spec = publishData.publishUrl;
     if (doDocUri)
-      spec += FormatDirForPublishing(publishData.docDir) + publishData.filename; 
+      spec += FormatDirForPublishing(publishData.docDir) + publishData.filename;
     else
       spec += FormatDirForPublishing(publishData.otherDir);
 
     URI = Services.io.newURI(spec, GetCurrentEditor().documentCharacterSet, null);
 
     if (publishData.username)
       URI.username = publishData.username;
     if (publishData.password)
@@ -1994,24 +1949,24 @@ function SetSaveAndPublishUI(urlstring)
 
 function SetDocumentEditable(isDocEditable)
 {
   var editor = GetCurrentEditor();
   if (editor && editor.document)
   {
     try {
       var flags = editor.flags;
-      editor.flags = isDocEditable ?  
+      editor.flags = isDocEditable ?
             flags &= ~nsIPlaintextEditor.eEditorReadonlyMask :
             flags | nsIPlaintextEditor.eEditorReadonlyMask;
     } catch(e) {}
 
     // update all commands
     window.updateCommands("create");
-  }  
+  }
 }
 
 // ****** end of save / publish **********//
 
 //-----------------------------------------------------------------------------------
 var nsPublishSettingsCommand =
 {
   isCommandEnabled: function(aCommand, dummy)
@@ -2046,60 +2001,56 @@ var nsRevertCommand =
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     // Confirm with the user to abandon current changes
-    var promptService = GetPromptService();
-    if (promptService)
+    // Put the page title in the message string
+    let title = GetDocumentTitle();
+    let msg = GetString("AbandonChanges").replace(/%title%/,title);
+
+    let result = Services.prompt.confirmEx(window, GetString("RevertCaption"), msg,
+                   (Services.prompt.BUTTON_TITLE_REVERT * Services.prompt.BUTTON_POS_0) +
+                   (Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1),
+                   null, null, null, null, {value:0});
+
+    // Reload page if first button (Revert) was pressed
+    if (result == 0)
     {
-      // Put the page title in the message string
-      var title = GetDocumentTitle();
-      var msg = GetString("AbandonChanges").replace(/%title%/,title);
-
-      var result = promptService.confirmEx(window, GetString("RevertCaption"), msg,
-  						      (promptService.BUTTON_TITLE_REVERT * promptService.BUTTON_POS_0) +
-  						      (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
-  						      null, null, null, null, {value:0});
-
-      // Reload page if first button (Revert) was pressed
-      if(result == 0)
-      {
-        CancelHTMLSource();
-        EditorLoadUrl(GetDocumentUrl());
-      }
+      CancelHTMLSource();
+      EditorLoadUrl(GetDocumentUrl());
     }
   }
 };
 
 //-----------------------------------------------------------------------------------
 var nsCloseCommand =
 {
   isCommandEnabled: function(aCommand, dummy)
   {
     return GetCurrentEditor() != null;
   },
-  
+
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     CloseWindow();
   }
 };
 
 function CloseWindow()
 {
   // Check to make sure document is saved. "true" means allow "Don't Save" button,
   //   so user can choose to close without saving
-  if (CheckAndSaveDocument("cmd_close", true)) 
+  if (CheckAndSaveDocument("cmd_close", true))
   {
     if (window.InsertCharWindow)
       SwitchInsertCharToAnotherEditorOrClose();
 
     try {
       var basewin = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                       .getInterface(Components.interfaces.nsIWebNavigation)
                       .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
@@ -2120,17 +2071,17 @@ var nsOpenRemoteCommand =
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     var params = { action: "2", url: "" };
-    openDialog( "chrome://communicator/content/openLocation.xul", "_blank", "chrome,modal,titlebar", params);
+    openDialog("chrome://communicator/content/openLocation.xul", "_blank", "chrome,modal,titlebar", params);
     var win = getTopWin();
     switch (params.action) {
       case "0": // current window
         win.focus();
         win.loadURI(params.url, null,
                     nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP);
         break;
       case "1": // new window
@@ -2151,46 +2102,46 @@ var nsOpenRemoteCommand =
   }
 };
 
 //-----------------------------------------------------------------------------------
 var nsPreviewCommand =
 {
   isCommandEnabled: function(aCommand, dummy)
   {
-    return (IsDocumentEditable() && 
-            IsHTMLEditor() && 
+    return (IsDocumentEditable() &&
+            IsHTMLEditor() &&
             (DocumentHasBeenSaved() || IsDocumentModified()));
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
-	  // Don't continue if user canceled during prompt for saving
+    // Don't continue if user canceled during prompt for saving
     // DocumentHasBeenSaved will test if we have a URL and suppress "Don't Save" button if not
     if (!CheckAndSaveDocument("cmd_preview", DocumentHasBeenSaved()))
-	    return;
+      return;
 
     // Check if we saved again just in case?
-	  if (DocumentHasBeenSaved())
+    if (DocumentHasBeenSaved())
     {
       var browser;
       try {
         // Find a browser with this URL
         var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
         var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
         var enumerator = windowManagerInterface.getEnumerator("navigator:browser");
 
         var documentURI = GetDocumentUrl();
-        while ( enumerator.hasMoreElements() )
+        while (enumerator.hasMoreElements())
         {
           browser = enumerator.getNext();
-          if ( browser && (documentURI == browser.getBrowser().currentURI.spec))
+          if (browser && (documentURI == browser.getBrowser().currentURI.spec))
             break;
 
           browser = null;
         }
       }
       catch (ex) {}
 
       // If none found, open a new browser
@@ -2221,25 +2172,25 @@ var nsSendPageCommand =
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     // Don't continue if user canceled during prompt for saving
     // DocumentHasBeenSaved will test if we have a URL and suppress "Don't Save" button if not
     if (!CheckAndSaveDocument("cmd_editSendPage", DocumentHasBeenSaved()))
-	    return;
+      return;
 
     // Check if we saved again just in case?
     if (DocumentHasBeenSaved())
     {
       // Launch Messenger Composer window with current page as contents
       try
       {
-        openComposeWindow(GetDocumentUrl(), GetDocumentTitle());        
+        openComposeWindow(GetDocumentUrl(), GetDocumentTitle());
       } catch (ex) { dump("Cannot Send Page: " + ex + "\n"); }
     }
   }
 };
 
 //-----------------------------------------------------------------------------------
 var nsPrintCommand =
 {
@@ -2342,17 +2293,17 @@ var nsFindAgainCommand =
     try {
       var findPrev = aCommand == "cmd_findPrev";
       var findInst = editorElement.webBrowserFind;
       var findService = Components.classes["@mozilla.org/find/find_service;1"]
                                   .getService(Components.interfaces.nsIFindService);
       findInst.findBackwards = findService.findBackwards ^ findPrev;
       findInst.findNext();
       // reset to what it was in dialog, otherwise dialog setting can get reversed
-      findInst.findBackwards = findService.findBackwards; 
+      findInst.findBackwards = findService.findBackwards;
     }
     catch (ex) {}
   }
 };
 
 //-----------------------------------------------------------------------------------
 var nsRewrapCommand =
 {
@@ -2371,17 +2322,17 @@ var nsRewrapCommand =
   }
 };
 
 //-----------------------------------------------------------------------------------
 var nsSpellingCommand =
 {
   isCommandEnabled: function(aCommand, dummy)
   {
-    return (IsDocumentEditable() && 
+    return (IsDocumentEditable() &&
             !IsInHTMLSourceMode() && IsSpellCheckerInstalled());
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
@@ -2581,17 +2532,17 @@ var nsLabelCommand =
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     var tagName = "label";
     try {
       var editor = GetCurrentEditor();
-      // Find selected label or if start/end of selection is in label 
+      // Find selected label or if start/end of selection is in label
       var labelElement = editor.getSelectedElement(tagName);
       if (!labelElement)
         labelElement = editor.getElementOrParentByTagName(tagName, editor.selection.anchorNode);
       if (!labelElement)
         labelElement = editor.getElementOrParentByTagName(tagName, editor.selection.focusNode);
       if (labelElement) {
         // We only open the dialog for an existing label
         window.openDialog("chrome://editor/content/EdLabelProps.xul", "_blank", "chrome,close,titlebar,modal", labelElement);
@@ -2731,17 +2682,17 @@ var nsLinkCommand =
     return (IsDocumentEditable() && IsEditingRenderedHTML());
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
-    // If selected element is an image, launch that dialog instead 
+    // If selected element is an image, launch that dialog instead
     // since last tab panel handles link around an image
     var element = GetObjectForProperties();
     if (element && element.nodeName.toLowerCase() == "img")
       window.openDialog("chrome://editor/content/EdImageProps.xul","_blank", "chrome,close,titlebar,modal", null, true);
     else
       window.openDialog("chrome://editor/content/EdLinkProps.xul","_blank", "chrome,close,titlebar,modal");
   }
 };
@@ -2882,17 +2833,17 @@ var nsPagePropertiesCommand =
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     var oldTitle = GetDocumentTitle();
     window.openDialog("chrome://editor/content/EdPageProps.xul","_blank", "chrome,close,titlebar,modal", "");
 
-    // Update main window title and 
+    // Update main window title and
     // recent menu data in prefs if doc title changed
     if (GetDocumentTitle() != oldTitle)
       UpdateWindowTitle();
   }
 };
 
 //-----------------------------------------------------------------------------------
 var nsObjectPropertiesCommand =
@@ -2908,17 +2859,17 @@ var nsObjectPropertiesCommand =
     return isEnabled;
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
-    // Launch Object properties for appropriate selected element 
+    // Launch Object properties for appropriate selected element
     var element = GetObjectForProperties();
     if (element)
     {
       var name = element.nodeName.toLowerCase();
       switch (name)
       {
         case 'img':
           goDoCommand("cmd_image");
@@ -2964,17 +2915,17 @@ var nsObjectPropertiesCommand =
         case 'li':
           goDoCommand("cmd_listProperties");
           break;
         case 'a':
           if (element.name)
           {
             goDoCommand("cmd_anchor");
           }
-          else if(element.href)
+          else if (element.href)
           {
             goDoCommand("cmd_link");
           }
           break;
         default:
           doAdvancedProperties(element);
           break;
       }
@@ -3042,49 +2993,49 @@ var nsSetSmiley =
         case "O:-)":
         case "o:-)": strSml="s14";
         break;
         case ":'(": strSml="s15";
         break;
         case ":-X":
         case ":-x": strSml="s16";
         break;
-        default:	strSml="";
+        default: strSml="";
         break;
     }
 
     try
     {
       var editor = GetCurrentEditor();
       var selection = editor.selection;
       var extElement = editor.createElementWithDefaults("span");
       extElement.setAttribute("class", "moz-smiley-" + strSml);
 
       var intElement = editor.createElementWithDefaults("span");
       if (!intElement)
         return;
 
       //just for mailnews, because of the way it removes HTML
-      var smileButMenu = document.getElementById('smileButtonMenu');      
+      var smileButMenu = document.getElementById('smileButtonMenu');
       if (smileButMenu.getAttribute("padwithspace"))
          smileyCode = " " + smileyCode + " ";
 
       var txtElement =  editor.document.createTextNode(smileyCode);
       if (!txtElement)
         return;
 
       intElement.appendChild (txtElement);
       extElement.appendChild (intElement);
 
 
       editor.insertElementAtSelection(extElement,true);
-      window.content.focus();		
-
-    } 
-    catch (e) 
+      window.content.focus();
+
+    }
+    catch (e)
     {
         dump("Exception occured in smiley InsertElementAtSelection\n");
     }
   },
   // This is now deprecated in favor of "doCommandParams"
   doCommand: function(aCommand) {}
 };
 
@@ -3125,18 +3076,18 @@ var nsColorPropertiesCommand =
     return (IsDocumentEditable() && IsEditingRenderedHTML());
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
-    window.openDialog("chrome://editor/content/EdColorProps.xul","_blank", "chrome,close,titlebar,modal", ""); 
-    UpdateDefaultColors(); 
+    window.openDialog("chrome://editor/content/EdColorProps.xul","_blank", "chrome,close,titlebar,modal", "");
+    UpdateDefaultColors();
   }
 };
 
 //-----------------------------------------------------------------------------------
 var nsRemoveNamedAnchorsCommand =
 {
   isCommandEnabled: function(aCommand, dummy)
   {
@@ -3600,17 +3551,17 @@ var nsDeleteTableCellCommand =
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     try {
-      GetCurrentTableEditor().deleteTableCell(1);   
+      GetCurrentTableEditor().deleteTableCell(1);
     } catch (e) {}
     window.content.focus();
   }
 };
 
 var nsDeleteTableCellContentsCommand =
 {
   isCommandEnabled: function(aCommand, dummy)
@@ -3641,17 +3592,17 @@ var nsNormalizeTableCommand =
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     // Use nullptr to let editor find table enclosing current selection
     try {
-      GetCurrentTableEditor().normalizeTable(null);   
+      GetCurrentTableEditor().normalizeTable(null);
     } catch (e) {}
     window.content.focus();
   }
 };
 
 //-----------------------------------------------------------------------------------
 var nsJoinTableCellsCommand =
 {
@@ -3664,17 +3615,17 @@ var nsJoinTableCellsCommand =
         var tagNameObj = { value: "" };
         var countObj = { value: 0 };
         var cell = editor.getSelectedOrParentTableElement(tagNameObj, countObj);
 
         // We need a cell and either > 1 selected cell or a cell to the right
         //  (this cell may originate in a row spanned from above current row)
         // Note that editor returns "td" for "th" also.
         // (this is a pain! Editor and gecko use lowercase tagNames, JS uses uppercase!)
-        if( cell && (tagNameObj.value == "td"))
+        if (cell && (tagNameObj.value == "td"))
         {
           // Selected cells
           if (countObj.value > 1) return true;
 
           var colSpan = cell.getAttribute("colspan");
 
           // getAttribute returns string, we need number
           // no attribute means colspan = 1
@@ -3720,19 +3671,19 @@ var nsSplitTableCellCommand =
     {
       var tagNameObj = { value: "" };
       var countObj = { value: 0 };
       var cell;
       try {
         cell = GetCurrentTableEditor().getSelectedOrParentTableElement(tagNameObj, countObj);
       } catch (e) {}
 
-      // We need a cell parent and there's just 1 selected cell 
+      // We need a cell parent and there's just 1 selected cell
       // or selection is entirely inside 1 cell
-      if ( cell && (tagNameObj.value == "td") && 
+      if ( cell && (tagNameObj.value == "td") &&
            countObj.value <= 1 &&
            IsSelectionInOneCell() )
       {
         var colSpan = cell.getAttribute("colspan");
         var rowSpan = cell.getAttribute("rowspan");
         if (!colSpan) colSpan = 1;
         if (!rowSpan) rowSpan = 1;
         return (colSpan > 1  || rowSpan > 1 ||
@@ -3851,17 +3802,17 @@ var nsConvertToTable =
             return false;
         }
 
         // Selection start and end must be in the same cell
         //   in same cell or both are NOT in a cell
         if ( GetParentTableCell(selection.focusNode) !=
              GetParentTableCell(selection.anchorNode) )
           return false
-      
+
         return true;
       }
     }
     return false;
   },
 
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
--- a/editor/ui/composer/content/editorUtilities.js
+++ b/editor/ui/composer/content/editorUtilities.js
@@ -33,49 +33,30 @@ const gMac = "Mac";
 const kWebComposerWindowID = "editorWindow";
 const kMailComposerWindowID = "msgcomposeWindow";
 
 var gIsHTMLEditor;
 /************* Message dialogs ***************/
 
 function AlertWithTitle(title, message, parentWindow)
 {
-  if (!parentWindow)
-    parentWindow = window;
-
-  var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
-  promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
-
-  if (promptService)
-  {
-    if (!title)
-      title = GetString("Alert");
-
-    // "window" is the calling dialog window
-    promptService.alert(parentWindow, title, message);
-  }
+  // "window" is the calling dialog window
+  Services.prompt.alert(parentWindow || window, title || GetString("Alert"), message);
 }
 
 // Optional: Caller may supply text to substitue for "Ok" and/or "Cancel"
 function ConfirmWithTitle(title, message, okButtonText, cancelButtonText)
 {
-  var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService();
-  promptService = promptService.QueryInterface(Components.interfaces.nsIPromptService);
+  let okFlag = okButtonText ? Services.prompt.BUTTON_TITLE_IS_STRING : Services.prompt.BUTTON_TITLE_OK;
+  let cancelFlag = cancelButtonText ? Services.prompt.BUTTON_TITLE_IS_STRING : Services.prompt.BUTTON_TITLE_CANCEL;
 
-  if (promptService)
-  {
-    var okFlag = okButtonText ? promptService.BUTTON_TITLE_IS_STRING : promptService.BUTTON_TITLE_OK;
-    var cancelFlag = cancelButtonText ? promptService.BUTTON_TITLE_IS_STRING : promptService.BUTTON_TITLE_CANCEL;
-
-    return promptService.confirmEx(window, title, message,
-                            (okFlag * promptService.BUTTON_POS_0) +
-                            (cancelFlag * promptService.BUTTON_POS_1),
-                            okButtonText, cancelButtonText, null, null, {value:0}) == 0;
-  }
-  return false;
+  return Services.prompt.confirmEx(window, title, message,
+                                   (okFlag * Services.prompt.BUTTON_POS_0) +
+                                   (cancelFlag * Services.prompt.BUTTON_POS_1),
+                                   okButtonText, cancelButtonText, null, null, {value:0}) == 0;
 }
 
 /************* String Utilities ***************/
 
 function GetString(name)
 {
   if (!gStringBundle)
   {
@@ -116,30 +97,33 @@ function GetFormattedString(aName, aVal)
       return gStringBundle.formatStringFromName(aName, [aVal], 1);
     } catch (e) {}
   }
   return null;
 }
 
 function TrimStringLeft(string)
 {
-  if(!string) return "";
+  if (!string)
+    return "";
   return string.trimLeft();
 }
 
 function TrimStringRight(string)
 {
-  if (!string) return "";
+  if (!string)
+    return "";
   return string.trimRight();
 }
 
 // Remove whitespace from both ends of a string
 function TrimString(string)
 {
-  if (!string) return "";
+  if (!string)
+    return "";
   return string.trim();
 }
 
 function IsWhitespace(string)
 {
   return /^\s/.test(string);
 }
 
@@ -965,15 +949,15 @@ function GetHTMLOrCSSStyleValue(element,
 
 /************* Miscellaneous ***************/
 // Clone simple JS objects
 function Clone(obj) 
 { 
   var clone = {};
   for (var i in obj)
   {
-    if( typeof obj[i] == 'object')
+    if (typeof obj[i] == 'object')
       clone[i] = Clone(obj[i]);
     else
       clone[i] = obj[i];
   }
   return clone;
 }
--- a/editor/ui/dialogs/content/EditorPublishProgress.js
+++ b/editor/ui/dialogs/content/EditorPublishProgress.js
@@ -290,29 +290,26 @@ function CheckKeepOpen()
     gTimerID = null;
   }
 }
 
 function onClose()
 {
   if (!gFinished)
   {
-    const nsIPromptService = Components.interfaces.nsIPromptService;
-    var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
-                                  .getService(nsIPromptService);
-    const buttonFlags = (nsIPromptService.BUTTON_TITLE_IS_STRING *
-                         nsIPromptService.BUTTON_POS_0) +
-                        (nsIPromptService.BUTTON_TITLE_CANCEL *
-                         nsIPromptService.BUTTON_POS_1);
-    var button = promptService.confirmEx(window,
-                                         GetString("CancelPublishTitle"),
-                                         GetString("CancelPublishMessage"),
-                                         buttonFlags,
-                                         GetString("CancelPublishContinue"),
-                                         null, null, null, {});
+    const buttonFlags = (Services.prompt.BUTTON_TITLE_IS_STRING *
+                         Services.prompt.BUTTON_POS_0) +
+                        (Services.prompt.BUTTON_TITLE_CANCEL *
+                         Services.prompt.BUTTON_POS_1);
+    let button = Services.prompt.confirmEx(window,
+                                           GetString("CancelPublishTitle"),
+                                           GetString("CancelPublishMessage"),
+                                           buttonFlags,
+                                           GetString("CancelPublishContinue"),
+                                           null, null, null, {});
     if (button == 0)
       return false;
   }
 
   if (gTimerID)
   {
     clearTimeout(gTimerID);
     gTimerID = null;