Backed out 4 changesets (bug 1868922, bug 1855375, bug 1874990) for causing xpcshell failures in /test_tab_quickwrite.js CLOSED TREE

Backed out changeset d558120aba19 (bug 1868922)
Backed out changeset e2c1399903d8 (bug 1855375)
Backed out changeset de119e6a8ced (bug 1874990)
Backed out changeset 3d1ef7c11154 (bug 1874990)
This commit is contained in:
Cristian Tuns 2024-01-18 12:07:55 -05:00
Родитель ac1fd45c39
Коммит 74c0e58b85
42 изменённых файлов: 83 добавлений и 1393 удалений

Просмотреть файл

@ -50,9 +50,9 @@ git = "https://github.com/mozilla-spidermonkey/jsparagus"
rev = "61f399c53a641ebd3077c1f39f054f6d396a633c"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5"]
[source."git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da"]
git = "https://github.com/mozilla/application-services"
rev = "63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
rev = "c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/audioipc?rev=6be424d75f1367e70f2f5ddcacd6d0237e81a6a9"]

25
Cargo.lock сгенерированный
Просмотреть файл

@ -1577,7 +1577,7 @@ dependencies = [
[[package]]
name = "error-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"error-support-macros",
"lazy_static",
@ -1589,7 +1589,7 @@ dependencies = [
[[package]]
name = "error-support-macros"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"proc-macro2",
"quote",
@ -2803,7 +2803,7 @@ dependencies = [
[[package]]
name = "interrupt-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"lazy_static",
"parking_lot",
@ -3980,7 +3980,7 @@ dependencies = [
[[package]]
name = "nss_build_common"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
[[package]]
name = "nsstring"
@ -4651,7 +4651,7 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "remote_settings"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"parking_lot",
"serde",
@ -5181,7 +5181,7 @@ dependencies = [
[[package]]
name = "sql-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"ffi-support",
"interrupt-support",
@ -5362,7 +5362,7 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "suggest"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"anyhow",
"chrono",
@ -5376,7 +5376,6 @@ dependencies = [
"sql-support",
"thiserror",
"uniffi",
"url",
]
[[package]]
@ -5409,7 +5408,7 @@ dependencies = [
[[package]]
name = "sync-guid"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"base64 0.21.3",
"rand",
@ -5420,7 +5419,7 @@ dependencies = [
[[package]]
name = "sync15"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"anyhow",
"error-support",
@ -5452,7 +5451,7 @@ dependencies = [
[[package]]
name = "tabs"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"anyhow",
"error-support",
@ -6094,7 +6093,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "viaduct"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"ffi-support",
"log",
@ -6240,7 +6239,7 @@ dependencies = [
[[package]]
name = "webext-storage"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=63a6260c14847c21c5a1fa3003efaf0114a3e4e5#63a6260c14847c21c5a1fa3003efaf0114a3e4e5"
source = "git+https://github.com/mozilla/application-services?rev=c1e935d9d1d68e2bee323a236e62165ab1bbb2da#c1e935d9d1d68e2bee323a236e62165ab1bbb2da"
dependencies = [
"anyhow",
"error-support",

Просмотреть файл

@ -202,13 +202,13 @@ warp = { git = "https://github.com/seanmonstar/warp", rev = "9d081461ae1167eb321
malloc_size_of_derive = { path = "xpcom/rust/malloc_size_of_derive" }
# application-services overrides to make updating them all simpler.
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "63a6260c14847c21c5a1fa3003efaf0114a3e4e5" }
sql-support = { git = "https://github.com/mozilla/application-services", rev = "63a6260c14847c21c5a1fa3003efaf0114a3e4e5" }
suggest = { git = "https://github.com/mozilla/application-services", rev = "63a6260c14847c21c5a1fa3003efaf0114a3e4e5" }
sync15 = { git = "https://github.com/mozilla/application-services", rev = "63a6260c14847c21c5a1fa3003efaf0114a3e4e5" }
tabs = { git = "https://github.com/mozilla/application-services", rev = "63a6260c14847c21c5a1fa3003efaf0114a3e4e5" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "63a6260c14847c21c5a1fa3003efaf0114a3e4e5" }
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "63a6260c14847c21c5a1fa3003efaf0114a3e4e5" }
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "c1e935d9d1d68e2bee323a236e62165ab1bbb2da" }
sql-support = { git = "https://github.com/mozilla/application-services", rev = "c1e935d9d1d68e2bee323a236e62165ab1bbb2da" }
suggest = { git = "https://github.com/mozilla/application-services", rev = "c1e935d9d1d68e2bee323a236e62165ab1bbb2da" }
sync15 = { git = "https://github.com/mozilla/application-services", rev = "c1e935d9d1d68e2bee323a236e62165ab1bbb2da" }
tabs = { git = "https://github.com/mozilla/application-services", rev = "c1e935d9d1d68e2bee323a236e62165ab1bbb2da" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "c1e935d9d1d68e2bee323a236e62165ab1bbb2da" }
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "c1e935d9d1d68e2bee323a236e62165ab1bbb2da" }
# Patch mio 0.6 to use winapi 0.3 and miow 0.3, getting rid of winapi 0.2.
# There is not going to be new version of mio 0.6, mio now being >= 0.7.11.

Просмотреть файл

@ -641,10 +641,6 @@ pref("browser.urlbar.suggest.addons", true);
// mdn suggestions are turned on.
pref("browser.urlbar.suggest.mdn", true);
// If `browser.urlbar.yelp.featureGate` is true, this controls whether
// Yelp suggestions are turned on.
pref("browser.urlbar.suggest.yelp", true);
// The minimum prefix length of addons keyword the user must type to trigger
// the suggestion. 0 means the min length should be taken from Nimbus.
pref("browser.urlbar.addons.minKeywordLength", 0);

Просмотреть файл

@ -29,7 +29,6 @@ const FEATURES = {
SuggestBackendRust:
"resource:///modules/urlbar/private/SuggestBackendRust.sys.mjs",
Weather: "resource:///modules/urlbar/private/Weather.sys.mjs",
YelpSuggestions: "resource:///modules/urlbar/private/YelpSuggestions.sys.mjs",
};
const TIMESTAMP_TEMPLATE = "%YYYYMMDDHH%";

Просмотреть файл

@ -299,13 +299,6 @@ const PREF_URLBAR_DEFAULTS = new Map([
// recentsearches are turned on.
["suggest.recentsearches", true],
// If `browser.urlbar.yelp.featureGate` is true, this controls whether
// Yelp suggestions are turned on.
["suggest.yelp", true],
// Feature gate pref for Yelp suggestions in the urlbar.
["yelp.featureGate", false],
// JSON'ed array of blocked quick suggest URL digests.
["quicksuggest.blockedDigests", ""],

Просмотреть файл

@ -141,12 +141,6 @@ firefox-suggest-mdn-bottom-text = { -mdn-brand-name }
# $keywordSubstringNotTyped (string) - The part of the suggestion keyword that the user did not yet type
firefox-suggest-pocket-bottom-text = { -pocket-brand-name } · Related to <strong>{ $keywordSubstringTyped }</strong>{ $keywordSubstringNotTyped }
## These strings are used for Yelp suggestions in the urlbar.
# This string is shown in Yelp suggestions and indicates the suggestion is for
# Yelp.
firefox-suggest-yelp-bottom-text = Yelp
## These strings are used in the preferences UI (about:preferences). Their names
## follow the naming conventions of other strings used in the preferences UI.

Просмотреть файл

@ -200,10 +200,6 @@ browser.urlbar.suggest.pocket (boolean, default: true)
If ``browser.urlbar.pocket.featureGate`` is true, this controls whether Pocket
suggestions are turned on. Otherwise they won't be shown.
browser.urlbar.suggest.yelp (boolean, default: true)
If ``browser.urlbar.yelp.featureGate`` is true, this controls whether Yelp
suggestions are turned on. Otherwise they won't be shown.
browser.urlbar.switchTabs.adoptIntoActiveWindow (boolean, default: false)
When using switch to tabs, if set to true this will move the tab into the
active window, instead of just switching to it.

Просмотреть файл

@ -69,7 +69,6 @@ EXTRA_JS_MODULES["urlbar/private"] += [
"private/SuggestBackendJs.sys.mjs",
"private/SuggestBackendRust.sys.mjs",
"private/Weather.sys.mjs",
"private/YelpSuggestions.sys.mjs",
]
TESTING_JS_MODULES += [

Просмотреть файл

@ -97,6 +97,8 @@ export class SuggestBackendRust extends BaseFeature {
return [];
}
searchString = searchString.toLocaleLowerCase();
// Build the list of Rust providers to query. Each provider is identified by
// an integer value defined on the `SuggestionProvider` object. Here we
// convert the Rust suggestion types of our registered features to their

Просмотреть файл

@ -1,59 +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/. */
import { BaseFeature } from "resource:///modules/urlbar/private/BaseFeature.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs",
UrlbarResult: "resource:///modules/UrlbarResult.sys.mjs",
UrlbarUtils: "resource:///modules/UrlbarUtils.sys.mjs",
});
/**
* A feature for Yelp suggestions.
*/
export class YelpSuggestions extends BaseFeature {
get shouldEnable() {
return (
lazy.UrlbarPrefs.get("yelpFeatureGate") &&
lazy.UrlbarPrefs.get("suggest.yelp")
);
}
get enablingPreferences() {
return ["suggest.yelp"];
}
get rustSuggestionTypes() {
return ["Yelp"];
}
getSuggestionTelemetryType(suggestion) {
return "yelp";
}
makeResult(queryContext, suggestion, searchString) {
return Object.assign(
new lazy.UrlbarResult(
lazy.UrlbarUtils.RESULT_TYPE.URL,
lazy.UrlbarUtils.RESULT_SOURCE.SEARCH,
...lazy.UrlbarResult.payloadAndSimpleHighlights(queryContext.tokens, {
// TODO: Should define Yelp icon here. Bug 1874624.
url: suggestion.url,
title: suggestion.title,
shouldShowUrl: true,
bottomTextL10n: { id: "firefox-suggest-yelp-bottom-text" },
})
),
{
isBestMatch: true,
suggestedIndex: 1,
isRichSuggestion: true,
richSuggestionIconSize: 24,
}
);
}
}

Просмотреть файл

@ -31,8 +31,6 @@ skip-if = ["os == 'linux' && bits == 64"] # Bug 1773830
["browser_quicksuggest_pocket.js"]
tags = "search-telemetry"
["browser_quicksuggest_yelp.js"]
["browser_telemetry_dynamicWikipedia.js"]
tags = "search-telemetry"

Просмотреть файл

@ -1,54 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test for Yelp suggestions.
const REMOTE_SETTINGS_RECORDS = [
{
type: "yelp-suggestions",
attachment: {
subjects: ["ramen"],
preModifiers: ["best"],
postModifiers: ["delivery"],
locationSigns: [{ keyword: "in", needLocation: true }],
},
},
];
add_setup(async function () {
Services.prefs.setBoolPref("browser.search.suggest.enabled", false);
await QuickSuggestTestUtils.ensureQuickSuggestInit({
remoteSettingsRecords: REMOTE_SETTINGS_RECORDS,
prefs: [
["quicksuggest.rustEnabled", true],
["suggest.quicksuggest.nonsponsored", true],
["suggest.yelp", true],
["yelp.featureGate", true],
],
});
});
add_task(async function basic() {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "RaMeN iN tOkYo",
});
Assert.equal(UrlbarTestUtils.getResultCount(window), 2);
const { result } = await UrlbarTestUtils.getDetailsOfResultAt(window, 1);
Assert.equal(
result.providerName,
UrlbarProviderQuickSuggest.name,
"The result should be from the expected provider"
);
Assert.equal(result.payload.provider, "Yelp");
Assert.equal(
result.payload.url,
"https://www.yelp.com/search?find_desc=RaMeN&find_loc=tOkYo"
);
Assert.equal(result.payload.title, "RaMeN iN tOkYo");
});

Просмотреть файл

@ -423,14 +423,6 @@ add_tasks_with_rust(async function remoteSettings() {
setUtmParams: false,
}),
},
{
input: "FoUrTh",
expected: makeExpectedResult({
suggestion: REMOTE_SETTINGS_RESULTS[0].attachment[3],
source: "remote-settings",
setUtmParams: false,
}),
},
];
// Disable Merino so we trigger only remote settings suggestions.

Просмотреть файл

@ -64,16 +64,6 @@ add_task(async function nonsponsoredDisabled() {
UrlbarPrefs.clear("suggest.quicksuggest.sponsored");
});
add_task(async function mixedCaseQuery() {
await check_results({
context: createContext("TeSt", {
providers: [UrlbarProviderQuickSuggest.name],
isPrivate: false,
}),
matches: [makeExpectedResult()],
});
});
function makeExpectedResult() {
return {
type: UrlbarUtils.RESULT_TYPE.URL,

Просмотреть файл

@ -177,19 +177,6 @@ add_task(async function nimbus() {
await QuickSuggestTestUtils.forceSync();
});
add_task(async function mixedCaseQuery() {
const suggestion = REMOTE_SETTINGS_DATA[0].attachment[1];
const keyword = "InPuT";
await check_results({
context: createContext(keyword, {
providers: [UrlbarProviderQuickSuggest.name],
isPrivate: false,
}),
matches: [makeExpectedResult({ searchString: keyword, suggestion })],
});
});
function makeExpectedResult({
searchString,
suggestion,

Просмотреть файл

@ -1,244 +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/. */
// Tests Yelp suggestions.
"use strict";
const REMOTE_SETTINGS_RECORDS = [
{
type: "yelp-suggestions",
attachment: {
subjects: ["ramen"],
preModifiers: ["best"],
postModifiers: ["delivery"],
locationSigns: [{ keyword: "in", needLocation: true }],
},
},
];
add_setup(async function () {
Services.prefs.setBoolPref("browser.search.suggest.enabled", false);
await QuickSuggestTestUtils.ensureQuickSuggestInit({
remoteSettingsRecords: REMOTE_SETTINGS_RECORDS,
prefs: [
["quicksuggest.rustEnabled", true],
["suggest.quicksuggest.nonsponsored", true],
["suggest.yelp", true],
["yelp.featureGate", true],
],
});
});
add_task(async function basic() {
const TEST_DATA = [
{
description: "Basic",
query: "best ramen delivery in tokyo",
expected: {
url: "https://www.yelp.com/search?find_desc=best+ramen+delivery&find_loc=tokyo",
title: "best ramen delivery in tokyo",
},
},
{
description: "With upper case",
query: "BeSt RaMeN dElIvErY iN tOkYo",
expected: {
url: "https://www.yelp.com/search?find_desc=BeSt+RaMeN+dElIvErY&find_loc=tOkYo",
title: "BeSt RaMeN dElIvErY iN tOkYo",
},
},
];
for (let { query, expected } of TEST_DATA) {
info(`Test for ${query}`);
await check_results({
context: createContext(query, {
providers: [UrlbarProviderQuickSuggest.name],
isPrivate: false,
}),
matches: expected ? [makeExpectedResult(expected)] : [],
});
}
});
add_task(async function telemetryType() {
Assert.equal(
QuickSuggest.getFeature("YelpSuggestions").getSuggestionTelemetryType({}),
"yelp",
"Telemetry type should be 'yelp'"
);
});
// When non-sponsored suggestions are disabled, Yelp suggestions should be
// disabled.
add_task(async function nonsponsoredDisabled() {
UrlbarPrefs.set("suggest.quicksuggest.sponsored", false);
// First make sure the suggestion is added when non-sponsored
// suggestions are enabled, if the rust is enabled.
await check_results({
context: createContext("ramen", {
providers: [UrlbarProviderQuickSuggest.name],
isPrivate: false,
}),
matches: [
makeExpectedResult({
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen",
}),
],
});
// Now disable the pref.
UrlbarPrefs.set("suggest.quicksuggest.nonsponsored", false);
await check_results({
context: createContext("ramen", {
providers: [UrlbarProviderQuickSuggest.name],
isPrivate: false,
}),
matches: [],
});
UrlbarPrefs.set("suggest.quicksuggest.nonsponsored", true);
UrlbarPrefs.clear("suggest.quicksuggest.sponsored");
await QuickSuggestTestUtils.forceSync();
});
// When Yelp-specific preferences are disabled, suggestions should not be
// added.
add_task(async function yelpSpecificPrefsDisabled() {
const prefs = ["suggest.yelp", "yelp.featureGate"];
for (const pref of prefs) {
// First make sure the suggestion is added, if the rust is enabled.
await check_results({
context: createContext("ramen", {
providers: [UrlbarProviderQuickSuggest.name],
isPrivate: false,
}),
matches: [
makeExpectedResult({
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen",
}),
],
});
// Now disable the pref.
UrlbarPrefs.set(pref, false);
await check_results({
context: createContext("ramen", {
providers: [UrlbarProviderQuickSuggest.name],
isPrivate: false,
}),
matches: [],
});
// Revert.
UrlbarPrefs.set(pref, true);
await QuickSuggestTestUtils.forceSync();
}
});
// Check wheather the Yelp suggestions will be shown by the setup of Nimbus
// variable.
add_task(async function nimbus() {
// Disable the fature gate.
UrlbarPrefs.set("yelp.featureGate", false);
await check_results({
context: createContext("ramem", {
providers: [UrlbarProviderQuickSuggest.name],
isPrivate: false,
}),
matches: [],
});
// Enable by Nimbus.
const cleanUpNimbusEnable = await UrlbarTestUtils.initNimbusFeature({
yelpFeatureGate: true,
});
await QuickSuggestTestUtils.forceSync();
await check_results({
context: createContext("ramen", {
providers: [UrlbarProviderQuickSuggest.name],
isPrivate: false,
}),
matches: [
makeExpectedResult({
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen",
}),
],
});
await cleanUpNimbusEnable();
// Enable locally.
UrlbarPrefs.set("yelp.featureGate", true);
await QuickSuggestTestUtils.forceSync();
// Disable by Nimbus.
const cleanUpNimbusDisable = await UrlbarTestUtils.initNimbusFeature({
yelpFeatureGate: false,
});
await check_results({
context: createContext("ramen", {
providers: [UrlbarProviderQuickSuggest.name],
isPrivate: false,
}),
matches: [],
});
await cleanUpNimbusDisable();
// Revert.
UrlbarPrefs.set("yelp.featureGate", true);
await QuickSuggestTestUtils.forceSync();
});
// The `Yelp` Rust provider should be passed to the Rust component when
// querying depending on whether Yelp suggestions are enabled.
add_task(async function rustProviders() {
await doRustProvidersTests({
searchString: "ramen",
tests: [
{
prefs: {
"suggest.yelp": true,
},
expectedUrls: ["https://www.yelp.com/search?find_desc=ramen"],
},
{
prefs: {
"suggest.yelp": false,
},
expectedUrls: [],
},
],
});
UrlbarPrefs.clear("suggest.yelp");
await QuickSuggestTestUtils.forceSync();
});
function makeExpectedResult(expected) {
return {
type: UrlbarUtils.RESULT_TYPE.URL,
source: UrlbarUtils.RESULT_SOURCE.SEARCH,
isBestMatch: true,
heuristic: false,
payload: {
source: "rust",
provider: "Yelp",
telemetryType: "yelp",
shouldShowUrl: true,
bottomTextL10n: { id: "firefox-suggest-yelp-bottom-text" },
url: expected.url,
title: expected.title,
displayUrl: expected.url
.replace(/^https:\/\/www[.]/, "")
.replace("%20", " "),
},
};
}

Просмотреть файл

@ -37,8 +37,6 @@ firefox-appdir = "browser"
["test_quicksuggest_topPicks.js"]
["test_quicksuggest_yelp.js"]
["test_rust_ingest.js"]
["test_suggestionsMap.js"]

Просмотреть файл

@ -179,7 +179,6 @@ add_task(async function test_tab_engine_skips_incoming_local_record() {
title: "title2",
urlHistory: ["http://bar.com/"],
icon: "",
inactive: false,
lastUsed: 3000,
},
]);

Просмотреть файл

@ -444,13 +444,6 @@ user-id = 3618
user-login = "dtolnay"
user-name = "David Tolnay"
[[publisher.qcms]]
version = "0.3.0"
when = "2024-01-09"
user-id = 5946
user-login = "jrmuizel"
user-name = "Jeff Muizelaar"
[[publisher.quote]]
version = "1.0.28"
when = "2023-05-25"
@ -1814,3 +1807,9 @@ criteria = "safe-to-deploy"
version = "1.4.0"
notes = "I have read over the macros, and audited the unsafe code."
aggregated-from = "https://raw.githubusercontent.com/mozilla/cargo-vet/main/supply-chain/audits.toml"
[[audits.mozilla.audits.qcms]]
who = "Jeff Muizelaar <jmuizelaar@mozilla.com>"
criteria = "safe-to-deploy"
version = "0.2.0"
aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml"

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"7e5e03ee92f01a28fa398d77167619e5a55c73db083cc27b74c4d63ab44db173","README.md":"8d7457893194e255b87e5a2667ee25c87bd470f5338d7078506f866a67a3fdbd","build.rs":"78780c5cccfe22c3ff4198624b9e188559c437c3e6fa1c8bb66548eee6aa66bf","src/db.rs":"6d39e96bcdaa2b01dc662b3ed17b3a022246534b919b13be637e4646c3b9c1dd","src/error.rs":"f47763a1a5d228b446eb8f718433e49fdb1c7b304de1255891215144dddd7a43","src/keyword.rs":"988d0ab021c0df19cfd3c519df7d37f606bf984cd14d0efca4e5a7aff88344dd","src/lib.rs":"95ac0da8585ddfe712884e05ae53fd5fdf79564675a1070222e4a310a79959f4","src/pocket.rs":"c4dda43390d1c39dc795933596b3c1e4e282932cac6c69da53c6e05d39e9ef29","src/provider.rs":"8cecefb01d3c09c164d7334647e586c5407e14d0ee7ef99eea6e5095ec59586c","src/rs.rs":"e27ba1e8e6f5b470f1df8bef7f2a7d7edd8ff2c0c0aedead86206fb3019a5f97","src/schema.rs":"3135d28652e3f0df6670a3afa3bdf03d95039383720f1f0d77523c0f4faf1797","src/store.rs":"0d06ef245440028f7f25e7823846947dd9ef64a1ad60b91cc21b44885c91b50b","src/suggest.udl":"e129cc04665a8484572c57c87b4a1713a7600254bf4110e06a5fe0d4eb746bb5","src/suggestion.rs":"dfe7c02e11ea9a01d3fdd71eb2c83b1c1d1b830c34f76829a91a01cda44c38b8","src/yelp.rs":"3e3868873643feddfa99d360f6547aab2a9d7983929b90e7911559d685bff33f","uniffi.toml":"f26317442ddb5b3281245bef6e60ffcb78bb95d29fe4a351a56dbb88d4ec8aab"},"package":null}
{"files":{"Cargo.toml":"14ad8d0442d1279484acd53b7fc9a7779325f7733902bb77c1fc08b5f5b52339","README.md":"8d7457893194e255b87e5a2667ee25c87bd470f5338d7078506f866a67a3fdbd","build.rs":"78780c5cccfe22c3ff4198624b9e188559c437c3e6fa1c8bb66548eee6aa66bf","src/db.rs":"60aaceae91013aac3d6420773eceb8eaa59109509bcba1d9661200bd6ab690ff","src/error.rs":"f47763a1a5d228b446eb8f718433e49fdb1c7b304de1255891215144dddd7a43","src/keyword.rs":"988d0ab021c0df19cfd3c519df7d37f606bf984cd14d0efca4e5a7aff88344dd","src/lib.rs":"c6bb8d94cf361482c5ebc182c4c853b72ed4eaad3220a7da9be5c7bd9aa08509","src/pocket.rs":"c4dda43390d1c39dc795933596b3c1e4e282932cac6c69da53c6e05d39e9ef29","src/provider.rs":"23733f87d3fa8d5574f9d12cb1c2762f168c4cd76118d2e27aae905d994ad767","src/rs.rs":"e39c79e7f1e5c369788fa3a2f61b327befe97fedd0cd3a77f0270b34ed01cab0","src/schema.rs":"4b1e70a4fdcda972bf0935b9c4b6fd59c83c5c85c41d7ff219b50252ac0d9376","src/store.rs":"8bc28d7ef523b043cf9f82fd074ea7f13f7de64e6634868d0e750297f617431b","src/suggest.udl":"653bb92b9f13c5800bd54fc2e11600bae9fda0ea09f072705bc039f33df22dd4","src/suggestion.rs":"4832bb3e66a5a647b3f0b935ff98cd9be585a889224cea9a775c51113b83d9c6","uniffi.toml":"f26317442ddb5b3281245bef6e60ffcb78bb95d29fe4a351a56dbb88d4ec8aab"},"package":null}

4
third_party/rust/suggest/Cargo.toml поставляемый
Просмотреть файл

@ -50,10 +50,6 @@ features = ["derive"]
[dependencies.sql-support]
path = "../support/sql"
[dependencies.url]
version = "2.1"
features = ["serde"]
[dev-dependencies]
expect-test = "1.4"
hex = "0.4"

21
third_party/rust/suggest/src/db.rs поставляемый
Просмотреть файл

@ -115,7 +115,7 @@ impl SuggestDb {
/// reference (`&mut self`).
pub(crate) struct SuggestDao<'a> {
pub conn: &'a Connection,
pub scope: SqlInterruptScope,
scope: SqlInterruptScope,
}
impl<'a> SuggestDao<'a> {
@ -125,10 +125,6 @@ impl<'a> SuggestDao<'a> {
/// Fetches suggestions that match the given query from the database.
pub fn fetch_suggestions(&self, query: &SuggestionQuery) -> Result<Vec<Suggestion>> {
if let Some(suggestion) = self.fetch_yelp_suggestion(query)? {
return Ok(vec![suggestion]);
}
let keyword_lowercased = &query.keyword.to_lowercase();
let (keyword_prefix, keyword_suffix) = split_keyword(keyword_lowercased);
let suggestions_limit = query.limit.unwrap_or(-1);
@ -298,8 +294,7 @@ impl<'a> SuggestDao<'a> {
} else {
Ok(None)
}
},
_ => Ok(None),
}
}
}
)?.flat_map(Result::transpose).collect::<Result<_>>()?;
@ -622,18 +617,6 @@ impl<'a> SuggestDao<'a> {
"DELETE FROM suggestions WHERE record_id = :record_id",
named_params! { ":record_id": record_id.as_str() },
)?;
self.conn.execute_cached(
"DELETE FROM yelp_subjects WHERE record_id = :record_id",
named_params! { ":record_id": record_id.as_str() },
)?;
self.conn.execute_cached(
"DELETE FROM yelp_modifiers WHERE record_id = :record_id",
named_params! { ":record_id": record_id.as_str() },
)?;
self.conn.execute_cached(
"DELETE FROM yelp_location_signs WHERE record_id = :record_id",
named_params! { ":record_id": record_id.as_str() },
)?;
Ok(())
}

1
third_party/rust/suggest/src/lib.rs поставляемый
Просмотреть файл

@ -13,7 +13,6 @@ mod rs;
mod schema;
mod store;
mod suggestion;
mod yelp;
pub use error::SuggestApiError;
pub use provider::SuggestionProvider;

2
third_party/rust/suggest/src/provider.rs поставляемый
Просмотреть файл

@ -16,7 +16,6 @@ pub enum SuggestionProvider {
Wikipedia = 2,
Amo = 3,
Pocket = 4,
Yelp = 5,
}
impl FromSql for SuggestionProvider {
@ -37,7 +36,6 @@ impl SuggestionProvider {
2 => Some(SuggestionProvider::Wikipedia),
3 => Some(SuggestionProvider::Amo),
4 => Some(SuggestionProvider::Pocket),
5 => Some(SuggestionProvider::Yelp),
_ => None,
}
}

20
third_party/rust/suggest/src/rs.rs поставляемый
Просмотреть файл

@ -90,8 +90,6 @@ pub(crate) enum SuggestRecord {
Amo,
#[serde(rename = "pocket-suggestions")]
Pocket,
#[serde(rename = "yelp-suggestions")]
Yelp,
}
/// Represents either a single value, or a list of values. This is used to
@ -268,21 +266,3 @@ pub(crate) struct DownloadedPocketSuggestion {
pub high_confidence_keywords: Vec<String>,
pub score: f64,
}
/// A location sign for Yelp to ingest from a Yelp Attachment
#[derive(Clone, Debug, Deserialize)]
pub(crate) struct DownloadedYelpLocationSign {
pub keyword: String,
#[serde(rename = "needLocation")]
pub need_location: bool,
}
/// A Yelp suggestion to ingest from a Yelp Attachment
#[derive(Clone, Debug, Deserialize)]
pub(crate) struct DownloadedYelpSuggestion {
pub subjects: Vec<String>,
#[serde(rename = "preModifiers")]
pub pre_modifiers: Vec<String>,
#[serde(rename = "postModifiers")]
pub post_modifiers: Vec<String>,
#[serde(rename = "locationSigns")]
pub location_signs: Vec<DownloadedYelpLocationSign>,
}

22
third_party/rust/suggest/src/schema.rs поставляемый
Просмотреть файл

@ -6,7 +6,7 @@
use rusqlite::{Connection, Transaction};
use sql_support::open_database::{self, ConnectionInitializer};
pub const VERSION: u32 = 10;
pub const VERSION: u32 = 9;
pub const SQL: &str = "
CREATE TABLE meta(
@ -78,24 +78,6 @@ pub const SQL: &str = "
id TEXT PRIMARY KEY,
data BLOB NOT NULL
) WITHOUT ROWID;
CREATE TABLE yelp_subjects(
keyword TEXT PRIMARY KEY,
record_id TEXT NOT NULL
) WITHOUT ROWID;
CREATE TABLE yelp_modifiers(
type INTEGER NOT NULL,
keyword TEXT NOT NULL,
record_id TEXT NOT NULL,
PRIMARY KEY (type, keyword)
) WITHOUT ROWID;
CREATE TABLE yelp_location_signs(
keyword TEXT PRIMARY KEY,
need_location INTEGER NOT NULL,
record_id TEXT NOT NULL
) WITHOUT ROWID;
";
/// Initializes an SQLite connection to the Suggest database, performing
@ -126,7 +108,7 @@ impl ConnectionInitializer for SuggestConnectionInitializer {
fn upgrade_from(&self, _db: &Transaction<'_>, version: u32) -> open_database::Result<()> {
match version {
1..=9 => {
1..=8 => {
// These schema versions were used during development, and never
// shipped in any applications. Treat these databases as
// corrupt, so that they'll be replaced.

384
third_party/rust/suggest/src/store.rs поставляемый
Просмотреть файл

@ -282,7 +282,6 @@ where
})?;
continue;
};
match fields {
SuggestRecord::AmpWikipedia => {
self.ingest_suggestions_from_record(
@ -332,16 +331,6 @@ where
},
)?;
}
SuggestRecord::Yelp => {
self.ingest_suggestions_from_record(
writer,
record,
|dao, record_id, suggestions| match suggestions.first() {
Some(suggestion) => dao.insert_yelp_suggestions(record_id, suggestion),
None => Ok(()),
},
)?;
}
}
}
Ok(())
@ -1715,17 +1704,6 @@ mod tests {
"hash": "",
"size": 0,
},
}, {
"id": "data-4",
"type": "yelp-suggestions",
"last_modified": 15,
"attachment": {
"filename": "data-4.json",
"mimetype": "application/json",
"location": "data-4.json",
"hash": "",
"size": 0,
},
}, {
"id": "icon-2",
"type": "icon",
@ -1835,20 +1813,6 @@ mod tests {
},
]),
)?
.with_data(
"data-4.json",
json!({
"subjects": ["ramen", "spicy ramen", "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Z"],
"preModifiers": ["best", "super best", "same_modifier"],
"postModifiers": ["delivery", "super delivery", "same_modifier"],
"locationSigns": [
{ "keyword": "in", "needLocation": true },
{ "keyword": "near", "needLocation": true },
{ "keyword": "near by", "needLocation": false },
{ "keyword": "near me", "needLocation": false },
]
}),
)?
.with_icon("icon-2.png", "i-am-an-icon".as_bytes().into())
.with_icon("icon-3.png", "also-an-icon".as_bytes().into());
@ -1866,7 +1830,6 @@ mod tests {
SuggestionProvider::Wikipedia,
SuggestionProvider::Amo,
SuggestionProvider::Pocket,
SuggestionProvider::Yelp,
],
limit: None,
},
@ -1883,7 +1846,6 @@ mod tests {
SuggestionProvider::Wikipedia,
SuggestionProvider::Amo,
SuggestionProvider::Pocket,
SuggestionProvider::Yelp,
],
limit: None,
},
@ -2431,340 +2393,6 @@ mod tests {
[]
"#]],
),
(
"keyword = `best spicy ramen delivery in tokyo`; Yelp only",
SuggestionQuery {
keyword: "best spicy ramen delivery in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=best+spicy+ramen+delivery&find_loc=tokyo",
title: "best spicy ramen delivery in tokyo",
},
]
"#]],
),
(
"keyword = `BeSt SpIcY rAmEn DeLiVeRy In ToKyO`; Yelp only",
SuggestionQuery {
keyword: "BeSt SpIcY rAmEn DeLiVeRy In ToKyO".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=BeSt+SpIcY+rAmEn+DeLiVeRy&find_loc=ToKyO",
title: "BeSt SpIcY rAmEn DeLiVeRy In ToKyO",
},
]
"#]],
),
(
"keyword = `best ramen delivery in tokyo`; Yelp only",
SuggestionQuery {
keyword: "best ramen delivery in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=best+ramen+delivery&find_loc=tokyo",
title: "best ramen delivery in tokyo",
},
]
"#]],
),
(
"keyword = `best invalid_ramen delivery in tokyo`; Yelp only",
SuggestionQuery {
keyword: "best invalid_ramen delivery in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[]
"#]],
),
(
"keyword = `best delivery in tokyo`; Yelp only",
SuggestionQuery {
keyword: "best delivery in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[]
"#]],
),
(
"keyword = `super best ramen delivery in tokyo`; Yelp only",
SuggestionQuery {
keyword: "super best ramen delivery in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=super+best+ramen+delivery&find_loc=tokyo",
title: "super best ramen delivery in tokyo",
},
]
"#]],
),
(
"keyword = `invalid_best ramen delivery in tokyo`; Yelp only",
SuggestionQuery {
keyword: "invalid_best ramen delivery in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[]
"#]],
),
(
"keyword = `ramen delivery in tokyo`; Yelp only",
SuggestionQuery {
keyword: "ramen delivery in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen+delivery&find_loc=tokyo",
title: "ramen delivery in tokyo",
},
]
"#]],
),
(
"keyword = `ramen super delivery in tokyo`; Yelp only",
SuggestionQuery {
keyword: "ramen super delivery in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen+super+delivery&find_loc=tokyo",
title: "ramen super delivery in tokyo",
},
]
"#]],
),
(
"keyword = `ramen invalid_delivery in tokyo`; Yelp only",
SuggestionQuery {
keyword: "ramen invalid_delivery in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[]
"#]],
),
(
"keyword = `ramen in tokyo`; Yelp only",
SuggestionQuery {
keyword: "ramen in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen&find_loc=tokyo",
title: "ramen in tokyo",
},
]
"#]],
),
(
"keyword = `ramen near tokyo`; Yelp only",
SuggestionQuery {
keyword: "ramen near tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen&find_loc=tokyo",
title: "ramen near tokyo",
},
]
"#]],
),
(
"keyword = `ramen invalid_in tokyo`; Yelp only",
SuggestionQuery {
keyword: "ramen invalid_in tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[]
"#]],
),
(
"keyword = `ramen in San Francisco`; Yelp only",
SuggestionQuery {
keyword: "ramen in San Francisco".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen&find_loc=San+Francisco",
title: "ramen in San Francisco",
},
]
"#]],
),
(
"keyword = `ramen in`; Yelp only",
SuggestionQuery {
keyword: "ramen in".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen in",
},
]
"#]],
),
(
"keyword = `ramen near by`; Yelp only",
SuggestionQuery {
keyword: "ramen near by".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen+near+by",
title: "ramen near by",
},
]
"#]],
),
(
"keyword = `ramen near me`; Yelp only",
SuggestionQuery {
keyword: "ramen near me".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen+near+me",
title: "ramen near me",
},
]
"#]],
),
(
"keyword = `ramen near by tokyo`; Yelp only",
SuggestionQuery {
keyword: "ramen near by tokyo".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[]
"#]],
),
(
"keyword = `ramen`; Yelp only",
SuggestionQuery {
keyword: "ramen".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=ramen",
title: "ramen",
},
]
"#]],
),
(
"keyword = maximum chars; Yelp only",
SuggestionQuery {
keyword: "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[
Yelp {
url: "https://www.yelp.com/search?find_desc=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
title: "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
},
]
"#]],
),
(
"keyword = over chars; Yelp only",
SuggestionQuery {
keyword: "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789Z".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[]
"#]],
),
(
"keyword = `best delivery`; Yelp only",
SuggestionQuery {
keyword: "best delivery".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[]
"#]],
),
(
"keyword = `same_modifier same_modifier`; Yelp only",
SuggestionQuery {
keyword: "same_modifier same_modifier".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[]
"#]],
),
(
"keyword = `same_modifier `; Yelp only",
SuggestionQuery {
keyword: "same_modifier ".into(),
providers: vec![SuggestionProvider::Yelp],
limit: None,
},
expect![[r#"
[]
"#]],
),
];
for (what, query, expect) in table {
expect.assert_debug_eq(
@ -2855,10 +2483,10 @@ mod tests {
UnparsableRecords(
{
"clippy-2": UnparsableRecord {
schema_version: 10,
schema_version: 9,
},
"fancy-new-suggestions-1": UnparsableRecord {
schema_version: 10,
schema_version: 9,
},
},
),
@ -2923,10 +2551,10 @@ mod tests {
UnparsableRecords(
{
"clippy-2": UnparsableRecord {
schema_version: 10,
schema_version: 9,
},
"fancy-new-suggestions-1": UnparsableRecord {
schema_version: 10,
schema_version: 9,
},
},
),
@ -3029,10 +2657,10 @@ mod tests {
UnparsableRecords(
{
"clippy-2": UnparsableRecord {
schema_version: 10,
schema_version: 9,
},
"fancy-new-suggestions-1": UnparsableRecord {
schema_version: 10,
schema_version: 9,
},
},
),

5
third_party/rust/suggest/src/suggest.udl поставляемый
Просмотреть файл

@ -22,7 +22,6 @@ enum SuggestionProvider {
"Pocket",
"Wikipedia",
"Amo",
"Yelp"
};
[Enum]
@ -62,10 +61,6 @@ interface Suggestion {
string guid,
f64 score
);
Yelp(
string url,
string title
);
};
dictionary SuggestionQuery {

4
third_party/rust/suggest/src/suggestion.rs поставляемый
Просмотреть файл

@ -52,10 +52,6 @@ pub enum Suggestion {
guid: String,
score: f64,
},
Yelp {
url: String,
title: String,
},
}
/// Replaces all template parameters in a "raw" sponsored suggestion URL,

362
third_party/rust/suggest/src/yelp.rs поставляемый
Просмотреть файл

@ -1,362 +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/.
*/
use rusqlite::types::ToSqlOutput;
use rusqlite::{named_params, Result as RusqliteResult, ToSql};
use sql_support::ConnExt;
use url::form_urlencoded;
use crate::{
db::SuggestDao,
provider::SuggestionProvider,
rs::{DownloadedYelpSuggestion, SuggestRecordId},
suggestion::Suggestion,
Result, SuggestionQuery,
};
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
#[repr(u8)]
enum Modifier {
PreModifier = 0,
PostModifier = 1,
}
impl ToSql for Modifier {
fn to_sql(&self) -> RusqliteResult<ToSqlOutput<'_>> {
Ok(ToSqlOutput::from(*self as u8))
}
}
/// This module assumes like following query.
/// "Pre-modifier? Subject Post-modifier? (Location-modifier | Location-sign Location?)?"
/// For example, the query below is valid.
/// "Best(Pre-modifier) Ramen(Subject) Delivery(Post-modifier) In(Location-sign) Tokyo(Location)"
/// Also, as everything except Subject is optional, "Ramen" will be also valid query.
/// However, "Best Best Ramen" and "Ramen Best" is out of the above appearance order rule,
/// parsing will be failed. Also, every words except Location needs to be registered in DB.
/// Please refer to the query test in store.rs for all of combination.
/// Currently, the maximum query length is determined while refering to having word lengths in DB
/// and location names.
/// max subject: 50 + pre-modifier: 10 + post-modifier: 10 + location-sign: 7 + location: 50 = 127 = 150.
const MAX_QUERY_LENGTH: usize = 150;
/// The max number of words consisting the modifier. To improve the SQL performance by matching with
/// "keyword=:modifier" (please see is_modifier()), define this how many words we should check.
const MAX_MODIFIER_WORDS_NUMBER: usize = 2;
impl<'a> SuggestDao<'a> {
/// Inserts the suggestions for Yelp attachment into the database.
pub fn insert_yelp_suggestions(
&mut self,
record_id: &SuggestRecordId,
suggestion: &DownloadedYelpSuggestion,
) -> Result<()> {
for keyword in &suggestion.subjects {
self.scope.err_if_interrupted()?;
self.conn.execute_cached(
"INSERT INTO yelp_subjects(record_id, keyword) VALUES(:record_id, :keyword)",
named_params! {
":record_id": record_id.as_str(),
":keyword": keyword,
},
)?;
}
for keyword in &suggestion.pre_modifiers {
self.scope.err_if_interrupted()?;
self.conn.execute_cached(
"INSERT INTO yelp_modifiers(record_id, type, keyword) VALUES(:record_id, :type, :keyword)",
named_params! {
":record_id": record_id.as_str(),
":type": Modifier::PreModifier,
":keyword": keyword,
},
)?;
}
for keyword in &suggestion.post_modifiers {
self.scope.err_if_interrupted()?;
self.conn.execute_cached(
"INSERT INTO yelp_modifiers(record_id, type, keyword) VALUES(:record_id, :type, :keyword)",
named_params! {
":record_id": record_id.as_str(),
":type": Modifier::PostModifier,
":keyword": keyword,
},
)?;
}
for sign in &suggestion.location_signs {
self.scope.err_if_interrupted()?;
self.conn.execute_cached(
"INSERT INTO yelp_location_signs(record_id, keyword, need_location) VALUES(:record_id, :keyword, :need_location)",
named_params! {
":record_id": record_id.as_str(),
":keyword": sign.keyword,
":need_location": sign.need_location,
},
)?;
}
Ok(())
}
/// Fetch Yelp suggestion from given user's query.
pub fn fetch_yelp_suggestion(&self, query: &SuggestionQuery) -> Result<Option<Suggestion>> {
if !query.providers.contains(&SuggestionProvider::Yelp) {
return Ok(None);
}
if query.keyword.len() > MAX_QUERY_LENGTH {
return Ok(None);
}
let query_string = &query.keyword.trim();
if !query_string.contains(' ') {
if !self.is_subject(query_string)? {
return Ok(None);
}
let builder = SuggestionBuilder {
query,
subject: query_string,
pre_modifier: None,
post_modifier: None,
location_sign: None,
location: None,
need_location: false,
};
return Ok(Some(builder.into()));
}
// Find the location sign and the location.
let (query_without_location, location_sign, location, need_location) =
self.find_location(query_string)?;
if let (Some(_), false) = (&location, need_location) {
// The location sign does not need the specific location, but user is setting something.
return Ok(None);
}
if query_without_location.is_empty() {
// No remained query.
return Ok(None);
}
// Find the modifiers.
let (subject_candidate, pre_modifier, post_modifier) =
self.find_modifiers(&query_without_location)?;
if !self.is_subject(&subject_candidate)? {
return Ok(None);
}
let builder = SuggestionBuilder {
query,
subject: &subject_candidate,
pre_modifier,
post_modifier,
location_sign,
location,
need_location,
};
Ok(Some(builder.into()))
}
/// Find the location information from the given query string.
/// It returns the location tuple as follows:
/// (
/// String: Query string that is removed found location information.
/// Option<String>: Location sign found in yelp_location_signs table. If not found, returns None.
/// Option<String>: Specific location name after location sign. If not found, returns None.
/// bool: Reflects need_location field in the table.
/// )
fn find_location(&self, query: &str) -> Result<(String, Option<String>, Option<String>, bool)> {
let query_with_spaces = format!(" {} ", query);
let mut results: Vec<(usize, usize, i8)> = self.conn.query_rows_and_then_cached(
"
SELECT
INSTR(:query, ' ' || keyword || ' ') AS sign_index,
LENGTH(keyword) AS sign_length,
need_location
FROM yelp_location_signs
WHERE
sign_index > 0
ORDER BY
sign_length DESC
LIMIT 1
",
named_params! {
":query": &query_with_spaces.to_lowercase(),
},
|row| -> Result<_> {
Ok((
row.get::<_, usize>("sign_index")?,
row.get::<_, usize>("sign_length")?,
row.get::<_, i8>("need_location")?,
))
},
)?;
let (sign_index, sign_length, need_location) = if let Some(res) = results.pop() {
res
} else {
return Ok((query.trim().to_string(), None, None, false));
};
let pre_location = query_with_spaces
.get(..sign_index)
.map(str::trim)
.map(str::to_string)
.unwrap_or_default();
let location_sign = query_with_spaces
.get(sign_index..sign_index + sign_length)
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string);
let location = query_with_spaces
.get(sign_index + sign_length..)
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string);
Ok((pre_location, location_sign, location, need_location == 1))
}
/// Find the pre/post modifier from the given query string.
/// It returns the modifiers tuple as follows:
/// (
/// String: Query string that is removed found the modifiers.
/// Option<String>: Pre-modifier found in the yelp_modifiers table. If not found, returns None.
/// Option<String>: Post-modifier found in the yelp_modifiers table. If not found, returns None.
/// )
fn find_modifiers(&self, query: &str) -> Result<(String, Option<String>, Option<String>)> {
if !query.contains(' ') {
return Ok((query.to_string(), None, None));
}
let words: Vec<_> = query.split_whitespace().collect();
let mut pre_modifier = None;
for n in (1..=MAX_MODIFIER_WORDS_NUMBER).rev() {
let mut candidate_chunks = words.chunks(n);
let candidate = candidate_chunks.next().unwrap_or(&[""]).join(" ");
if self.is_modifier(&candidate, Modifier::PreModifier)? {
pre_modifier = Some(candidate);
break;
}
}
let mut post_modifier = None;
for n in (1..=MAX_MODIFIER_WORDS_NUMBER).rev() {
let mut candidate_chunks = words.rchunks(n);
let candidate = candidate_chunks.next().unwrap_or(&[""]).join(" ");
if self.is_modifier(&candidate, Modifier::PostModifier)? {
post_modifier = Some(candidate);
break;
}
}
let mut subject_candidate = query;
if let Some(ref modifier) = pre_modifier {
subject_candidate = &subject_candidate[modifier.len()..];
}
if let Some(ref modifier) = post_modifier {
subject_candidate = &subject_candidate[..subject_candidate.len() - modifier.len()];
}
Ok((
subject_candidate.trim().to_string(),
pre_modifier,
post_modifier,
))
}
fn is_modifier(&self, word: &str, modifier_type: Modifier) -> Result<bool> {
let result = self.conn.query_row_and_then_cachable(
"
SELECT EXISTS (
SELECT 1 FROM yelp_modifiers WHERE type = :type AND keyword = :word LIMIT 1
)
",
named_params! {
":type": modifier_type,
":word": word.to_lowercase(),
},
|row| row.get::<_, bool>(0),
true,
)?;
Ok(result)
}
fn is_subject(&self, word: &str) -> Result<bool> {
if word.is_empty() {
return Ok(false);
}
let result = self.conn.query_row_and_then_cachable(
"
SELECT EXISTS (
SELECT 1 FROM yelp_subjects WHERE keyword = :word LIMIT 1
)
",
named_params! {
":word": word.to_lowercase(),
},
|row| row.get::<_, bool>(0),
true,
)?;
Ok(result)
}
}
struct SuggestionBuilder<'a> {
query: &'a SuggestionQuery,
subject: &'a str,
pre_modifier: Option<String>,
post_modifier: Option<String>,
location_sign: Option<String>,
location: Option<String>,
need_location: bool,
}
impl<'a> From<SuggestionBuilder<'a>> for Suggestion {
fn from(builder: SuggestionBuilder<'a>) -> Suggestion {
// This location sign such the 'near by' needs to add as a description parameter.
let location_modifier = if !builder.need_location {
builder.location_sign
} else {
None
};
let description = [
builder.pre_modifier,
Some(builder.subject.to_string()),
builder.post_modifier,
location_modifier,
]
.iter()
.flatten()
.map(|s| s.as_str())
.collect::<Vec<_>>()
.join(" ");
// https://www.yelp.com/search?find_desc={description}&find_loc={location}
let mut url = String::from("https://www.yelp.com/search?");
let mut parameters = form_urlencoded::Serializer::new(String::new());
parameters.append_pair("find_desc", &description);
if let (Some(location), true) = (&builder.location, builder.need_location) {
parameters.append_pair("find_loc", location);
}
url.push_str(&parameters.finish());
Suggestion::Yelp {
url,
// Use users query as title as it is.
title: builder.query.keyword.clone(),
}
}
}

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"f1c393a0b8b62e476bdde3e01e69087ec1a25597ec1c4a2d996d4f5514a39768","README.md":"6d4ff5b079ac5340d18fa127f583e7ad793c5a2328b8ecd12c3fc723939804f2","build.rs":"aa971160d67ce8626b26e15c04c34b730f594c45c817aae34cfc9f3ea14ae284","src/bso/content.rs":"92935258745bdf0c3915a555cb6884a7fa69faa1290ec2c1815f6e2f3c0f0562","src/bso/crypto.rs":"27602dcccb37d3a55620ee4e16b705da455d49af575de115c7c79c0178eb1d6d","src/bso/mod.rs":"09e723dc7e99295ecafdcadffaf604d66ea27cf2b7f1fd9ab3cac4f4698ff6a7","src/bso/test_utils.rs":"4ec5a2df5e1c0ec14dc770681e959bdcef6ef04f6fde435999197f46a8ae4831","src/client/coll_state.rs":"13e6ef55273baf5536acc369be522e34a803a32cabf19cce43e426aea9b6223e","src/client/coll_update.rs":"dac04a90c29dd969f8b4250414609c9b6d61daf2dfa4ae77d1c4a165ba970b05","src/client/collection_keys.rs":"c27b2277a3a52033b58ab01490fc2ea7007494195dd5e6dc2c6931a4ca96795a","src/client/mod.rs":"8f588d4a035cf79d96f2500f06d5651c1a7c566127c456ffa5429811ddce3fd6","src/client/request.rs":"8841524e37d8195867bdf6ba98c75f610cf47a4644adeebd6372cc6713f2260a","src/client/state.rs":"4e31193ef2471c1dfabf1c6a391bcb95e14ddb45855786a4194ff187d5c9347c","src/client/status.rs":"f445a8765dac9789444e23b5145148413407bb1d18a15ef56682243997f591bf","src/client/storage_client.rs":"8de72d4ba3ca4f68c8e1898466de83a2b543545a18679800cb4f7fbda2dc3183","src/client/sync.rs":"b29abb512ec9d163f7883b71f78c9202802dcb17cad1fc5dc08087fb0bb66704","src/client/sync_multiple.rs":"6e92571132f89744b553190c596be8aff9b2d031d8f79d82c94cdf78b1683f4a","src/client/token.rs":"b268759d31e0fe17e0e2a428694cd9a317fcfbdd52f023d5d8c7cc6f00f1a102","src/client/util.rs":"71cc70ee41f821f53078675e636e9fad9c6046fa1a989e37f5487e340a2277d6","src/client_types.rs":"3c3cac1540b92482f43660d9e43bdde8481c4cc1a98253a68c80e791231f5976","src/clients_engine/engine.rs":"9e11b47be81fc63214f31879af74075674aa50a8f8989afe20fefa7990fa99b9","src/clients_engine/mod.rs":"461729e6f89b66b2cbd89b041a03d4d6a8ba582284ed4f3015cb13e1a0c6da97","src/clients_engine/record.rs":"b0d84bf420743d7638a45e4836633a45e50257d5548fe7ecd04bff4d724439b8","src/clients_engine/ser.rs":"ef12daeb11faf618fe3cafe91f20a031fe5bb6751369b6ee5aee03f196efe88c","src/device_type.rs":"dc2d4296d25e31471c8e68488f1043ff239b902036cd6aea8a686cf79b4ed335","src/enc_payload.rs":"aa3eea7df49b24cd59831680a47c417b73a3e36e6b0f3f4baf14ca66bd68be6b","src/engine/bridged_engine.rs":"f70f1bfce6e0c04b0c72ec9cbfbb12c82d4009a23fb9768792107d41b2865a4f","src/engine/mod.rs":"90f1f9760f5f712a337aebb04e59c736e4b6fbd89d6a188d969210c7f3f321ae","src/engine/request.rs":"5923025fb9550178339f880a1bf8526d8e853e7a0b2bce6d9d687cc808ac0085","src/engine/sync_engine.rs":"531b35d72ce9e04c3e543c0468c1e450fba2c0dc3d33d68d9b1c0a5c1ad7dd34","src/error.rs":"a45cfe02e6301f473c34678b694943c1a04308b8c292c6e0448bf495194c3b5e","src/key_bundle.rs":"abd0781f3be8c8e7c691f18bb71f3433b633803c48da9794e15ac6301ed60d6c","src/lib.rs":"f59f8817978d943518dfa03ab31fc0f6b1fc72ee9943a97aef1537e2769649f5","src/record_types.rs":"02bb3d352fb808131d298f9b90d9c95b7e9e0138b97c5401f3b9fdacc5562f44","src/server_timestamp.rs":"6272299c92b05b9ec9dc2e18402ebe927b07ccf1dcab5082301a09e0ee56ce24","src/sync15.udl":"005b2b056b93c959a04670f6f489afecb8e17093d8e4be34765a3a4cc0faeb8c","src/telemetry.rs":"e3a7e13e85f5e336526ebf07db04c81b8f1ba89ae1db4159a3a570826cb8cfd2","uniffi.toml":"34488f947497a9b05007445dd816024ef02e6b1696f1056ee868f039722828ee"},"package":null}
{"files":{"Cargo.toml":"f1c393a0b8b62e476bdde3e01e69087ec1a25597ec1c4a2d996d4f5514a39768","README.md":"6d4ff5b079ac5340d18fa127f583e7ad793c5a2328b8ecd12c3fc723939804f2","build.rs":"aa971160d67ce8626b26e15c04c34b730f594c45c817aae34cfc9f3ea14ae284","src/bso/content.rs":"92935258745bdf0c3915a555cb6884a7fa69faa1290ec2c1815f6e2f3c0f0562","src/bso/crypto.rs":"27602dcccb37d3a55620ee4e16b705da455d49af575de115c7c79c0178eb1d6d","src/bso/mod.rs":"09e723dc7e99295ecafdcadffaf604d66ea27cf2b7f1fd9ab3cac4f4698ff6a7","src/bso/test_utils.rs":"4ec5a2df5e1c0ec14dc770681e959bdcef6ef04f6fde435999197f46a8ae4831","src/client/coll_state.rs":"13e6ef55273baf5536acc369be522e34a803a32cabf19cce43e426aea9b6223e","src/client/coll_update.rs":"dac04a90c29dd969f8b4250414609c9b6d61daf2dfa4ae77d1c4a165ba970b05","src/client/collection_keys.rs":"c27b2277a3a52033b58ab01490fc2ea7007494195dd5e6dc2c6931a4ca96795a","src/client/mod.rs":"8f588d4a035cf79d96f2500f06d5651c1a7c566127c456ffa5429811ddce3fd6","src/client/request.rs":"8841524e37d8195867bdf6ba98c75f610cf47a4644adeebd6372cc6713f2260a","src/client/state.rs":"4e31193ef2471c1dfabf1c6a391bcb95e14ddb45855786a4194ff187d5c9347c","src/client/status.rs":"f445a8765dac9789444e23b5145148413407bb1d18a15ef56682243997f591bf","src/client/storage_client.rs":"8de72d4ba3ca4f68c8e1898466de83a2b543545a18679800cb4f7fbda2dc3183","src/client/sync.rs":"b29abb512ec9d163f7883b71f78c9202802dcb17cad1fc5dc08087fb0bb66704","src/client/sync_multiple.rs":"6e92571132f89744b553190c596be8aff9b2d031d8f79d82c94cdf78b1683f4a","src/client/token.rs":"b268759d31e0fe17e0e2a428694cd9a317fcfbdd52f023d5d8c7cc6f00f1a102","src/client/util.rs":"71cc70ee41f821f53078675e636e9fad9c6046fa1a989e37f5487e340a2277d6","src/client_types.rs":"3c3cac1540b92482f43660d9e43bdde8481c4cc1a98253a68c80e791231f5976","src/clients_engine/engine.rs":"9e11b47be81fc63214f31879af74075674aa50a8f8989afe20fefa7990fa99b9","src/clients_engine/mod.rs":"461729e6f89b66b2cbd89b041a03d4d6a8ba582284ed4f3015cb13e1a0c6da97","src/clients_engine/record.rs":"b0d84bf420743d7638a45e4836633a45e50257d5548fe7ecd04bff4d724439b8","src/clients_engine/ser.rs":"ef12daeb11faf618fe3cafe91f20a031fe5bb6751369b6ee5aee03f196efe88c","src/device_type.rs":"dc2d4296d25e31471c8e68488f1043ff239b902036cd6aea8a686cf79b4ed335","src/enc_payload.rs":"aa3eea7df49b24cd59831680a47c417b73a3e36e6b0f3f4baf14ca66bd68be6b","src/engine/bridged_engine.rs":"f70f1bfce6e0c04b0c72ec9cbfbb12c82d4009a23fb9768792107d41b2865a4f","src/engine/mod.rs":"90f1f9760f5f712a337aebb04e59c736e4b6fbd89d6a188d969210c7f3f321ae","src/engine/request.rs":"5923025fb9550178339f880a1bf8526d8e853e7a0b2bce6d9d687cc808ac0085","src/engine/sync_engine.rs":"531b35d72ce9e04c3e543c0468c1e450fba2c0dc3d33d68d9b1c0a5c1ad7dd34","src/error.rs":"a45cfe02e6301f473c34678b694943c1a04308b8c292c6e0448bf495194c3b5e","src/key_bundle.rs":"abd0781f3be8c8e7c691f18bb71f3433b633803c48da9794e15ac6301ed60d6c","src/lib.rs":"f59f8817978d943518dfa03ab31fc0f6b1fc72ee9943a97aef1537e2769649f5","src/record_types.rs":"02bb3d352fb808131d298f9b90d9c95b7e9e0138b97c5401f3b9fdacc5562f44","src/server_timestamp.rs":"0020f31971ccbfc485894cabc3087459d42252b86d7de07f2136997864b0373b","src/sync15.udl":"005b2b056b93c959a04670f6f489afecb8e17093d8e4be34765a3a4cc0faeb8c","src/telemetry.rs":"e3a7e13e85f5e336526ebf07db04c81b8f1ba89ae1db4159a3a570826cb8cfd2","uniffi.toml":"34488f947497a9b05007445dd816024ef02e6b1696f1056ee868f039722828ee"},"package":null}

Просмотреть файл

@ -1,7 +1,7 @@
/* 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/. */
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use std::time::Duration;
/// Typesafe way to manage server timestamps without accidentally mixing them up with
/// local ones.
@ -84,17 +84,6 @@ impl<'de> serde::de::Deserialize<'de> for ServerTimestamp {
}
}
/// Exposed only for tests that need to create a server timestamp from the system time
/// Please be cautious when constructing the timestamp directly, as constructing the server
/// timestamp from system time is almost certainly not what you'd want to do for non-test code
impl TryFrom<SystemTime> for ServerTimestamp {
type Error = std::time::SystemTimeError;
fn try_from(value: SystemTime) -> Result<Self, Self::Error> {
Ok(Self(value.duration_since(UNIX_EPOCH)?.as_millis() as i64))
}
}
#[cfg(test)]
mod test {
use super::*;

2
third_party/rust/tabs/.cargo-checksum.json поставляемый
Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"b1aebb4475665781d03e81608afa113aee8343c3e9707fd91591244f0c08c8c7","README.md":"c48b8f391ef822c4f3971b5f453a1e7b43bea232752d520460d2f04803aead1a","build.rs":"33e61b811b19ed2b58e319cc65d5988bed258d2c4fea2d706301184c59847a0f","src/error.rs":"2694657aeb12f99c4b2fe102ad2b08b79955d209201831b3e071129f0b7d7eda","src/lib.rs":"7208f78955e015ef8bab7916307e551cd3c1bd56d7fe14f8b53cd53bc4b38555","src/schema.rs":"2b7b51f3c2edc0ca603495c10b917603fd9ac791c4a366080e40d090b13b91f2","src/storage.rs":"18f449b6daf1641dc351be451311495b7c05e16c4e2d4eaf12c1fa02fa750b67","src/store.rs":"ab0b6214b30b0f0fa7c6a89098ff3db1a8f76264f6711c4481c0be460afe522b","src/sync/bridge.rs":"18d3a7913a030b598d4b6cbd5b7e2ab4cef4cc7ea964f5bc84d7fb2f28787529","src/sync/engine.rs":"2d14d899a38ac72b9141d505babd94ef7b6fbc5a95be70f324a40bf01935793d","src/sync/mod.rs":"09ba3c87f1174a243bf5aaa481effd18929d54359ceb9b23ccb2c32ee3482f34","src/sync/record.rs":"eef6751c209d039958afbe245ddb006cfdf6b8b6b47f925f69c552b832b87922","src/tabs.udl":"2cefc7f6a27b5619bc536d4a19608cf24153d745199fbeaf192e24b4381dedfb","uniffi.toml":"f9125e8d55b109e86076ee88bfd640372f06b142b7db557e41816c7227dd445c"},"package":null}
{"files":{"Cargo.toml":"b1aebb4475665781d03e81608afa113aee8343c3e9707fd91591244f0c08c8c7","README.md":"c48b8f391ef822c4f3971b5f453a1e7b43bea232752d520460d2f04803aead1a","build.rs":"33e61b811b19ed2b58e319cc65d5988bed258d2c4fea2d706301184c59847a0f","src/error.rs":"2694657aeb12f99c4b2fe102ad2b08b79955d209201831b3e071129f0b7d7eda","src/lib.rs":"7208f78955e015ef8bab7916307e551cd3c1bd56d7fe14f8b53cd53bc4b38555","src/schema.rs":"2b7b51f3c2edc0ca603495c10b917603fd9ac791c4a366080e40d090b13b91f2","src/storage.rs":"4ad235bda076a85660f7825aea518c0d1ae458e7eddf47b1cf1167ca5a52385f","src/store.rs":"ab0b6214b30b0f0fa7c6a89098ff3db1a8f76264f6711c4481c0be460afe522b","src/sync/bridge.rs":"3bf96a7e028efb771854439f7ec183488f831f859396b562bbcf1ece9a6959b3","src/sync/engine.rs":"13656bf027fcbf0b5682a66d29f062177e49250a73ec1fd0cf2af3f1fe59f12f","src/sync/mod.rs":"09ba3c87f1174a243bf5aaa481effd18929d54359ceb9b23ccb2c32ee3482f34","src/sync/record.rs":"896ebc6aa213bac9e6170c7e0b7dbee322f62e5f6c28462cb6da0bfe8ce938ba","src/tabs.udl":"e94706bc555ed082c806b2bc806f494770b66470aa8ee437f7f43eb26fd8f112","uniffi.toml":"f9125e8d55b109e86076ee88bfd640372f06b142b7db557e41816c7227dd445c"},"package":null}

