Closed Bug 2070691 Opened 2 months ago Closed 12 days ago

Add error component

Categories

(Firefox :: Widgets, task, P3)

task
Points:
2

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: fchasen, Assigned: nina-py)

References

(Blocks 1 open bug)

Details

(Whiteboard: [hnt][hnt-wattle])

Attachments

(3 external files)

The widget needs and error component to show an error screen and a reportError method and error property to trigger it.

Points: --- → 2

This should be the same screen as https://www.figma.com/design/i8wWurQ8yn9y5hCjnf8BYu/HNT---Nova?node-id=17363-110293&m=dev

That one says: Crossword unavailable. Check back later.

We will have the widget name available, but that would be like Daily Crossword so not sure it will grammatically make sense as is using the full name?

Should also include telemetry on New Tab

Assignee: nobody → npypchenko
Status: NEW → ASSIGNED

The error state has moved into moz-widget, since it owns the frame.
The frame reports its own failure over postMessage on a moz_widget
channel: widget_error sets the state and widget_ready clears it,
each re-emitted as a widget-error or widget-ready DOM event.
reportError() and clearError() drive the same state from a host
that detects a failure some other way. Both message names come from the
Particle (Crossword) widget, which already posts them.

The error content covers the frame rather than replacing it, so a
widget whose data source comes back can say so and get its own view
back. The frame keeps running behind an opaque overlay and goes inert.

New Tab supplies the message, and WidgetError records the error on
first visibility so a preloaded tab the user never saw records nothing.
The wording names no widget, since the header above already does. But
role="alert" announces the message and nothing else, so the name goes
inside it as well, visually hidden. A screen reader reads the widget
name, then the message. Where a widget draws no header of its own, it
passes headerless and the name shows.

Storybook has a ReportedError story that runs the cycle against a
real document, served through a new staticDirs entry in
.storybook/main.js.

Attachment #9668355 - Attachment description: WIP: Bug 2070691 - Add error component r=fchasen! → Bug 2070691 - Add error component r=fchasen!
Attachment #9668355 - Attachment description: Bug 2070691 - Add error component r=fchasen! → Bug 2070691 - Part 1: Add an error state to moz-widget r=fchasen!

A New Tab widget that fails now shows a message in place of its
content. MozWidgetCard listens for the widget-error and
widget-ready events from moz-widget, and draws WidgetError in the
error slot while the widget is in the error state. A widget in
WIDGET_REGISTRY can set errorL10nId for wording of its own.

WidgetError records widgets_error once the message is on screen, so
a preloaded tab the user never saw records nothing. The error_type is
the reason the widget reported, or load_error when the card noticed
the failure itself. The widget name goes inside the role="alert", and
is visually hidden when a header already shows it.

MozWidgetCard takes a readyOnLoad prop, true by default for
extension pages, and sets the ready-on-load attribute from it.

A hosted widget page reports its state with postMessage, following
the protocol in docs/host-integration.md of mozilla/framed-widgets.
FramedWidgetCard listens on the <telemetryName>_widget channel and
accepts only messages from the window of its frame and the origin of
its document.

A widget_error with terminal: true and a reason that matches the
protocol's token rule calls reportError(reason) on moz-widget, so
the reason reaches widgets_error as error_type. Other errors are
ignored for now. A widget_ready calls reportReady(), unless the
card is already in the error state, since a widget sends widget_ready
when its page loads even after an early crash.

The card passes readyOnLoad={false}, because the page reports for
itself. reportError() and reportReady() don't exist before Firefox
161, so the optional calls do nothing there.

Status: ASSIGNED → RESOLVED
Closed: 12 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: