Bug 1373718 - Update follow-on search add-on to 0.9.1 - fix double reporting and fix case sensitivity. r?past
--- a/browser/extensions/followonsearch/content/followonsearch-fs.js
+++ b/browser/extensions/followonsearch/content/followonsearch-fs.js
@@ -138,24 +138,31 @@ function log(message) {
// console.log(message);
}
// Hack to handle the most common reload case.
// If gLastSearch is the same as the current URL, ignore the search.
// This also prevents us from handling reloads with hashes twice
let gLastSearch = null;
+// Keep track of the original window we were loaded in
+// so we don't handle requests for other windows.
+let gOriginalWindow = null;
+
/**
* Since most codes are in the URL, we can handle them via
* a progress listener.
*/
var webProgressListener = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, Ci.nsISupportsWeakReference]),
onLocationChange(aWebProgress, aRequest, aLocation, aFlags)
{
+ if (aWebProgress.DOMWindow && (aWebProgress.DOMWindow != gOriginalWindow)) {
+ 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) ||
// Is the same as our last search (avoids reloads)
aLocation.spec == gLastSearch) {
@@ -226,19 +233,19 @@ function onPageLoad(event) {
var uri = doc.documentURIObject;
if (!(uri instanceof Ci.nsIStandardURL) ||
(!uri.schemeIs("http") && !uri.schemeIs("https")) ||
uri.host != "www.bing.com" ||
!doc.location.search ||
uri.spec == gLastSearch) {
return;
}
- var queries = new URLSearchParams(doc.location.search);
+ 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") {
+ 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");
gLastSearch = uri.spec;
}
}
@@ -258,16 +265,18 @@ function sendSaveTelemetryMsg(code, sap,
type,
});
}
addEventListener("DOMContentLoaded", onPageLoad, false);
docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebProgress)
.addProgressListener(webProgressListener, Ci.nsIWebProgress.NOTIFY_LOCATION);
+gOriginalWindow = content;
+
let gDisabled = false;
addMessageListener(kShutdownMsg, () => {
if (!gDisabled) {
removeEventListener("DOMContentLoaded", onPageLoad, false);
docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebProgress)
.removeProgressListener(webProgressListener);
gDisabled = true;
--- a/browser/extensions/followonsearch/install.rdf
+++ b/browser/extensions/followonsearch/install.rdf
@@ -2,17 +2,17 @@
<!-- 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/. -->
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>followonsearch@mozilla.com</em:id>
<em:name>Follow-on Search Telemetry</em:name>
- <em:version>0.9.0</em:version>
+ <em:version>0.9.1</em:version>
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>
<em:multiprocessCompatible>true</em:multiprocessCompatible>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>52.0</em:minVersion>
<em:maxVersion>59.*</em:maxVersion>