[tbb-commits] [tor-browser] 20/179: Bug 1775312 - When reporting an empty submission url to Glean, use a dummy value as it requires a non-empty string. r=mak, a=RyanVM

gitolite role git at cupani.torproject.org
Fri Aug 19 08:35:17 UTC 2022


This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to branch tor-browser-102.2.0esr-12.0-1
in repository tor-browser.

commit cd42e3cdd940a1f6248cd9f128d81145c5a3bf00
Author: Mark Banner <standard8 at mozilla.com>
AuthorDate: Wed Jun 22 10:51:12 2022 +0000

    Bug 1775312 - When reporting an empty submission url to Glean, use a dummy value as it requires a non-empty string. r=mak, a=RyanVM
    
    Differential Revision: https://phabricator.services.mozilla.com/D149929
---
 toolkit/components/search/SearchService.jsm        |  4 ++--
 .../search/tests/xpcshell/test_defaultEngine.js    | 18 ++++++++++++++++
 .../tests/xpcshell/test_defaultPrivateEngine.js    | 25 +++++++++++++++++++++-
 .../search/tests/xpcshell/test_opensearch.js       | 17 +++++++++++++++
 4 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/toolkit/components/search/SearchService.jsm b/toolkit/components/search/SearchService.jsm
index d0c990126d10a..d424f8fb07013 100644
--- a/toolkit/components/search/SearchService.jsm
+++ b/toolkit/components/search/SearchService.jsm
@@ -2582,7 +2582,7 @@ SearchService.prototype = {
       info.defaultSearchEngineData.loadPath
     );
     Glean.searchEngineDefault.submissionUrl.set(
-      info.defaultSearchEngineData.submissionURL
+      info.defaultSearchEngineData.submissionURL ?? "blank:"
     );
     Glean.searchEngineDefault.verified.set(info.defaultSearchEngineData.origin);
 
@@ -2598,7 +2598,7 @@ SearchService.prototype = {
         info.defaultPrivateSearchEngineData.loadPath
       );
       Glean.searchEnginePrivate.submissionUrl.set(
-        info.defaultPrivateSearchEngineData.submissionURL
+        info.defaultPrivateSearchEngineData.submissionURL ?? "blank:"
       );
       Glean.searchEnginePrivate.verified.set(
         info.defaultPrivateSearchEngineData.origin
diff --git a/toolkit/components/search/tests/xpcshell/test_defaultEngine.js b/toolkit/components/search/tests/xpcshell/test_defaultEngine.js
index 1f16c433ec830..c8ff3e6436ecc 100644
--- a/toolkit/components/search/tests/xpcshell/test_defaultEngine.js
+++ b/toolkit/components/search/tests/xpcshell/test_defaultEngine.js
@@ -82,6 +82,24 @@ add_task(async function test_defaultEngine() {
   });
 });
 
+add_task(async function test_telemetry_empty_submission_url() {
+  let engine = await Services.search.addOpenSearchEngine(
+    gDataUrl + "../opensearch/simple.xml",
+    null
+  );
+  Services.search.defaultPrivateEngine = engine;
+
+  await assertGleanDefaultEngine({
+    normal: {
+      engineId: "other-simple",
+      displayName: "simple",
+      loadPath: "[http]localhost/simple.xml",
+      submissionUrl: "blank:",
+      verified: "verified",
+    },
+  });
+});
+
 add_task(async function test_switch_with_invalid_overriddenBy() {
   engine1.wrappedJSObject.setAttr("overriddenBy", "random at id");
 
diff --git a/toolkit/components/search/tests/xpcshell/test_defaultPrivateEngine.js b/toolkit/components/search/tests/xpcshell/test_defaultPrivateEngine.js
index d7a7620162645..797f4717dba22 100644
--- a/toolkit/components/search/tests/xpcshell/test_defaultPrivateEngine.js
+++ b/toolkit/components/search/tests/xpcshell/test_defaultPrivateEngine.js
@@ -29,7 +29,7 @@ add_setup(async () => {
     true
   );
 
-  useHttpServer();
+  useHttpServer("opensearch");
   await AddonTestUtils.promiseStartupManager();
 
   await Services.search.init();
@@ -214,6 +214,29 @@ add_task(async function test_defaultPrivateEngine() {
   Services.search.defaultEngine = originalDefault;
 });
 
+add_task(async function test_telemetry_private_empty_submission_url() {
+  let engine = await Services.search.addOpenSearchEngine(
+    gDataUrl + "simple.xml",
+    null
+  );
+  Services.search.defaultPrivateEngine = engine;
+
+  await assertGleanDefaultEngine({
+    normal: {
+      engineId: originalDefault.telemetryId,
+    },
+    private: {
+      engineId: "other-simple",
+      displayName: "simple",
+      loadPath: "[http]localhost/simple.xml",
+      submissionUrl: "blank:",
+      verified: "verified",
+    },
+  });
+
+  Services.search.defaultEngine = originalDefault;
+});
+
 add_task(async function test_defaultPrivateEngine_turned_off() {
   Services.search.defaultEngine = originalDefault;
   Services.search.defaultPrivateEngine = engine1;
diff --git a/toolkit/components/search/tests/xpcshell/test_opensearch.js b/toolkit/components/search/tests/xpcshell/test_opensearch.js
index 1145eda43d34f..bdd42860afb5e 100644
--- a/toolkit/components/search/tests/xpcshell/test_opensearch.js
+++ b/toolkit/components/search/tests/xpcshell/test_opensearch.js
@@ -60,6 +60,7 @@ const tests = [
 ];
 
 add_task(async function setup() {
+  Services.fog.initializeFOG();
   useHttpServer("opensearch");
   await AddonTestUtils.promiseStartupManager();
   await Services.search.init();
@@ -141,3 +142,19 @@ for (const test of tests) {
     }
   });
 }
+
+add_task(async function test_telemetry_reporting() {
+  // Use an engine from the previous tests.
+  let engine = Services.search.getEngineByName("simple");
+  Services.search.defaultEngine = engine;
+
+  await assertGleanDefaultEngine({
+    normal: {
+      engineId: "other-simple",
+      displayName: "simple",
+      loadPath: "[http]localhost/simple.xml",
+      submissionUrl: "blank:",
+      verified: "verified",
+    },
+  });
+});

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tbb-commits mailing list