Skip to content

Commit

Permalink
Merge autoland to mozilla-central. a=merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandor Molnar committed Mar 21, 2024
2 parents c393942 + f76d82b commit f0fb2f5
Show file tree
Hide file tree
Showing 444 changed files with 20,310 additions and 3,192 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ module.exports = {
"no-unused-vars": [
"error",
{
args: "none",
argsIgnorePattern: "^_",
vars: "local",
},
],
Expand All @@ -184,7 +184,7 @@ module.exports = {
"no-unused-vars": [
"error",
{
args: "none",
argsIgnorePattern: "^_",
vars: "all",
},
],
Expand Down
2 changes: 1 addition & 1 deletion accessible/tests/browser/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
"no-proto": "error",
"no-return-assign": "error",
"no-shadow": "error",
"no-unused-vars": ["error", { vars: "all", args: "none" }],
"no-unused-vars": ["error", { vars: "all", argsIgnorePattern: "^_" }],
"one-var": ["error", "never"],
radix: "error",
strict: ["error", "global"],
Expand Down
10 changes: 5 additions & 5 deletions accessible/tests/browser/e10s/browser_aria_activedescendant.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ async function basicListboxTest(browser, elementReflection) {

addAccessibleTask(
LISTBOX_MARKUP,
async function (browser, docAcc) {
async function (browser) {
info("Test aria-activedescendant content attribute");
await basicListboxTest(browser, false);

Expand All @@ -303,7 +303,7 @@ addAccessibleTask(

addAccessibleTask(
LISTBOX_MARKUP,
async function (browser, docAcc) {
async function (browser) {
info("Test ariaActiveDescendantElement element reflection");
await basicListboxTest(browser, true);
},
Expand All @@ -316,7 +316,7 @@ addAccessibleTask(
<div role="listbox">
<div role="option" id="activedesc_nondesc_option">option</div>
</div>`,
async function (browser, docAcc) {
async function (browser) {
info("Test aria-activedescendant non-descendant");
await synthFocus(
browser,
Expand Down Expand Up @@ -348,7 +348,7 @@ addAccessibleTask(
item.setAttribute("role", "option");
listbox.appendChild(item);
</script>`,
async function (browser, docAcc) {
async function (browser) {
info("Test aria-activedescendant in shadow root");
// We want to retrieve elements using their IDs inside the shadow root, so
// we define a custom get element by ID method that our utility functions
Expand Down Expand Up @@ -448,7 +448,7 @@ customElements.define("custom-listbox",
}
);
</script>`,
async function (browser, docAcc) {
async function (browser) {
await synthFocus(browser, "custom-listbox1", "l1_3");

let evtProm = Promise.all([
Expand Down
2 changes: 1 addition & 1 deletion accessible/tests/browser/windows/uia/browser_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ addUiaTask(
<div id="editable" contenteditable>editable</div>
<table id="table"><tr><th>th</th></tr></table>
`,
async function (browser, docAcc) {
async function () {
await definePyVar("doc", `getDocUia()`);
await assignPyVarToUiaWithId("p");
await testIsControl("p", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ add_task(async function () {
gBrowser,
url,
},
async function (browser) {
async function () {
let popup = await openSelectPopup("click");
let menuitems = popup.querySelectorAll("menuitem");
is(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ add_task(async function testClearingBeforeDataSizesLoad() {
info("stub called");

info("This promise should never resolve");
await new Promise(resolve => {});
await new Promise(() => {});
});
dh.onload = async function () {
// we don't need to initiate a event listener to wait for the resolver to be assigned for this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ add_task(async function () {
BrowserTestUtils.synthesizeMouseAtCenter(id, { ...event }, browser);
} else {
// Make sure the keyboard activates a simple button on the page.
await ContentTask.spawn(browser, id, elementId => {
await ContentTask.spawn(browser, id, () => {
content.document.querySelector("#focus-result").value = "";
content.document.querySelector("#focus-check").focus();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PseudoLocalizationButton } from "../PseudoLocalizationButton.jsx";
import { FluentPanel } from "../FluentPanel.jsx";

// Register the addon.
addons.register(ADDON_ID, api => {
addons.register(ADDON_ID, () => {
// Register the tool.
addons.add(TOOL_ID, {
type: types.TOOL,
Expand Down
66 changes: 53 additions & 13 deletions browser/components/urlbar/UrlbarController.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,6 @@ class TelemetryEvent {
constructor(controller, category) {
this._controller = controller;
this._category = category;
this.#exposureResultTypes = new Set();
this.#beginObservingPingPrefs();
}

Expand Down Expand Up @@ -1093,18 +1092,20 @@ class TelemetryEvent {
}

// First check to see if we can record an exposure event
if (
(method === "abandonment" || method === "engagement") &&
this.#exposureResultTypes.size
) {
const exposureResults = Array.from(this.#exposureResultTypes).join(",");
this._controller.logger.debug(
`exposure event: ${JSON.stringify({ results: exposureResults })}`
);
Glean.urlbar.exposure.record({ results: exposureResults });
if (method === "abandonment" || method === "engagement") {
if (this.#exposureResultTypes.size) {
let exposure = {
results: [...this.#exposureResultTypes].sort().join(","),
};
this._controller.logger.debug(
`exposure event: ${JSON.stringify(exposure)}`
);
Glean.urlbar.exposure.record(exposure);
}

// reset the provider list on the controller
this.#exposureResultTypes.clear();
this.#tentativeExposureResultTypes.clear();
}

this._controller.logger.info(
Expand All @@ -1115,16 +1116,54 @@ class TelemetryEvent {
}

/**
* Add result type to engagementEvent instance exposureResultTypes Set.
* Registers an exposure for a result in the current urlbar session. All
* exposures that are added during a session are recorded in an exposure event
* at the end of the session. Exposures are cleared at the end of each session
* and do not carry over to the next session.
*
* @param {UrlbarResult} result UrlbarResult to have exposure recorded.
* @param {UrlbarResult} result An exposure will be added for this result if
* exposures are enabled for its result type.
*/
addExposure(result) {
if (result.exposureResultType) {
this.#exposureResultTypes.add(result.exposureResultType);
}
}

/**
* Registers a tentative exposure for a result in the current urlbar session.
* Exposures that remain tentative at the end of the session are discarded and
* are not recorded in the exposure event.
*
* @param {UrlbarResult} result A tentative exposure will be added for this
* result if exposures are enabled for its result type.
*/
addTentativeExposure(result) {
if (result.exposureResultType) {
this.#tentativeExposureResultTypes.add(result.exposureResultType);
}
}

/**
* Converts all tentative exposures that were added and not yet discarded
* during the current urlbar session into actual exposures that will be
* recorded at the end of the session.
*/
acceptTentativeExposures() {
for (let type of this.#tentativeExposureResultTypes) {
this.#exposureResultTypes.add(type);
}
this.#tentativeExposureResultTypes.clear();
}

/**
* Discards all tentative exposures that were added and not yet accepted
* during the current urlbar session.
*/
discardTentativeExposures() {
this.#tentativeExposureResultTypes.clear();
}

#getInteractionType(
method,
startEventInfo,
Expand Down Expand Up @@ -1313,5 +1352,6 @@ class TelemetryEvent {

#previousSearchWordsSet = null;

#exposureResultTypes;
#exposureResultTypes = new Set();
#tentativeExposureResultTypes = new Set();
}
29 changes: 17 additions & 12 deletions browser/components/urlbar/UrlbarView.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,10 @@ export class UrlbarView {
// future we should make it support any type of result. Or, even better,
// results should be grouped, thus we can directly update groups.

// Discard tentative exposures. This is analogous to marking the
// hypothetical hidden rows of hidden-exposure results as stale.
this.controller.engagementEvent.discardTentativeExposures();

// Walk rows and find an insertion index for results. To avoid flicker, we
// skip rows until we find one compatible with the result we want to apply.
// If we couldn't find a compatible range, we'll just update.
Expand Down Expand Up @@ -1217,7 +1221,7 @@ export class UrlbarView {
) {
// We can replace the row's current result with the new one.
if (result.exposureResultHidden) {
this.#addExposure(result);
this.controller.engagementEvent.addExposure(result);
} else {
this.#updateRow(row, result);
}
Expand Down Expand Up @@ -1287,7 +1291,13 @@ export class UrlbarView {
newSpanCount <= this.#queryContext.maxResults && !seenMisplacedResult;
if (result.exposureResultHidden) {
if (canBeVisible) {
this.#addExposure(result);
this.controller.engagementEvent.addExposure(result);
} else {
// Add a tentative exposure: The hypothetical row for this
// hidden-exposure result can't be visible now, but as long as it were
// not marked stale in a later update, it would be shown when stale
// rows are removed.
this.controller.engagementEvent.addTentativeExposure(result);
}
continue;
}
Expand Down Expand Up @@ -2126,7 +2136,7 @@ export class UrlbarView {
let visible = this.#isElementVisible(item);
if (visible) {
if (item.result.exposureResultType) {
this.#addExposure(item.result);
this.controller.engagementEvent.addExposure(item.result);
}
this.visibleResults.push(item.result);
}
Expand Down Expand Up @@ -2363,6 +2373,10 @@ export class UrlbarView {
row = next;
}
this.#updateIndices();

// Accept tentative exposures. This is analogous to unhiding the
// hypothetical non-stale hidden rows of hidden-exposure results.
this.controller.engagementEvent.acceptTentativeExposures();
}

#startRemoveStaleRowsTimer() {
Expand Down Expand Up @@ -3460,15 +3474,6 @@ export class UrlbarView {
this.#populateResultMenu();
}
}

/**
* Add result to exposure set on the controller.
*
* @param {UrlbarResult} result UrlbarResult for which to record an exposure.
*/
#addExposure(result) {
this.controller.engagementEvent.addExposure(result);
}
}

/**
Expand Down
9 changes: 5 additions & 4 deletions browser/components/urlbar/private/SuggestBackendRust.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ export class SuggestBackendRust extends BaseFeature {
suggestion.provider = type;
suggestion.is_sponsored = type == "Amp" || type == "Yelp";
if (Array.isArray(suggestion.icon)) {
suggestion.icon_blob = new Blob(
[new Uint8Array(suggestion.icon)],
type == "Yelp" ? { type: "image/svg+xml" } : null
);
suggestion.icon_blob = new Blob([new Uint8Array(suggestion.icon)], {
type: suggestion.iconMimetype ?? "",
});

delete suggestion.icon;
delete suggestion.iconMimetype;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function checkUrlbarFocus(win, focusState) {
// URL bar records the correct abandonment telemetry with abandonment type
// "tab_swtich".
add_task(async function tabSwitchFocusedToFocused() {
await doTest(async browser => {
await doTest(async () => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "test search",
Expand All @@ -45,7 +45,7 @@ add_task(async function tabSwitchFocusedToFocused() {
// URL bar loses focus logs abandonment telemetry with abandonment type
// "blur".
add_task(async function tabSwitchFocusedToUnfocused() {
await doTest(async browser => {
await doTest(async () => {
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "test search",
Expand All @@ -65,7 +65,7 @@ add_task(async function tabSwitchFocusedToUnfocused() {
// the URL bar gains focus does not record any abandonment telemetry, reflecting
// no change in focus state relevant to abandonment.
add_task(async function tabSwitchUnFocusedToFocused() {
await doTest(async browser => {
await doTest(async () => {
checkUrlbarFocus(window, false);

let promiseTabOpened = BrowserTestUtils.waitForEvent(
Expand All @@ -91,7 +91,7 @@ add_task(async function tabSwitchUnFocusedToFocused() {
// Checks that switching between two tabs, both with unfocused URL bars, does
// not trigger any abandonment telmetry.
add_task(async function tabSwitchUnFocusedToUnFocused() {
await doTest(async browser => {
await doTest(async () => {
checkUrlbarFocus(window, false);

let tab2 = await BrowserTestUtils.openNewForegroundTab(window.gBrowser);
Expand Down
Loading

0 comments on commit f0fb2f5

Please sign in to comment.