function beginFirefoxDownload()

in media/js/firefox/new/common/thanks-direct.es6.js [27:74]


function beginFirefoxDownload() {
    const directDownloadLink = document.getElementById('direct-download-link');
    let downloadURL;

    // Only auto-start the download if a supported platform is detected.
    if (
        Mozilla.DownloadThanks.shouldAutoDownload(
            window.site.platform,
            window.site.fxSupported
        ) &&
        typeof Mozilla.Utils !== 'undefined'
    ) {
        downloadURL = Mozilla.DownloadThanks.getDownloadURL(window.site);

        if (downloadURL) {
            // Pull download link from the download button and add to the 'Try downloading again' link.
            // Make sure the 'Try downloading again' link is well formatted! (issue 9615)
            if (directDownloadLink && directDownloadLink.href) {
                directDownloadLink.href = downloadURL;
                directDownloadLink.addEventListener(
                    'click',
                    (event) => {
                        try {
                            Mozilla.TrackProductDownload.handleLink(event);
                        } catch (error) {
                            return;
                        }
                    },
                    false
                );
            }

            // Start the platform-detected download a second after DOM ready event.
            Mozilla.Utils.onDocumentReady(() => {
                setTimeout(() => {
                    try {
                        Mozilla.TrackProductDownload.sendEventFromURL(
                            downloadURL
                        );
                    } catch (error) {
                        return;
                    }
                    window.location.href = downloadURL;
                }, 1000);
            });
        }
    }
}