51
third_party/rust/tabs/src/storage.rs поставляемый
Просмотреть файл

@ -30,13 +30,12 @@ const FAR_FUTURE: i64 = 4_102_405_200_000; // 2100/01/01
const MAX_PAYLOAD_SIZE: usize = 512 * 1024; // Twice as big as desktop, still smaller than server max (2MB)
const MAX_TITLE_CHAR_LENGTH: usize = 512; // We put an upper limit on title sizes for tabs to reduce memory
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct RemoteTab {
pub title: String,
pub url_history: Vec<String>,
pub icon: Option<String>,
pub last_used: i64, // In ms.
pub inactive: bool,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
@ -496,10 +495,13 @@ mod tests {
assert_eq!(storage.prepare_local_tabs_for_upload(), None);
storage.update_local_state(vec![
RemoteTab {
title: "".to_owned(),
url_history: vec!["about:blank".to_owned(), "https://foo.bar".to_owned()],
..Default::default()
icon: None,
last_used: 0,
},
RemoteTab {
title: "".to_owned(),
url_history: vec![
"https://foo.bar".to_owned(),
"about:blank".to_owned(),
@ -510,9 +512,11 @@ mod tests {
"about:blank".to_owned(),
"about:blank".to_owned(),
],
..Default::default()
icon: None,
last_used: 0,
},
RemoteTab {
title: "".to_owned(),
url_history: vec![
"https://foo.bar".to_owned(),
"about:blank".to_owned(),
@ -522,20 +526,27 @@ mod tests {
"https://foo5.bar".to_owned(),
"https://foo6.bar".to_owned(),
],
..Default::default()
icon: None,
last_used: 0,
},
RemoteTab {
..Default::default()
title: "".to_owned(),
url_history: vec![],
icon: None,
last_used: 0,
},
]);
assert_eq!(
storage.prepare_local_tabs_for_upload(),
Some(vec![
RemoteTab {
title: "".to_owned(),
url_history: vec!["https://foo.bar".to_owned()],
..Default::default()
icon: None,
last_used: 0,
},
RemoteTab {
title: "".to_owned(),
url_history: vec![
"https://foo.bar".to_owned(),
"https://foo2.bar".to_owned(),
@ -543,7 +554,8 @@ mod tests {
"https://foo4.bar".to_owned(),
"https://foo5.bar".to_owned()
],
..Default::default()
icon: None,
last_used: 0,
},
])
);
@ -555,7 +567,8 @@ mod tests {
storage.update_local_state(vec![RemoteTab {
title: "a".repeat(MAX_TITLE_CHAR_LENGTH + 10), // Fill a string more than max
url_history: vec!["https://foo.bar".to_owned()],
..Default::default()
icon: None,
last_used: 0,
}]);
let ellipsis_char = '\u{2026}';
let mut truncated_title = "a".repeat(MAX_TITLE_CHAR_LENGTH - ellipsis_char.len_utf8());
@ -567,7 +580,8 @@ mod tests {
RemoteTab {
title: truncated_title, // title was trimmed to only max char length
url_history: vec!["https://foo.bar".to_owned()],
..Default::default()
icon: None,
last_used: 0,
},
])
);
@ -580,12 +594,14 @@ mod tests {
RemoteTab {
title: "😍".repeat(MAX_TITLE_CHAR_LENGTH + 10), // Fill a string more than max
url_history: vec!["https://foo.bar".to_owned()],
..Default::default()
icon: None,
last_used: 0,
},
RemoteTab {
title: "".repeat(MAX_TITLE_CHAR_LENGTH + 5), // Fill a string more than max
url_history: vec!["https://foo_jp.bar".to_owned()],
..Default::default()
icon: None,
last_used: 0,
},
]);
let ellipsis_char = '\u{2026}';
@ -602,12 +618,14 @@ mod tests {
RemoteTab {
title: truncated_title, // title was trimmed to only max char length
url_history: vec!["https://foo.bar".to_owned()],
..Default::default()
icon: None,
last_used: 0,
},
RemoteTab {
title: truncated_jp_title, // title was trimmed to only max char length
url_history: vec!["https://foo_jp.bar".to_owned()],
..Default::default()
icon: None,
last_used: 0,
},
]
);
@ -625,7 +643,8 @@ mod tests {
title: "aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa aaaa" //50 characters
.to_owned(),
url_history: vec![format!("https://foo{}.bar", n)],
..Default::default()
icon: None,
last_used: 0,
});
}
let tabs_mem_size = compute_serialized_size(&too_many_tabs);
@ -662,7 +681,6 @@ mod tests {
url_history: vec!["https://mozilla.org/".to_string()],
icon: Some("https://mozilla.org/icon".to_string()),
last_used: 1643764207000,
..Default::default()
}],
},
last_modified: 1643764207000,
@ -677,7 +695,6 @@ mod tests {
url_history: vec!["https://mozilla.org/".to_string()],
icon: Some("https://mozilla.org/icon".to_string()),
last_used: 1643764207000,
..Default::default()
}],
},
last_modified: 1443764207000, // old

