Skip to content

Commit 3bc6f8d

Browse files
authored
Provide correct instructions on the home page for Firefox for Android (Fenix) (#5816)
1 parent e197075 commit 3bc6f8d

File tree

4 files changed

+354
-15
lines changed

4 files changed

+354
-15
lines changed

locales/en-US/app.ftl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,15 @@ Home--instructions-content =
381381
Recording performance profiles requires <a>{ -firefox-brand-name }</a>.
382382
However, existing profiles can be viewed in any modern browser.
383383
384+
Home--fenix-instructions-directly =
385+
{ -firefox-android-brand-name } can be profiled directly on this device. For
386+
more information, read <a>Profiling { -firefox-android-brand-name } directly on device</a>.
387+
388+
Home--fenix-instructions-remotely =
389+
You can also profile { -firefox-android-brand-name } remotely from { -firefox-brand-name }
390+
for desktop. For more information, please consult this documentation:
391+
<a>Profiling { -firefox-android-brand-name } remotely</a>.
392+
384393
Home--record-instructions-start-stop = Stop and start profiling
385394
Home--record-instructions-capture-load = Capture and load profile
386395
Home--profiler-motto = Capture a performance profile. Analyze it. Share it. Make the web faster.

src/components/app/Home.tsx

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ type PopupInstallPhase =
223223
| 'popup-enabled'
224224
| 'suggest-enable-popup'
225225
// Other browsers:
226+
| 'firefox-android'
226227
| 'suggest-chrome-extension'
227228
| 'other-browser';
228229

@@ -233,21 +234,25 @@ class HomeImpl extends React.PureComponent<HomeProps, HomeState> {
233234
let popupInstallPhase = 'other-browser';
234235

235236
if (_isFirefox()) {
236-
popupInstallPhase = 'checking-webchannel';
237-
238-
// Query the browser to see if the menu button is available.
239-
queryIsMenuButtonEnabled().then(
240-
(isMenuButtonEnabled) => {
241-
this.setState({
242-
popupInstallPhase: isMenuButtonEnabled
243-
? 'popup-enabled'
244-
: 'suggest-enable-popup',
245-
});
246-
},
247-
() => {
248-
this.setState({ popupInstallPhase: 'webchannel-unavailable' });
249-
}
250-
);
237+
if (_isAndroid()) {
238+
popupInstallPhase = 'firefox-android';
239+
} else {
240+
popupInstallPhase = 'checking-webchannel';
241+
242+
// Query the browser to see if the menu button is available.
243+
queryIsMenuButtonEnabled().then(
244+
(isMenuButtonEnabled) => {
245+
this.setState({
246+
popupInstallPhase: isMenuButtonEnabled
247+
? 'popup-enabled'
248+
: 'suggest-enable-popup',
249+
});
250+
},
251+
() => {
252+
this.setState({ popupInstallPhase: 'webchannel-unavailable' });
253+
}
254+
);
255+
}
251256
} else if (_isChromium()) {
252257
popupInstallPhase = 'suggest-chrome-extension';
253258
// TODO: Check if the extension is installed and show the recording
@@ -269,6 +274,8 @@ class HomeImpl extends React.PureComponent<HomeProps, HomeState> {
269274
return this._renderEnablePopupInstructions(false);
270275
case 'popup-enabled':
271276
return this._renderRecordInstructions(FirefoxPopupScreenshot);
277+
case 'firefox-android':
278+
return this._renderFenixInstructions();
272279
case 'suggest-chrome-extension':
273280
return this._renderChromeInstructions();
274281
case 'other-browser':
@@ -381,6 +388,55 @@ class HomeImpl extends React.PureComponent<HomeProps, HomeState> {
381388
);
382389
}
383390

391+
_renderFenixInstructions() {
392+
return (
393+
<InstructionTransition key={0}>
394+
<div className="homeInstructions" data-testid="home-fenix-instructions">
395+
{/* Grid container: homeInstructions */}
396+
{/* Left column: img */}
397+
<img
398+
className="homeSectionScreenshot"
399+
src={PerfScreenshot}
400+
alt="screenshot of profiler.firefox.com"
401+
/>
402+
{/* Right column: instructions */}
403+
<div>
404+
<DocsButton />
405+
<Localized
406+
id="Home--fenix-instructions-directly"
407+
elems={{
408+
a: (
409+
<a href="https://profiler.firefox.com/docs/#/./guide-profiling-android-directly-on-device?id=profiling-firefox-for-android-directly-on-device" />
410+
),
411+
}}
412+
>
413+
<p>
414+
Firefox for Android can be profiled directly on this device. For
415+
more information, read{' '}
416+
<a>Profiling Firefox for Android directly on device</a>.
417+
</p>
418+
</Localized>
419+
<Localized
420+
id="Home--fenix-instructions-remotely"
421+
elems={{
422+
a: (
423+
<a href="https://profiler.firefox.com/docs/#/./guide-remote-profiling?id=remote-profiling-firefox-for-android" />
424+
),
425+
}}
426+
>
427+
<p>
428+
You can also profile Firefox for Android remotely from Firefox
429+
for desktop. For more information, please consult this
430+
documentation: <a>Profiling Firefox for Android remotely</a>.
431+
</p>
432+
</Localized>
433+
</div>
434+
{/* end of grid container */}
435+
</div>
436+
</InstructionTransition>
437+
);
438+
}
439+
384440
_renderChromeInstructions() {
385441
const chromeExtensionUrl =
386442
'https://chromewebstore.google.com/detail/firefox-profiler/ljmahpnflmbkgaipnfbpgjipcnahlghn';
@@ -700,6 +756,10 @@ function _isChromium(): boolean {
700756
return Boolean(navigator.userAgent.match(/Chrome\/\d+\.\d+/));
701757
}
702758

759+
function _isAndroid(): boolean {
760+
return Boolean(navigator.userAgent.match(/\bAndroid\b/i));
761+
}
762+
703763
export const Home = explicitConnect<
704764
OwnHomeProps,
705765
StateHomeProps,

src/test/components/Home.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const SAFARI =
2525
const CHROME =
2626
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
2727
let userAgent: string | undefined;
28+
const ANDROID =
29+
'Mozilla/5.0 (Android 16; Mobile; rv:147.0) Gecko/147.0 Firefox/147.0';
2830

2931
// Flow doesn't understand Object.defineProperty. Use the "any" type to use it anyway.
3032
(Object.defineProperty as any)(window.navigator, 'userAgent', {
@@ -53,6 +55,11 @@ describe('app/Home', function () {
5355
expect(container.firstChild).toMatchSnapshot();
5456
});
5557

58+
it('renders the information screen for fenix', () => {
59+
const { container } = setup(ANDROID);
60+
expect(container.firstChild).toMatchSnapshot();
61+
});
62+
5663
it('renders the information screen for other browsers', () => {
5764
const { container } = setup(SAFARI);
5865
expect(container.firstChild).toMatchSnapshot();

0 commit comments

Comments
 (0)