Backout bug 723001.
authorJosh Matthews <josh@joshmatthews.net>
Thu, 11 Oct 2012 22:22:43 -0400
changeset 110174 038ef23a04cda664bc09cc9f61c4cfcd53f7ec98
parent 110173 6db2ba78beb85df414f8c85e2b04709882a1ad5f
child 110175 bb55953508db0a3d86fa8f7937cedafbe28e16bb
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
bugs723001
milestone19.0a1
Backout bug 723001.
browser/components/search/content/search.xml
browser/components/search/test/Makefile.in
browser/components/search/test/browser_contextmenu.js
browser/components/search/test/browser_private_search.js
toolkit/components/satchel/formSubmitListener.js
toolkit/components/satchel/nsFormHistory.js
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -431,17 +431,17 @@
           }
           else {
             var newTabPref = textBox._prefBranch.getBoolPref("browser.search.openintab");
             if ((aEvent && aEvent.altKey) ^ newTabPref)
               where = "tab";
           }
 
           // Save the current value in the form history
-          if (textValue && !gPrivateBrowsingUI.privateWindow) {
+          if (textValue) {
             try {
               textBox._formHistSvc.addEntry(textBox.getAttribute("autocompletesearchparam"),
                                             textValue);
             } catch (ex) {
               Components.utils.reportError("Saving search to form history failed: " + ex);
             }
           }
 
--- a/browser/components/search/test/Makefile.in
+++ b/browser/components/search/test/Makefile.in
@@ -17,12 +17,11 @@ MOCHITEST_BROWSER_FILES = 	  browser_405
 	                  testEngine_mozsearch.xml \
 	                  testEngine.src \
 	                  browser_426329.js \
 	                  426329.xml \
 	                  browser_483086.js \
 	                  483086-1.xml \
 	                  483086-2.xml \
 	                  test.html \
-	                  browser_private_search.js \
 	                  $(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/browser/components/search/test/browser_contextmenu.js
+++ b/browser/components/search/test/browser_contextmenu.js
@@ -54,17 +54,16 @@ function test() {
 
     // check the search menu item and then perform a search
     function checkContextMenu() {
       var searchItem = contextMenu.getElementsByAttribute("id", "context-searchselect")[0];
       ok(searchItem, "Got search context menu item");
       is(searchItem.label, 'Search ' + ENGINE_NAME + ' for "test search"', "Check context menu label");
       is(searchItem.disabled, false, "Check that search context menu item is enabled");
       searchItem.click();
-      contextMenu.hidePopup();
     }
 
     function checkSearchURL(event){
       is(event.originalTarget.URL,
          "http://mochi.test:8888/browser/browser/components/search/test/?test=test+search&ie=utf-8&client=app&channel=contextsearch",
          "Checking context menu search URL");
       finalize();
     }
deleted file mode 100644
--- a/browser/components/search/test/browser_private_search.js
+++ /dev/null
@@ -1,101 +0,0 @@
-// This test performs a search in a public window, then a different
-// search in a private window, and then checks in the public window
-// whether there is an autocomplete entry for the private search.
-
-function onLoad(callback) {
-  gBrowser.addEventListener("DOMContentLoaded", function load() {
-    gBrowser.removeEventListener("DOMContentLoaded", load, false);
-    callback();
-  }, false);
-}
-
-function doPrivateTest(searchBar) {
-  gPrivateBrowsingUI.toggleMode();
-  Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
-
-  searchBar.value = "p";
-  searchBar.focus();
-  let popup = searchBar.textbox.popup;
-  //searchBar.textbox.closePopup();
-
-  info("adding listener");
-  popup.addEventListener("popupshowing", function showing() {
-    let entries = getMenuEntries(searchBar);
-    for (var i = 0; i < entries.length; i++)
-      isnot(entries[0], "private test", "shouldn't see private autocomplete entries");
-    popup.removeEventListener("popupshowing", showing, false);
-
-    searchBar.textbox.toggleHistoryPopup();
-    executeSoon(function() {
-    searchBar.value = "";
-    gBrowser.addTab();
-    gBrowser.removeCurrentTab();
-    content.location.href = "about:blank";
-    var engine = Services.search.getEngineByName("Bug 426329");
-    Services.search.removeEngine(engine);
-    finish();
-                  
-                });
-  }, false);
-
-  info("triggering popup");
-  searchBar.textbox.showHistoryPopup();  
-}
-
-function doTest() {
-  let searchBar = BrowserSearch.searchBar;
-  ok(searchBar, "got search bar");
-  
-  onLoad(function() {
-    Services.prefs.setBoolPref("browser.privatebrowsing.keep_current_session", true);
-    gPrivateBrowsingUI.toggleMode();
-
-    onLoad(function() {
-      doPrivateTest(searchBar);
-    });
- 
-    searchBar.value = "private test";
-    searchBar.focus();
-    EventUtils.synthesizeKey("VK_RETURN", {});
-  });
-    
-  searchBar.value = "public test";
-  searchBar.focus();
-  EventUtils.synthesizeKey("VK_RETURN", {});
-}
-
-function test() {
-  waitForExplicitFinish();
-  //gBrowser.addTab();
-  //let testBrowser = gBrowser.selectedBrowser;
- 
-  function observer(aSub, aTopic, aData) {
-    switch (aData) {
-      case "engine-current":
-        ok(ss.currentEngine.name == "Bug 426329", "currentEngine set");
-        doTest();
-        break;
-      default:
-      break;
-    }
-  }
-
-  var ss = Services.search;
-  Services.obs.addObserver(observer, "browser-search-engine-modified", false);
-  ss.addEngine("http://mochi.test:8888/browser/browser/components/search/test/426329.xml",
-               Ci.nsISearchEngine.DATA_XML, "data:image/x-icon,%00",
-               false);
-}
-
-function getMenuEntries(searchBar) {
-  var entries = [];
-  var autocompleteMenu = searchBar.textbox.popup;
-  // Could perhaps pull values directly from the controller, but it seems
-  // more reliable to test the values that are actually in the tree?
-  var column = autocompleteMenu.tree.columns[0];
-  var numRows = autocompleteMenu.tree.view.rowCount;
-  for (var i = 0; i < numRows; i++) {
-    entries.push(autocompleteMenu.tree.view.getValueAt(i, column));
-  }
-  return entries;
-}
--- a/toolkit/components/satchel/formSubmitListener.js
+++ b/toolkit/components/satchel/formSubmitListener.js
@@ -4,17 +4,16 @@
 
 (function(){
 
 var Cc = Components.classes;
 var Ci = Components.interfaces;
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
 
 var satchelFormListener = {
     QueryInterface : XPCOMUtils.generateQI([Ci.nsIFormSubmitObserver,
                                             Ci.nsIDOMEventListener,
                                             Ci.nsObserver,
                                             Ci.nsISupportsWeakReference]),
 
     debug          : true,
@@ -99,18 +98,16 @@ var satchelFormListener = {
             // Even though the global context is for a specific browser, we
             // can receive observer events from other tabs! Ensure this event
             // is about our content.
             if (domWin.top != content)
                 return;
             if (!this.enabled)
                 return;
 
-            if (PrivateBrowsingUtils.isWindowPrivate(domWin))
-                return;
 
             this.log("Form submit observer notified.");
 
             if (!this.saveHttpsForms) {
                 if (actionURI.schemeIs("https"))
                     return;
                 if (form.ownerDocument.documentURIObject.schemeIs("https"))
                     return;
--- a/toolkit/components/satchel/nsFormHistory.js
+++ b/toolkit/components/satchel/nsFormHistory.js
@@ -68,16 +68,31 @@ FormHistory.prototype = {
     _uuidService: null,
     get uuidService() {
         if (!this._uuidService)
             this._uuidService = Cc["@mozilla.org/uuid-generator;1"].
                                 getService(Ci.nsIUUIDGenerator);
         return this._uuidService;
     },
 
+    // Private Browsing Service
+    // If the service is not available, null will be returned.
+    _privBrowsingSvc : undefined,
+    get privBrowsingSvc() {
+        if (this._privBrowsingSvc == undefined) {
+            if ("@mozilla.org/privatebrowsing;1" in Cc)
+                this._privBrowsingSvc = Cc["@mozilla.org/privatebrowsing;1"].
+                                        getService(Ci.nsIPrivateBrowsingService);
+            else
+                this._privBrowsingSvc = null;
+        }
+        return this._privBrowsingSvc;
+    },
+
+
     log : function log(message) {
         if (!this.debug)
             return;
         dump("FormHistory: " + message + "\n");
         Services.console.logStringMessage("FormHistory: " + message);
     },
 
 
@@ -123,17 +138,18 @@ FormHistory.prototype = {
 
 
     get hasEntries() {
         return (this.countAllEntries() > 0);
     },
 
 
     addEntry : function addEntry(name, value) {
-        if (!this.enabled)
+        if (!this.enabled ||
+            this.privBrowsingSvc && this.privBrowsingSvc.privateBrowsingEnabled)
             return;
 
         this.log("addEntry for " + name + "=" + value);
 
         let now = Date.now() * 1000; // microseconds
 
         let [id, guid] = this.getExistingEntryID(name, value);
         let stmt;