4
third_party/rust/tabs/src/sync/bridge.rs поставляемый
Просмотреть файл

@ -149,14 +149,14 @@ mod tests {
RemoteTab {
title: "my first tab".to_string(),
url_history: vec!["http://1.com".to_string()],
icon: None,
last_used: 2,
..Default::default()
},
RemoteTab {
title: "my second tab".to_string(),
url_history: vec!["http://2.com".to_string()],
icon: None,
last_used: 1,
..Default::default()
},
];
store.set_local_tabs(my_tabs.clone());

2
third_party/rust/tabs/src/sync/engine.rs поставляемый
Просмотреть файл

@ -92,7 +92,6 @@ impl RemoteTab {
url_history: tab.url_history.clone(),
icon: tab.icon.clone(),
last_used: tab.last_used.checked_mul(1000).unwrap_or_default(),
inactive: tab.inactive,
}
}
pub(super) fn to_record_tab(&self) -> TabsRecordTab {
@ -101,7 +100,6 @@ impl RemoteTab {
url_history: self.url_history.clone(),
icon: self.icon.clone(),
last_used: self.last_used.checked_div(1000).unwrap_or_default(),
inactive: self.inactive,
}
}
}

9
third_party/rust/tabs/src/sync/record.rs поставляемый
Просмотреть файл

