Bug 1101648 - UITour API to determine selected search engine. r=gavin
authorFelipe Gomes <felipc@gmail.com>
Thu, 20 Nov 2014 18:21:29 -0200
changeset 217924 10950600b75b1dc93a502ab3c9312c432bcab558
parent 217923 f70b0aed42372edfed5237f6b55007fe0e7ff9ba
child 217925 31c69e3f618167aad9c96b4c10ea960a923c0eca
push id10200
push userfelipc@gmail.com
push dateFri, 28 Nov 2014 02:36:19 +0000
treeherderfx-team@837b0643d0d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs1101648
milestone36.0a1
Bug 1101648 - UITour API to determine selected search engine. r=gavin
browser/modules/UITour.jsm
browser/modules/test/browser_UITour3.js
--- a/browser/modules/UITour.jsm
+++ b/browser/modules/UITour.jsm
@@ -1291,16 +1291,29 @@ this.UITour = {
         });
         break;
       case "appinfo":
         let props = ["defaultUpdateChannel", "version"];
         let appinfo = {};
         props.forEach(property => appinfo[property] = Services.appinfo[property]);
         this.sendPageCallback(aMessageManager, aCallbackID, appinfo);
         break;
+      case "selectedSearchEngine":
+        Services.search.init(rv => {
+          let engine;
+          if (Components.isSuccessCode(rv)) {
+            engine = Services.search.defaultEngine;
+          } else {
+            engine = { identifier: "" };
+          }
+          this.sendPageCallback(aMessageManager, aCallbackID, {
+            searchEngineIdentifier: engine.identifier
+          });
+        });
+        break;
       default:
         log.error("getConfiguration: Unknown configuration requested: " + aConfiguration);
         break;
     }
   },
 
   getAvailableTargets: function(aMessageManager, aChromeWindow, aCallbackID) {
     Task.spawn(function*() {
--- a/browser/modules/test/browser_UITour3.js
+++ b/browser/modules/test/browser_UITour3.js
@@ -3,16 +3,17 @@
 
 "use strict";
 
 let gTestTab;
 let gContentAPI;
 let gContentWindow;
 
 Components.utils.import("resource:///modules/UITour.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
 
 requestLongerTimeout(2);
 
 function test() {
   UITourTest();
 }
 
 let tests = [
@@ -140,9 +141,20 @@ let tests = [
     is(gContentWindow.callbackData.target, "appMenu", "target callback was from the appMenu");
     is(gContentWindow.callbackData.type, "popupshown", "target callback was from the mousedown");
 
     // Cleanup.
     yield hideInfoPromise();
 
     popup.removeAttribute("animate");
   }),
+
+  function test_getConfiguration_selectedSearchEngine(done) {
+    Services.search.init(rv => {
+      ok(Components.isSuccessCode(rv), "Search service initialized");
+      let engine = Services.search.defaultEngine;
+      gContentAPI.getConfiguration("selectedSearchEngine", (data) => {
+        is(data.searchEngineIdentifier, engine.identifier, "Correct engine identifier");
+        done();
+      });
+    });
+  },
 ];