diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /toolkit/mozapps/extensions/test/browser/browser_html_abuse_report_dialog.js | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions/test/browser/browser_html_abuse_report_dialog.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/browser/browser_html_abuse_report_dialog.js | 185 |
1 files changed, 0 insertions, 185 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_html_abuse_report_dialog.js b/toolkit/mozapps/extensions/test/browser/browser_html_abuse_report_dialog.js deleted file mode 100644 index 1efb28add3..0000000000 --- a/toolkit/mozapps/extensions/test/browser/browser_html_abuse_report_dialog.js +++ /dev/null @@ -1,185 +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/. */ -/* eslint max-len: ["error", 80] */ - -loadTestSubscript("head_abuse_report.js"); - -add_setup(async function () { - // Make sure the integrated abuse report panel is the one enabled - // while this test file runs (instead of the AMO hosted form). - // NOTE: behaviors expected when amoFormEnabled is true are tested - // in the separate browser_amo_abuse_report.js test file. - await SpecialPowers.pushPrefEnv({ - set: [["extensions.abuseReport.amoFormEnabled", false]], - }); - await AbuseReportTestUtils.setup(); -}); - -/** - * Test tasks specific to the abuse report opened in its own dialog window. - */ - -add_task(async function test_close_icon_button_hidden_when_dialog() { - const addonId = "addon-to-report@mochi.test"; - const extension = await installTestExtension(addonId); - - const reportDialog = await AbuseReporter.openDialog( - addonId, - "menu", - gBrowser.selectedBrowser - ); - await AbuseReportTestUtils.promiseReportDialogRendered(); - - const panelEl = await reportDialog.promiseReportPanel; - - let promiseClosedWindow = waitClosedWindow(); - - EventUtils.synthesizeKey("VK_RETURN", {}, panelEl.ownerGlobal); - AbuseReportTestUtils.triggerSubmit("fake-reason", "fake-message"); - - await promiseClosedWindow; - ok( - await reportDialog.promiseReport, - "expect the report to not be cancelled by pressing enter" - ); - - await extension.unload(); -}); - -add_task(async function test_report_triggered_when_report_dialog_is_open() { - const addonId = "addon-to-report@mochi.test"; - const extension = await installTestExtension(addonId); - - const reportDialog = await AbuseReporter.openDialog( - addonId, - "menu", - gBrowser.selectedBrowser - ); - await AbuseReportTestUtils.promiseReportDialogRendered(); - - let promiseClosedWindow = waitClosedWindow(); - - const reportDialog2 = await AbuseReporter.openDialog( - addonId, - "menu", - gBrowser.selectedBrowser - ); - - await promiseClosedWindow; - - // Trigger the report submit and check that the second report is - // resolved as expected. - await AbuseReportTestUtils.promiseReportDialogRendered(); - - ok( - !reportDialog.window || reportDialog.window.closed, - "expect the first dialog to be closed" - ); - ok(!!reportDialog2.window, "expect the second dialog to be open"); - - is( - reportDialog2.window, - AbuseReportTestUtils.getReportDialog(), - "Got a report dialog as expected" - ); - - AbuseReportTestUtils.triggerSubmit("fake-reason", "fake-message"); - - // promiseReport is resolved to undefined if the report has been - // cancelled, otherwise it is resolved to a report object. - ok( - !(await reportDialog.promiseReport), - "expect the first report to be cancelled" - ); - ok( - !!(await reportDialog2.promiseReport), - "expect the second report to be resolved" - ); - - await extension.unload(); -}); - -add_task(async function test_report_dialog_window_closed_by_user() { - const addonId = "addon-to-report@mochi.test"; - const extension = await installTestExtension(addonId); - - const reportDialog = await AbuseReporter.openDialog( - addonId, - "menu", - gBrowser.selectedBrowser - ); - await AbuseReportTestUtils.promiseReportDialogRendered(); - - let promiseClosedWindow = waitClosedWindow(); - - reportDialog.close(); - - await promiseClosedWindow; - - ok( - !(await reportDialog.promiseReport), - "expect promiseReport to be resolved as user cancelled" - ); - - await extension.unload(); -}); - -add_task(async function test_amo_details_for_not_installed_addon() { - const addonId = "not-installed-addon@mochi.test"; - const fakeAMODetails = { - name: "fake name", - current_version: { version: "1.0" }, - type: "extension", - icon_url: "http://test.addons.org/asserts/fake-icon-url.png", - homepage: "http://fake.url/homepage", - support_url: "http://fake.url/support", - authors: [ - { name: "author1", url: "http://fake.url/author1" }, - { name: "author2", url: "http://fake.url/author2" }, - ], - is_recommended: true, - }; - - AbuseReportTestUtils.amoAddonDetailsMap.set(addonId, fakeAMODetails); - registerCleanupFunction(() => - AbuseReportTestUtils.amoAddonDetailsMap.clear() - ); - - const reportDialog = await AbuseReporter.openDialog( - addonId, - "menu", - gBrowser.selectedBrowser - ); - - const reportEl = await reportDialog.promiseReportPanel; - - // Assert that the panel has been able to retrieve from AMO - // all the addon details needed to render the panel correctly. - is(reportEl.addonId, addonId, "Got the expected addonId"); - is(reportEl.addonName, fakeAMODetails.name, "Got the expected addon name"); - is(reportEl.addonType, fakeAMODetails.type, "Got the expected addon type"); - is( - reportEl.authorName, - fakeAMODetails.authors[0].name, - "Got the first author name as expected" - ); - is( - reportEl.authorURL, - fakeAMODetails.authors[0].url, - "Got the first author url as expected" - ); - is(reportEl.iconURL, fakeAMODetails.icon_url, "Got the expected icon url"); - is( - reportEl.supportURL, - fakeAMODetails.support_url, - "Got the expected support url" - ); - is( - reportEl.homepageURL, - fakeAMODetails.homepage, - "Got the expected homepage url" - ); - - reportDialog.close(); -}); |