@ -4,11 +4,6 @@
use serde_derive::{Deserialize, Serialize};
// copy/pasta...
fn skip_if_default<T: PartialEq + Default>(v: &T) -> bool {
*v == T::default()
}
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct TabsRecordTab {
@ -16,8 +11,6 @@ pub struct TabsRecordTab {
pub url_history: Vec<String>,
pub icon: Option<String>,
pub last_used: i64, // Seconds since epoch!
#[serde(default, skip_serializing_if = "skip_if_default")]
pub inactive: bool,
}
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
@ -58,7 +51,6 @@ pub mod test {
assert_eq!(tab.title, "the title");
assert_eq!(tab.icon, Some("https://mozilla.org/icon".to_string()));
assert_eq!(tab.last_used, 1643764207);
assert!(!tab.inactive);
}
#[test]
@ -71,7 +63,6 @@ pub mod test {
url_history: vec!["https://mozilla.org/".into()],
icon: Some("https://mozilla.org/icon".into()),
last_used: 1643764207,
inactive: true,
}],
};
let round_tripped =

1
third_party/rust/tabs/src/tabs.udl поставляемый
Просмотреть файл

@ -37,7 +37,6 @@ dictionary RemoteTabRecord {
string? icon;
// Number of ms since the unix epoch (as reported by the client's clock)
i64 last_used;
boolean inactive = false;
};
dictionary ClientRemoteTabs {

Просмотреть файл

@ -400,12 +400,6 @@ urlbar:
If neither Nimbus nor remote settings defines a cap, no cap will be
used, and the user will be able to increment the minimum length without
any limit.
yelpFeatureGate:
type: boolean
fallbackPref: browser.urlbar.yelp.featureGate
description: >-
Feature gate that controls whether all aspects of the Yelp suggestion
feature are exposed to the user.
frecency:
description: "The address bar ranking algorithm"

Просмотреть файл

@ -849,16 +849,6 @@ Suggestion.Amo = class extends Suggestion{
this.score = score;
}
}
Suggestion.Yelp = class extends Suggestion{
constructor(
url,
title
) {
super();
this.url = url;
this.title = title;
}
}
// Export the FFIConverter object to make external types work.
export class FfiConverterTypeSuggestion extends FfiConverterArrayBuffer {
@ -903,11 +893,6 @@ export class FfiConverterTypeSuggestion extends FfiConverterArrayBuffer {
FfiConverterString.read(dataStream),
FfiConverterF64.read(dataStream)
);
case 5:
return new Suggestion.Yelp(
FfiConverterString.read(dataStream),
FfiConverterString.read(dataStream)
);
default:
return new Error("Unknown Suggestion variant");
}
@ -957,12 +942,6 @@ export class FfiConverterTypeSuggestion extends FfiConverterArrayBuffer {
FfiConverterF64.write(dataStream, value.score);
return;
}
if (value instanceof Suggestion.Yelp) {
dataStream.writeInt32(5);
FfiConverterString.write(dataStream, value.url);
FfiConverterString.write(dataStream, value.title);
return;
}
return new Error("Unknown Suggestion variant");
}
@ -1008,11 +987,6 @@ export class FfiConverterTypeSuggestion extends FfiConverterArrayBuffer {
totalSize += FfiConverterF64.computeSize(value.score);
return totalSize;
}
if (value instanceof Suggestion.Yelp) {
totalSize += FfiConverterString.computeSize(value.url);
totalSize += FfiConverterString.computeSize(value.title);
return totalSize;
}
return new Error("Unknown Suggestion variant");
}
@ -1030,7 +1004,6 @@ export const SuggestionProvider = {
POCKET: 2,
WIKIPEDIA: 3,
AMO: 4,
YELP: 5,
};
Object.freeze(SuggestionProvider);
@ -1046,8 +1019,6 @@ export class FfiConverterTypeSuggestionProvider extends FfiConverterArrayBuffer
return SuggestionProvider.WIKIPEDIA
case 4:
return SuggestionProvider.AMO
case 5:
return SuggestionProvider.YELP
default:
return new Error("Unknown SuggestionProvider variant");
}
@ -1070,10 +1041,6 @@ export class FfiConverterTypeSuggestionProvider extends FfiConverterArrayBuffer
dataStream.writeInt32(4);
return;
}
if (value === SuggestionProvider.YELP) {
dataStream.writeInt32(5);
return;
}
return new Error("Unknown SuggestionProvider variant");
}
@ -1082,7 +1049,7 @@ export class FfiConverterTypeSuggestionProvider extends FfiConverterArrayBuffer
}
static checkType(value) {
if (!Number.isInteger(value) || value < 1 || value > 5) {
if (!Number.isInteger(value) || value < 1 || value > 4) {
throw new UniFFITypeError(`${value} is not a valid value for SuggestionProvider`);
}
}

Просмотреть файл

@ -286,29 +286,6 @@ export class FfiConverterI64 extends FfiConverter {
}
}
// Export the FFIConverter object to make external types work.
export class FfiConverterBool extends FfiConverter {
static computeSize() {
return 1;
}
static lift(value) {
return value == 1;
}
static lower(value) {
if (value) {
return 1;
} else {
return 0;
}
}
static write(dataStream, value) {
dataStream.writeUint8(this.lower(value))
}
static read(dataStream) {
return this.lift(dataStream.readUint8())
}
}
// Export the FFIConverter object to make external types work.
export class FfiConverterString extends FfiConverter {
static checkType(value) {
@ -921,7 +898,7 @@ export class FfiConverterTypeClientRemoteTabs extends FfiConverterArrayBuffer {
}
export class RemoteTabRecord {
constructor(title,urlHistory,icon,lastUsed,inactive = false) {
constructor(title,urlHistory,icon,lastUsed) {
try {
FfiConverterString.checkType(title)
} catch (e) {
@ -954,27 +931,17 @@ export class RemoteTabRecord {
}
throw e;
}
try {
FfiConverterBool.checkType(inactive)
} catch (e) {
if (e instanceof UniFFITypeError) {
e.addItemDescriptionPart("inactive");
}
throw e;
}
this.title = title;
this.urlHistory = urlHistory;
this.icon = icon;
this.lastUsed = lastUsed;
this.inactive = inactive;
}
equals(other) {
return (
this.title == other.title &&
this.urlHistory == other.urlHistory &&
this.icon == other.icon &&
this.lastUsed == other.lastUsed &&
this.inactive == other.inactive
this.lastUsed == other.lastUsed
)
}
}
@ -986,8 +953,7 @@ export class FfiConverterTypeRemoteTabRecord extends FfiConverterArrayBuffer {
FfiConverterString.read(dataStream),
FfiConverterSequencestring.read(dataStream),
FfiConverterOptionalstring.read(dataStream),
FfiConverterI64.read(dataStream),
FfiConverterBool.read(dataStream)
FfiConverterI64.read(dataStream)
);
}
static write(dataStream, value) {
@ -995,7 +961,6 @@ export class FfiConverterTypeRemoteTabRecord extends FfiConverterArrayBuffer {
FfiConverterSequencestring.write(dataStream, value.urlHistory);
FfiConverterOptionalstring.write(dataStream, value.icon);
FfiConverterI64.write(dataStream, value.lastUsed);
FfiConverterBool.write(dataStream, value.inactive);
}
static computeSize(value) {
@ -1004,7 +969,6 @@ export class FfiConverterTypeRemoteTabRecord extends FfiConverterArrayBuffer {
totalSize += FfiConverterSequencestring.computeSize(value.urlHistory);
totalSize += FfiConverterOptionalstring.computeSize(value.icon);
totalSize += FfiConverterI64.computeSize(value.lastUsed);
totalSize += FfiConverterBool.computeSize(value.inactive);
return totalSize
}
@ -1042,14 +1006,6 @@ export class FfiConverterTypeRemoteTabRecord extends FfiConverterArrayBuffer {
}
throw e;
}
try {
FfiConverterBool.checkType(value.inactive);
} catch (e) {
if (e instanceof UniFFITypeError) {
e.addItemDescriptionPart(".inactive");
}
throw e;
}
}
}