Bug 689599 - Ensure postData is non-null before accessing it in Browser.loadURI [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Tue, 27 Sep 2011 12:45:49 -0700
changeset 77728 45e745c780d7c68d8d450601b30340e9e95dd726
parent 77727 29897f5185bb650caae6cf429c154ab00532e036
child 77729 78a47ef40099a331cc87e95680f2782c0459f704
push id2213
push usermbrubeck@mozilla.com
push dateTue, 27 Sep 2011 19:46:40 +0000
treeherdermozilla-inbound@45e745c780d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs689599
milestone10.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 689599 - Ensure postData is non-null before accessing it in Browser.loadURI [r=mfinkle]
mobile/chrome/content/browser-ui.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -708,19 +708,20 @@ var BrowserUI = {
     Browser.hideSidebars();
     this.closeAutoComplete();
 
     // Make sure we're online before attempting to load
     Util.forceOnline();
 
     let engine = Services.search.getEngineByName(aName);
     let submission = engine.getSubmission(searchValue, null);
-    Browser.selectedBrowser.userTypedValue = submission.uri.spec;
     Browser.loadURI(submission.uri.spec, { postData: submission.postData });
 
+    // loadURI may open a new tab, so get the selectedBrowser afterward.
+    Browser.selectedBrowser.userTypedValue = submission.uri.spec;
     this._titleChanged(Browser.selectedBrowser);
   },
 
   updateUIFocus: function _updateUIFocus() {
     if (Elements.contentShowing.getAttribute("disabled") == "true")
       Browser.selectedBrowser.messageManager.sendAsyncMessage("Browser:Blur", { });
   },
 
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -596,18 +596,17 @@ var Browser = {
 
       // Add new tab before closing the old one, in case there is only one.
       Browser.addTab(aURI, true, oldTab, aParams);
       if (/^about:(blank|empty)$/.test(currentURI) && !browser.canGoBack && !browser.canGoForward) {
         oldTab.chromeTab.ignoreUndo = true;
         this.closeTab(oldTab, { forceClose: true });
         oldTab = null;
       }
-    }
-    else {
+    } else {
       let params = aParams || {};
       let flags = params.flags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
       browser.loadURIWithFlags(aURI, flags, params.referrerURI, params.charset, params.postData);
     }
   },
 
   /**
    * Determine if the given URL is a shortcut/keyword and, if so, expand it
@@ -2937,17 +2936,17 @@ Tab.prototype = {
     let browser = this._createBrowser(aURI, null);
 
     // Should we fully load the new browser, or wait until later
     if ("delayLoad" in aParams && aParams.delayLoad)
       return;
 
     try {
       let flags = aParams.flags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
-      let postData = "postData" in aParams ? aParams.postData.value : null;
+      let postData = ("postData" in aParams && aParams.postData) ? aParams.postData.value : null;
       let referrerURI = "referrerURI" in aParams ? aParams.referrerURI : null;
       let charset = "charset" in aParams ? aParams.charset : null;
       browser.loadURIWithFlags(aURI, flags, referrerURI, charset, postData);
     } catch(e) {
       dump("Error: " + e + "\n");
     }
   },