Bug 790898 - Match desktop in restrictions for Add Search Engine option. r=margaret
authorretornam <mozbugs.retornam@gmail.com>
Fri, 06 Dec 2013 16:03:21 -0800
changeset 159255 a7f8d2324426a09a2c1f8ec8d3a3a5263d986159
parent 159254 d0f6fb31e9823db7ef48fbc969a313bf27403e1e
child 159256 445cafa077dc662df612cd258405dbe43f465978
push id3847
push usermleibovic@mozilla.com
push dateSat, 07 Dec 2013 00:03:34 +0000
treeherderfx-team@a7f8d2324426 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs790898
milestone28.0a1
Bug 790898 - Match desktop in restrictions for Add Search Engine option. r=margaret
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -6626,17 +6626,37 @@ var SearchEngines = {
     Services.obs.addObserver(this, "SearchEngines:Add", false);
     Services.obs.addObserver(this, "SearchEngines:Get", false);
     Services.obs.addObserver(this, "SearchEngines:GetVisible", false);
     Services.obs.addObserver(this, "SearchEngines:SetDefault", false);
     Services.obs.addObserver(this, "SearchEngines:Remove", false);
 
     let filter = {
       matches: function (aElement) {
-        return (aElement.form && NativeWindow.contextmenus.textContext.matches(aElement));
+        // Copied from body of isTargetAKeywordField function in nsContextMenu.js
+        if(!(aElement instanceof HTMLInputElement))
+          return false;
+        let form = aElement.form;
+        if (!form || aElement.type == "password")
+          return false;
+
+        let method = form.method.toUpperCase();
+
+        // These are the following types of forms we can create keywords for:
+        //
+        // method    encoding type        can create keyword
+        // GET       *                                   YES
+        //           *                                   YES
+        // POST      *                                   YES
+        // POST      application/x-www-form-urlencoded   YES
+        // POST      text/plain                          NO ( a little tricky to do)
+        // POST      multipart/form-data                 NO
+        // POST      everything else                     YES
+        return (method == "GET" || method == "") ||
+               (form.enctype != "text/plain") && (form.enctype != "multipart/form-data");
       }
     };
     SelectionHandler.actions.SEARCH_ADD = {
       id: "add_search_action",
       label: Strings.browser.GetStringFromName("contextmenu.addSearchEngine"),
       icon: "drawable://ic_url_bar_search",
       selector: filter,
       action: function(aElement) {