From e79c9647ebedde2603355b2e4a58a5fa2b0071df Mon Sep 17 00:00:00 2001 From: Michael Kaply Date: Mon, 20 Aug 2018 11:50:27 +0000 Subject: [PATCH] Bug 1481442 - Remove followonsearch system add-on. r=Standard8 Differential Revision: https://phabricator.services.mozilla.com/D3639 --HG-- extra : moz-landing-system : lando --- .eslintignore | 3 +- .../extensions/followonsearch/.eslintrc.js | 8 - .../extensions/followonsearch/bootstrap.js | 192 ----------- .../content/followonsearch-fs.js | 308 ------------------ browser/extensions/followonsearch/install.rdf | 22 -- browser/extensions/followonsearch/jar.mn | 7 - browser/extensions/followonsearch/moz.build | 17 - .../followonsearch/test/browser/.eslintrc.js | 7 - .../followonsearch/test/browser/browser.ini | 7 - .../test/browser/browser_followOnTelemetry.js | 66 ---- .../followonsearch/test/browser/test.html | 15 - .../followonsearch/test/browser/test2.html | 8 - .../test/browser/testEngine.xml | 15 - 13 files changed, 1 insertion(+), 674 deletions(-) delete mode 100644 browser/extensions/followonsearch/.eslintrc.js delete mode 100644 browser/extensions/followonsearch/bootstrap.js delete mode 100644 browser/extensions/followonsearch/content/followonsearch-fs.js delete mode 100644 browser/extensions/followonsearch/install.rdf delete mode 100644 browser/extensions/followonsearch/jar.mn delete mode 100644 browser/extensions/followonsearch/moz.build delete mode 100644 browser/extensions/followonsearch/test/browser/.eslintrc.js delete mode 100644 browser/extensions/followonsearch/test/browser/browser.ini delete mode 100644 browser/extensions/followonsearch/test/browser/browser_followOnTelemetry.js delete mode 100644 browser/extensions/followonsearch/test/browser/test.html delete mode 100644 browser/extensions/followonsearch/test/browser/test2.html delete mode 100644 browser/extensions/followonsearch/test/browser/testEngine.xml diff --git a/.eslintignore b/.eslintignore index 044c26f480a3..d3c457cad62b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -80,9 +80,8 @@ browser/components/sessionstore/test/unit/data/sessionstore_invalid.js browser/components/enterprisepolicies/schemas/schema.jsm # generated & special files in cld2 browser/components/translation/cld2/** -# Screenshots and Follow-on search are imported as a system add-on and have +# Screenshots is imported as a system add-on and has # their own lint rules currently. -browser/extensions/followonsearch/** browser/extensions/screenshots/** browser/extensions/pdfjs/content/build** browser/extensions/pdfjs/content/web** diff --git a/browser/extensions/followonsearch/.eslintrc.js b/browser/extensions/followonsearch/.eslintrc.js deleted file mode 100644 index 7086cdb848d6..000000000000 --- a/browser/extensions/followonsearch/.eslintrc.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; - -module.exports = { - "env": { - "browser": true, - "node": false - } -}; diff --git a/browser/extensions/followonsearch/bootstrap.js b/browser/extensions/followonsearch/bootstrap.js deleted file mode 100644 index 276d72e33f5e..000000000000 --- a/browser/extensions/followonsearch/bootstrap.js +++ /dev/null @@ -1,192 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* global APP_SHUTDOWN:false */ - -"use strict"; - -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -ChromeUtils.import("resource://gre/modules/Timer.jsm"); - -// Preferences this add-on uses. -const kPrefPrefix = "extensions.followonsearch."; -const PREF_LOGGING = `${kPrefPrefix}logging`; - -const kExtensionID = "followonsearch@mozilla.com"; -const kSaveTelemetryMsg = `${kExtensionID}:save-telemetry`; -const kShutdownMsg = `${kExtensionID}:shutdown`; - -const frameScript = `chrome://followonsearch/content/followonsearch-fs.js?q=${Math.random()}`; - -const validSearchTypes = [ - // A search is a follow-on search from an SAP. - "follow-on", - // The search is a "search access point". - "sap", -]; - -var gLoggingEnabled = false; -var gTelemetryActivated = false; - -/** - * Logs a message to the console if logging is enabled. - * - * @param {String} message The message to log. - */ -function log(message) { - if (gLoggingEnabled) { - console.log("Follow-On Search", message); - } -} - -/** - * Handles receiving a message from the content process to save telemetry. - * - * @param {Object} message The message received. - */ -function handleSaveTelemetryMsg(message) { - if (message.name != kSaveTelemetryMsg) { - throw new Error(`Unexpected message received: ${message.name}`); - } - - let info = message.data; - - if (!validSearchTypes.includes(info.type)) { - throw new Error("Unexpected type!"); - } - - log(info); - - let histogram = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS"); - let payload = `${info.sap}.${info.type}:unknown:${info.code}`; - if (info.extra) { - payload += `:${info.extra}` - } - histogram.add(payload); -} - -/** - * Activates recording of telemetry if it isn't already activated. - */ -function activateTelemetry() { - if (gTelemetryActivated) { - return; - } - - gTelemetryActivated = true; - - Services.mm.addMessageListener(kSaveTelemetryMsg, handleSaveTelemetryMsg); - Services.mm.loadFrameScript(frameScript, true); -} - -/** - * Deactivites recording of telemetry if it isn't already deactivated. - */ -function deactivateTelemetry() { - if (!gTelemetryActivated) { - return; - } - - Services.mm.removeMessageListener(kSaveTelemetryMsg, handleSaveTelemetryMsg); - Services.mm.removeDelayedFrameScript(frameScript); - Services.mm.broadcastAsyncMessage(kShutdownMsg); - - gTelemetryActivated = false; -} - -/** - * cohortManager is used to decide which users to enable the add-on for. - */ -var cohortManager = { - // Indicates whether the telemetry should be enabled. - enableForUser: false, - - // Records if we've already run init. - _definedThisSession: false, - - /** - * Initialises the manager, working out if telemetry should be enabled - * for the user. - */ - init() { - if (this._definedThisSession) { - return; - } - - this._definedThisSession = true; - this.enableForUser = false; - - try { - let distId = Services.prefs.getCharPref("distribution.id", ""); - if (distId) { - log("It is a distribution, not setting up nor enabling telemetry."); - return; - } - } catch (e) {} - - log("Enabling telemetry for user"); - this.enableForUser = true; - }, -}; - -/** - * Called when the add-on is installed. - * - * @param {Object} data Data about the add-on. - * @param {Number} reason Indicates why the extension is being installed. - */ -function install(data, reason) { - // Nothing specifically to do, startup will set everything up for us. -} - -/** - * Called when the add-on is uninstalled. - * - * @param {Object} data Data about the add-on. - * @param {Number} reason Indicates why the extension is being uninstalled. - */ -function uninstall(data, reason) { - // Nothing specifically to do, shutdown does what we need. -} - -/** - * Called when the add-on starts up. - * - * @param {Object} data Data about the add-on. - * @param {Number} reason Indicates why the extension is being started. - */ -function startup(data, reason) { - try { - gLoggingEnabled = Services.prefs.getBoolPref(PREF_LOGGING, false); - } catch (e) { - // Needed until Firefox 54 - } - - cohortManager.init(); - - if (cohortManager.enableForUser) { - // Workaround for bug 1202125 - // We need to delay our loading so that when we are upgraded, - // our new script doesn't get the shutdown message. - setTimeout(() => { - activateTelemetry(); - }, 1000); - } -} - -/** - * Called when the add-on shuts down. - * - * @param {Object} data Data about the add-on. - * @param {Number} reason Indicates why the extension is being shut down. - */ -function shutdown(data, reason) { - // If we're shutting down, skip the cleanup to save time. - if (reason === APP_SHUTDOWN) { - return; - } - - deactivateTelemetry(); -} diff --git a/browser/extensions/followonsearch/content/followonsearch-fs.js b/browser/extensions/followonsearch/content/followonsearch-fs.js deleted file mode 100644 index aaba382d0c86..000000000000 --- a/browser/extensions/followonsearch/content/followonsearch-fs.js +++ /dev/null @@ -1,308 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* eslint-env mozilla/frame-script */ - -"use strict"; - -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -XPCOMUtils.defineLazyGlobalGetters(this, ["URLSearchParams"]); - -const kExtensionID = "followonsearch@mozilla.com"; -const kSaveTelemetryMsg = `${kExtensionID}:save-telemetry`; -const kShutdownMsg = `${kExtensionID}:shutdown`; -const kLastSearchQueueDepth = 10; - -/** - * A map of search domains with their expected codes. - */ -let searchDomains = [{ - "domains": [ "search.yahoo.co.jp" ], - "search": "p", - "followOnSearch": "ai", - "prefix": ["fr"], - "codes": ["mozff"], - "sap": "yahoo", -}, { - "domains": [ "www.bing.com" ], - "search": "q", - "prefix": ["pc"], - "reportPrefix": "form", - "codes": ["MOZI", "MOZD", "MZSL01", "MZSL02", "MZSL03", "MOZ2"], - "sap": "bing", -}, { - // The Google domains. - "domains": [ - "www.google.com", "www.google.ac", "www.google.ad", "www.google.ae", - "www.google.com.af", "www.google.com.ag", "www.google.com.ai", - "www.google.al", "www.google.am", "www.google.co.ao", "www.google.com.ar", - "www.google.as", "www.google.at", "www.google.com.au", "www.google.az", - "www.google.ba", "www.google.com.bd", "www.google.be", "www.google.bf", - "www.google.bg", "www.google.com.bh", "www.google.bi", "www.google.bj", - "www.google.com.bn", "www.google.com.bo", "www.google.com.br", - "www.google.bs", "www.google.bt", "www.google.co.bw", "www.google.by", - "www.google.com.bz", "www.google.ca", "www.google.com.kh", "www.google.cc", - "www.google.cd", "www.google.cf", "www.google.cat", "www.google.cg", - "www.google.ch", "www.google.ci", "www.google.co.ck", "www.google.cl", - "www.google.cm", "www.google.cn", "www.google.com.co", "www.google.co.cr", - "www.google.com.cu", "www.google.cv", "www.google.cx", "www.google.com.cy", - "www.google.cz", "www.google.de", "www.google.dj", "www.google.dk", - "www.google.dm", "www.google.com.do", "www.google.dz", "www.google.com.ec", - "www.google.ee", "www.google.com.eg", "www.google.es", "www.google.com.et", - "www.google.eu", "www.google.fi", "www.google.com.fj", "www.google.fm", - "www.google.fr", "www.google.ga", "www.google.ge", "www.google.gf", - "www.google.gg", "www.google.com.gh", "www.google.com.gi", "www.google.gl", - "www.google.gm", "www.google.gp", "www.google.gr", "www.google.com.gt", - "www.google.gy", "www.google.com.hk", "www.google.hn", "www.google.hr", - "www.google.ht", "www.google.hu", "www.google.co.id", "www.google.iq", - "www.google.ie", "www.google.co.il", "www.google.im", "www.google.co.in", - "www.google.io", "www.google.is", "www.google.it", "www.google.je", - "www.google.com.jm", "www.google.jo", "www.google.co.jp", "www.google.co.ke", - "www.google.ki", "www.google.kg", "www.google.co.kr", "www.google.com.kw", - "www.google.kz", "www.google.la", "www.google.com.lb", "www.google.com.lc", - "www.google.li", "www.google.lk", "www.google.co.ls", "www.google.lt", - "www.google.lu", "www.google.lv", "www.google.com.ly", "www.google.co.ma", - "www.google.md", "www.google.me", "www.google.mg", "www.google.mk", - "www.google.ml", "www.google.com.mm", "www.google.mn", "www.google.ms", - "www.google.com.mt", "www.google.mu", "www.google.mv", "www.google.mw", - "www.google.com.mx", "www.google.com.my", "www.google.co.mz", - "www.google.com.na", "www.google.ne", "www.google.nf", "www.google.com.ng", - "www.google.com.ni", "www.google.nl", "www.google.no", "www.google.com.np", - "www.google.nr", "www.google.nu", "www.google.co.nz", "www.google.com.om", - "www.google.com.pk", "www.google.com.pa", "www.google.com.pe", - "www.google.com.ph", "www.google.pl", "www.google.com.pg", "www.google.pn", - "www.google.com.pr", "www.google.ps", "www.google.pt", "www.google.com.py", - "www.google.com.qa", "www.google.ro", "www.google.rs", "www.google.ru", - "www.google.rw", "www.google.com.sa", "www.google.com.sb", "www.google.sc", - "www.google.se", "www.google.com.sg", "www.google.sh", "www.google.si", - "www.google.sk", "www.google.com.sl", "www.google.sn", "www.google.sm", - "www.google.so", "www.google.st", "www.google.sr", "www.google.com.sv", - "www.google.td", "www.google.tg", "www.google.co.th", "www.google.com.tj", - "www.google.tk", "www.google.tl", "www.google.tm", "www.google.to", - "www.google.tn", "www.google.com.tr", "www.google.tt", "www.google.com.tw", - "www.google.co.tz", "www.google.com.ua", "www.google.co.ug", - "www.google.co.uk", "www.google.us", "www.google.com.uy", "www.google.co.uz", - "www.google.com.vc", "www.google.co.ve", "www.google.vg", "www.google.co.vi", - "www.google.com.vn", "www.google.vu", "www.google.ws", "www.google.co.za", - "www.google.co.zm", "www.google.co.zw", - ], - "search": "q", - "prefix": ["client"], - "followOnSearch": "oq", - "codes": ["firefox-b-ab", "firefox-b", "firefox-b-1-ab", "firefox-b-1"], - "sap": "google", -}, { - // This is intended only for tests. - "domains": [ "mochi.test" ], - "search": "m", - "prefix": ["mt"], - "followOnSearch": "mtfo", - "reportPrefix": "form", - "codes": ["TEST"], - "sap": "mochitest" -}]; - -function getSearchDomainCodes(host) { - for (let domainInfo of searchDomains) { - if (domainInfo.domains.includes(host)) { - return domainInfo; - } - } - return null; -} - -/** - * Used for debugging to log messages. - * - * @param {String} message The message to log. - */ -function log(message) { - // console.log(message); -} - -// Hack to handle the most common reload/back/forward case. -// If gLastSearchQueue includes the current URL, ignore the search. -// This also prevents us from handling reloads with hashes twice -let gLastSearchQueue = []; -gLastSearchQueue.push = function(...args) { - if (this.length >= kLastSearchQueueDepth) { - this.shift(); - } - return Array.prototype.push.apply(this, args); -}; - -// Track if we are in the middle of a Google session -// that started from Firefox -let searchingGoogle = false; - -/** - * Since most codes are in the URL, we can handle them via - * a progress listener. - */ -var webProgressListener = { - QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]), - onLocationChange(aWebProgress, aRequest, aLocation, aFlags) - { - if (aWebProgress.DOMWindow && (aWebProgress.DOMWindow != content)) { - return; - } - try { - if (!aWebProgress.isTopLevel || - // Not a URL - (!aLocation.schemeIs("http") && !aLocation.schemeIs("https")) || - // Doesn't have a query string or a ref - (!aLocation.query && !aLocation.ref)) { - searchingGoogle = false; - return; - } - if (gLastSearchQueue.includes(aLocation.spec)) { - // If it's a recent search, just return. We - // don't reset searchingGoogle though because - // we might still be doing that. - return; - } - let domainInfo = getSearchDomainCodes(aLocation.host); - if (!domainInfo) { - searchingGoogle = false; - return; - } - - let queries = new URLSearchParams(aLocation.query); - // Yahoo has switched to Unified search so we can get - // different codes on the same domain. Hack for now - // to allow two different prefixes for codes - let code = queries.get(domainInfo.prefix[0]); - if (!code && domainInfo.prefix.length > 1) { - code = queries.get(domainInfo.prefix[1]); - } - // Special case Google so we can track searches - // without codes from the browser. - if (domainInfo.sap == "google") { - if (aLocation.filePath == "/search") { - gLastSearchQueue.push(aLocation.spec); - // Our engine currently sends oe and ie - no one else does - if (queries.get("oe") && queries.get("ie")) { - sendSaveTelemetryMsg(code ? code : "none", code, "sap"); - searchingGoogle = true; - } else { - // The tbm value is the specific type of search (Books, Images, News, etc). - // These are referred to as vertical searches. - let tbm = queries.get("tbm"); - if (searchingGoogle) { - sendSaveTelemetryMsg(code ? code : "none", code, "follow-on", tbm ? `vertical-${tbm}` : null); - } else if (code) { - // Trying to do the right thing for back button to existing entries - sendSaveTelemetryMsg(code, domainInfo.sap, "follow-on", tbm ? `vertical-${tbm}` : null); - } - } - } - // Special case all Google. Otherwise our code can - // show up in maps - return; - } - searchingGoogle = false; - if (queries.get(domainInfo.search)) { - if (domainInfo.codes.includes(code)) { - if (domainInfo.reportPrefix && - queries.get(domainInfo.reportPrefix)) { - code = queries.get(domainInfo.reportPrefix); - } - if (queries.get(domainInfo.followOnSearch)) { - log(`${aLocation.host} search with code ${code} - Follow on`); - sendSaveTelemetryMsg(code, domainInfo.sap, "follow-on"); - } else { - log(`${aLocation.host} search with code ${code} - First search via Firefox`); - sendSaveTelemetryMsg(code, domainInfo.sap, "sap"); - } - gLastSearchQueue.push(aLocation.spec); - } - } - } catch (e) { - console.error(e); - } - }, -}; - -/** - * Parses a cookie string into separate parts. - * - * @param {String} cookieString The string to parse. - * @param {Object} [params] An optional object to append the parameters to. - * @return {Object} An object containing the query keys and values. - */ -function parseCookies(cookieString, params = {}) { - var cookies = cookieString.split(/;\s*/); - - for (var i in cookies) { - var kvp = cookies[i].split(/=(.+)/); - params[kvp[0]] = kvp[1]; - } - - return params; -} - -/** - * Page load listener to handle loads www.bing.com only. - * We have to use a page load listener because we need - * to check cookies. - * @param {Object} event The page load event. - */ -function onPageLoad(event) { - var doc = event.target; - var win = doc.defaultView; - if (win != win.top) { - return; - } - var uri = doc.documentURIObject; - if (!(uri instanceof Ci.nsIStandardURL) || - (!uri.schemeIs("http") && !uri.schemeIs("https")) || - uri.host != "www.bing.com" || - !doc.location.search || - gLastSearchQueue.includes(uri.spec)) { - return; - } - var queries = new URLSearchParams(doc.location.search.toLowerCase()); - // For Bing, QBRE form code is used for all follow-on search - if (queries.get("form") != "qbre") { - return; - } - if (parseCookies(doc.cookie).SRCHS == "PC=MOZI") { - log(`${uri.host} search with code MOZI - Follow on`); - sendSaveTelemetryMsg("MOZI", "bing", "follow-on"); - gLastSearchQueue.push(uri.spec); - } -} - -/** - * Sends a message to the process that added this script to tell it to save - * telemetry. - * - * @param {String} code The codes used for the search engine. - * @param {String} sap The SAP code. - * @param {String} type The type of search (sap/follow-on). - * @param {String} extra Any additional parameters (Optional) - */ -function sendSaveTelemetryMsg(code, sap, type, extra) { - sendAsyncMessage(kSaveTelemetryMsg, { - code, - sap, - type, - extra, - }); -} - -addEventListener("DOMContentLoaded", onPageLoad, false); -docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebProgress) - .addProgressListener(webProgressListener, Ci.nsIWebProgress.NOTIFY_LOCATION); - -let gDisabled = false; - -addMessageListener(kShutdownMsg, () => { - if (!gDisabled) { - removeEventListener("DOMContentLoaded", onPageLoad, false); - docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebProgress) - .removeProgressListener(webProgressListener); - gDisabled = true; - } -}); diff --git a/browser/extensions/followonsearch/install.rdf b/browser/extensions/followonsearch/install.rdf deleted file mode 100644 index 971f8ed63889..000000000000 --- a/browser/extensions/followonsearch/install.rdf +++ /dev/null @@ -1,22 +0,0 @@ - - - - - followonsearch@mozilla.com - Follow-on Search Telemetry - 0.9.7 - 2 - true - true - - - {ec8030f7-c20a-464f-9b0e-13a3a9e97384} - 52.0 - 66.* - - - - diff --git a/browser/extensions/followonsearch/jar.mn b/browser/extensions/followonsearch/jar.mn deleted file mode 100644 index 8bad68630202..000000000000 --- a/browser/extensions/followonsearch/jar.mn +++ /dev/null @@ -1,7 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -[features/followonsearch@mozilla.com] chrome.jar: -% content followonsearch %content/ - content/ (content/*) diff --git a/browser/extensions/followonsearch/moz.build b/browser/extensions/followonsearch/moz.build deleted file mode 100644 index 4a95c67135c1..000000000000 --- a/browser/extensions/followonsearch/moz.build +++ /dev/null @@ -1,17 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -with Files("**"): - BUG_COMPONENT = ("Firefox", "Search") - -FINAL_TARGET_FILES.features['followonsearch@mozilla.com'] += [ - 'bootstrap.js', - 'install.rdf', -] - -BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] - -JAR_MANIFESTS += ['jar.mn'] diff --git a/browser/extensions/followonsearch/test/browser/.eslintrc.js b/browser/extensions/followonsearch/test/browser/.eslintrc.js deleted file mode 100644 index 71818fe6506a..000000000000 --- a/browser/extensions/followonsearch/test/browser/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -module.exports = { - "extends": [ - "plugin:mozilla/browser-test", - ], -}; diff --git a/browser/extensions/followonsearch/test/browser/browser.ini b/browser/extensions/followonsearch/test/browser/browser.ini deleted file mode 100644 index 434191379e92..000000000000 --- a/browser/extensions/followonsearch/test/browser/browser.ini +++ /dev/null @@ -1,7 +0,0 @@ -[DEFAULT] - -[browser_followOnTelemetry.js] -support-files = - test.html - test2.html - testEngine.xml diff --git a/browser/extensions/followonsearch/test/browser/browser_followOnTelemetry.js b/browser/extensions/followonsearch/test/browser/browser_followOnTelemetry.js deleted file mode 100644 index f610f4d99c37..000000000000 --- a/browser/extensions/followonsearch/test/browser/browser_followOnTelemetry.js +++ /dev/null @@ -1,66 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ */ - -"use strict"; - -ChromeUtils.defineModuleGetter(this, "SearchTestUtils", - "resource://testing-common/SearchTestUtils.jsm"); - -SearchTestUtils.init(Assert, registerCleanupFunction); - -const BASE_URL = "http://mochi.test:8888/browser/browser/extensions/followonsearch/test/browser/"; -const TEST_ENGINE_BASENAME = "testEngine.xml"; - -add_task(async function test_followOnSearchTelemetry() { - let engine = await SearchTestUtils.promiseNewSearchEngine( - getRootDirectory(gTestPath) + TEST_ENGINE_BASENAME, - registerCleanupFunction); - let oldCurrentEngine = Services.search.currentEngine; - Services.search.currentEngine = engine; - - let histogram = Services.telemetry.getKeyedHistogramById("SEARCH_COUNTS"); - histogram.clear(); - - registerCleanupFunction(() => Services.search.currentEngine = oldCurrentEngine); - - await BrowserTestUtils.withNewTab({gBrowser}, async browser => { - // Open the initial search page via entering a search on the URL bar. - let loadPromise = BrowserTestUtils.waitForLocationChange(gBrowser, - `${BASE_URL}test.html?searchm=test&mt=TEST`); - - gURLBar.focus(); - EventUtils.sendString("test"); - EventUtils.sendKey("return"); - - await loadPromise; - - // Perform a follow-on search, selecting the form in the page. - loadPromise = BrowserTestUtils.waitForLocationChange(gBrowser, - `${BASE_URL}test2.html?mtfo=followonsearchtest&mt=TEST&m=test`); - - await ContentTask.spawn(browser, null, function() { - content.document.getElementById("submit").click(); - }); - - await loadPromise; - - let snapshot; - - // We have to wait for the snapshot to come in, as there's async functionality - // in the extension. - await TestUtils.waitForCondition(() => { - snapshot = histogram.snapshot(); - return "mochitest.follow-on:unknown:TEST" in snapshot; - }); - Assert.ok("mochitest.follow-on:unknown:TEST" in snapshot, - "Histogram should have an entry for the follow-on search."); - Assert.deepEqual(snapshot["mochitest.follow-on:unknown:TEST"], { - counts: [ 1, 0, 0 ], - histogram_type: 4, - max: 2, - min: 1, - ranges: [ 0, 1, 2 ], - sum: 1, - }, "Histogram should have the correct snapshot data"); - }); -}); diff --git a/browser/extensions/followonsearch/test/browser/test.html b/browser/extensions/followonsearch/test/browser/test.html deleted file mode 100644 index e71568e1511b..000000000000 --- a/browser/extensions/followonsearch/test/browser/test.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Follow-on Search Test - - -
- - - - -
- - diff --git a/browser/extensions/followonsearch/test/browser/test2.html b/browser/extensions/followonsearch/test/browser/test2.html deleted file mode 100644 index 1c0987b7aa2e..000000000000 --- a/browser/extensions/followonsearch/test/browser/test2.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - Follow-on Search Test Final Page - - - diff --git a/browser/extensions/followonsearch/test/browser/testEngine.xml b/browser/extensions/followonsearch/test/browser/testEngine.xml deleted file mode 100644 index b3c4e5ed1767..000000000000 --- a/browser/extensions/followonsearch/test/browser/testEngine.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - Mochitest - Mochitest Engine - UTF-8 - data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC - - - - -