From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- devtools/client/application/README.md | 334 ++ devtools/client/application/application.css | 36 + devtools/client/application/index.html | 22 + devtools/client/application/initializer.js | 150 + devtools/client/application/moz.build | 13 + devtools/client/application/panel.js | 46 + devtools/client/application/src/actions/index.js | 12 + .../client/application/src/actions/manifest.js | 50 + devtools/client/application/src/actions/moz.build | 11 + devtools/client/application/src/actions/page.js | 20 + devtools/client/application/src/actions/ui.js | 20 + devtools/client/application/src/actions/workers.js | 51 + devtools/client/application/src/base.css | 83 + devtools/client/application/src/components/App.css | 34 + devtools/client/application/src/components/App.js | 46 + .../src/components/manifest/Manifest.js | 136 + .../src/components/manifest/ManifestColorItem.css | 29 + .../src/components/manifest/ManifestColorItem.js | 57 + .../src/components/manifest/ManifestEmpty.js | 81 + .../src/components/manifest/ManifestIconItem.css | 7 + .../src/components/manifest/ManifestIconItem.js | 98 + .../src/components/manifest/ManifestIssue.css | 17 + .../src/components/manifest/ManifestIssue.js | 72 + .../src/components/manifest/ManifestIssueList.css | 15 + .../src/components/manifest/ManifestIssueList.js | 68 + .../src/components/manifest/ManifestItem.css | 28 + .../src/components/manifest/ManifestItem.js | 50 + .../src/components/manifest/ManifestJsonLink.css | 9 + .../src/components/manifest/ManifestJsonLink.js | 67 + .../src/components/manifest/ManifestLoader.css | 14 + .../src/components/manifest/ManifestLoader.js | 108 + .../src/components/manifest/ManifestPage.js | 76 + .../src/components/manifest/ManifestSection.css | 25 + .../src/components/manifest/ManifestSection.js | 44 + .../src/components/manifest/ManifestUrlItem.css | 8 + .../src/components/manifest/ManifestUrlItem.js | 39 + .../application/src/components/manifest/moz.build | 18 + .../client/application/src/components/moz.build | 14 + .../src/components/routing/PageSwitcher.css | 45 + .../src/components/routing/PageSwitcher.js | 59 + .../application/src/components/routing/Sidebar.css | 33 + .../application/src/components/routing/Sidebar.js | 70 + .../src/components/routing/SidebarItem.css | 33 + .../src/components/routing/SidebarItem.js | 95 + .../application/src/components/routing/moz.build | 5 + .../components/service-workers/Registration.css | 73 + .../src/components/service-workers/Registration.js | 153 + .../service-workers/RegistrationList.css | 54 + .../components/service-workers/RegistrationList.js | 92 + .../service-workers/RegistrationListEmpty.js | 122 + .../src/components/service-workers/Worker.css | 75 + .../src/components/service-workers/Worker.js | 225 ++ .../src/components/service-workers/WorkersPage.js | 71 + .../src/components/service-workers/moz.build | 11 + .../application/src/components/ui/UIButton.css | 75 + .../application/src/components/ui/UIButton.js | 41 + .../client/application/src/components/ui/moz.build | 7 + devtools/client/application/src/constants.js | 61 + devtools/client/application/src/create-store.js | 50 + .../application/src/middleware/event-telemetry.js | 37 + .../client/application/src/middleware/moz.build | 7 + .../src/modules/application-services.js | 85 + devtools/client/application/src/modules/l10n.js | 12 + devtools/client/application/src/modules/moz.build | 8 + devtools/client/application/src/moz.build | 17 + devtools/client/application/src/reducers/index.js | 28 + .../application/src/reducers/manifest-state.js | 158 + devtools/client/application/src/reducers/moz.build | 11 + .../client/application/src/reducers/page-state.js | 39 + .../client/application/src/reducers/ui-state.js | 30 + .../application/src/reducers/workers-state.js | 65 + devtools/client/application/src/types/index.js | 18 + devtools/client/application/src/types/manifest.js | 89 + devtools/client/application/src/types/moz.build | 10 + devtools/client/application/src/types/routing.js | 16 + .../application/src/types/service-workers.js | 35 + .../client/application/test/browser/browser.ini | 80 + ...owser_application_panel_debug-service-worker.js | 61 + ...rowser_application_panel_list-domain-workers.js | 70 + ...anel_list-multiple-workers-same-registration.js | 64 + ...owser_application_panel_list-several-workers.js | 54 + ...browser_application_panel_list-single-worker.js | 64 + .../browser_application_panel_list-unicode.js | 47 + ...browser_application_panel_list-workers-empty.js | 29 + .../browser_application_panel_manifest-display.js | 145 + .../browser_application_panel_manifest-load.js | 67 + ...browser_application_panel_manifest-open-json.js | 67 + .../browser_application_panel_manifest-reload.js | 51 + .../browser_application_panel_open-links.js | 48 + .../browser/browser_application_panel_sidebar.js | 82 + ...owser_application_panel_start-service-worker.js | 54 + .../browser_application_panel_target-switching.js | 68 + ...ser_application_panel_telemetry-debug-worker.js | 49 + ...wser_application_panel_telemetry-select-page.js | 26 + ...ser_application_panel_telemetry-start-worker.js | 45 + ...pplication_panel_telemetry-unregister-worker.js | 37 + .../browser_application_panel_unregister-worker.js | 36 + ..._application_panel_viewsource-service-worker.js | 50 + .../browser_application_panel_worker-states.js | 62 + devtools/client/application/test/browser/head.js | 134 + .../test/browser/resources/manifest/icon.svg | 4 + .../test/browser/resources/manifest/load-fail.html | 9 + .../resources/manifest/load-no-manifest.html | 8 + .../browser/resources/manifest/load-ok-icons.html | 9 + .../resources/manifest/load-ok-json-error.html | 10 + .../resources/manifest/load-ok-manifest-link.html | 9 + .../resources/manifest/load-ok-warnings.html | 10 + .../test/browser/resources/manifest/load-ok.html | 9 + .../test/browser/resources/manifest/manifest.json | 3 + .../service-workers/controlled-install-sw.js | 29 + .../service-workers/controlled-install.html | 27 + .../browser/resources/service-workers/debug-sw.js | 18 + .../browser/resources/service-workers/debug.html | 25 + .../service-workers/dynamic-registration.html | 19 + .../browser/resources/service-workers/empty-sw.js | 4 + .../browser/resources/service-workers/empty.html | 11 + .../resources/service-workers/scope-page.html | 19 + .../resources/service-workers/simple-unicode.html | 15 + .../browser/resources/service-workers/simple.html | 32 + devtools/client/application/test/node/.eslintrc.js | 10 + .../actions_application_panel-manifest.test.js | 83 + .../client/application/test/node/babel.config.js | 8 + .../components_application_panel-App.test.js.snap | 12 + .../components_application_panel-App.test.js | 26 + ...ponents_application_panel-Manifest.test.js.snap | 396 +++ ...pplication_panel-ManifestColorItem.test.js.snap | 58 + ...ts_application_panel-ManifestEmpty.test.js.snap | 46 + ...application_panel-ManifestIconItem.test.js.snap | 106 + ...ts_application_panel-ManifestIssue.test.js.snap | 49 + ...pplication_panel-ManifestIssueList.test.js.snap | 89 + ...nts_application_panel-ManifestItem.test.js.snap | 35 + ...application_panel-ManifestJsonLink.test.js.snap | 26 + ...s_application_panel-ManifestLoader.test.js.snap | 50 + ...nts_application_panel-ManifestPage.test.js.snap | 80 + ..._application_panel-ManifestSection.test.js.snap | 30 + ..._application_panel-ManifestUrlItem.test.js.snap | 21 + .../components_application_panel-Manifest.test.js | 73 + ...nts_application_panel-ManifestColorItem.test.js | 48 + ...ponents_application_panel-ManifestEmpty.test.js | 23 + ...ents_application_panel-ManifestIconItem.test.js | 48 + ...ponents_application_panel-ManifestIssue.test.js | 30 + ...nts_application_panel-ManifestIssueList.test.js | 59 + ...mponents_application_panel-ManifestItem.test.js | 28 + ...ents_application_panel-ManifestJsonLink.test.js | 36 + ...onents_application_panel-ManifestLoader.test.js | 82 + ...mponents_application_panel-ManifestPage.test.js | 59 + ...nents_application_panel-ManifestSection.test.js | 34 + ...nents_application_panel-ManifestUrlItem.test.js | 30 + ...nts_application_panel-PageSwitcher.test.js.snap | 9 + ...mponents_application_panel-Sidebar.test.js.snap | 64 + ...ents_application_panel-SidebarItem.test.js.snap | 141 + ...mponents_application_panel-PageSwitcher.test.js | 73 + .../components_application_panel-Sidebar.test.js | 51 + ...omponents_application_panel-SidebarItem.test.js | 82 + ...nts_application_panel-Registration.test.js.snap | 180 + ...application_panel-RegistrationList.test.js.snap | 159 + ...cation_panel-RegistrationListEmpty.test.js.snap | 66 + ...omponents_application_panel-Worker.test.js.snap | 132 + ...ents_application_panel-WorkersPage.test.js.snap | 143 + ...mponents_application_panel-Registration.test.js | 88 + ...ents_application_panel-RegistrationList.test.js | 43 + ...application_panel-RegistrationListEmpty.test.js | 23 + .../components_application_panel-Worker.test.js | 110 + ...omponents_application_panel-WorkersPage.test.js | 82 + .../test/node/fixtures/data/constants.js | 312 ++ devtools/client/application/test/node/helpers.js | 31 + .../client/application/test/node/jest.config.js | 14 + devtools/client/application/test/node/package.json | 25 + devtools/client/application/test/node/setup.js | 15 + devtools/client/application/test/node/yarn.lock | 3563 ++++++++++++++++++++ .../client/application/test/xpcshell/.eslintrc.js | 6 + .../test/xpcshell/test_manifest_reducer.js | 201 ++ .../application/test/xpcshell/test_page_reducer.js | 22 + .../application/test/xpcshell/test_ui_reducer.js | 22 + .../test/xpcshell/test_workers_reducer.js | 115 + .../application/test/xpcshell/xpcshell-head.js | 10 + .../client/application/test/xpcshell/xpcshell.ini | 10 + 177 files changed, 13350 insertions(+) create mode 100644 devtools/client/application/README.md create mode 100644 devtools/client/application/application.css create mode 100644 devtools/client/application/index.html create mode 100644 devtools/client/application/initializer.js create mode 100644 devtools/client/application/moz.build create mode 100644 devtools/client/application/panel.js create mode 100644 devtools/client/application/src/actions/index.js create mode 100644 devtools/client/application/src/actions/manifest.js create mode 100644 devtools/client/application/src/actions/moz.build create mode 100644 devtools/client/application/src/actions/page.js create mode 100644 devtools/client/application/src/actions/ui.js create mode 100644 devtools/client/application/src/actions/workers.js create mode 100644 devtools/client/application/src/base.css create mode 100644 devtools/client/application/src/components/App.css create mode 100644 devtools/client/application/src/components/App.js create mode 100644 devtools/client/application/src/components/manifest/Manifest.js create mode 100644 devtools/client/application/src/components/manifest/ManifestColorItem.css create mode 100644 devtools/client/application/src/components/manifest/ManifestColorItem.js create mode 100644 devtools/client/application/src/components/manifest/ManifestEmpty.js create mode 100644 devtools/client/application/src/components/manifest/ManifestIconItem.css create mode 100644 devtools/client/application/src/components/manifest/ManifestIconItem.js create mode 100644 devtools/client/application/src/components/manifest/ManifestIssue.css create mode 100644 devtools/client/application/src/components/manifest/ManifestIssue.js create mode 100644 devtools/client/application/src/components/manifest/ManifestIssueList.css create mode 100644 devtools/client/application/src/components/manifest/ManifestIssueList.js create mode 100644 devtools/client/application/src/components/manifest/ManifestItem.css create mode 100644 devtools/client/application/src/components/manifest/ManifestItem.js create mode 100644 devtools/client/application/src/components/manifest/ManifestJsonLink.css create mode 100644 devtools/client/application/src/components/manifest/ManifestJsonLink.js create mode 100644 devtools/client/application/src/components/manifest/ManifestLoader.css create mode 100644 devtools/client/application/src/components/manifest/ManifestLoader.js create mode 100644 devtools/client/application/src/components/manifest/ManifestPage.js create mode 100644 devtools/client/application/src/components/manifest/ManifestSection.css create mode 100644 devtools/client/application/src/components/manifest/ManifestSection.js create mode 100644 devtools/client/application/src/components/manifest/ManifestUrlItem.css create mode 100644 devtools/client/application/src/components/manifest/ManifestUrlItem.js create mode 100644 devtools/client/application/src/components/manifest/moz.build create mode 100644 devtools/client/application/src/components/moz.build create mode 100644 devtools/client/application/src/components/routing/PageSwitcher.css create mode 100644 devtools/client/application/src/components/routing/PageSwitcher.js create mode 100644 devtools/client/application/src/components/routing/Sidebar.css create mode 100644 devtools/client/application/src/components/routing/Sidebar.js create mode 100644 devtools/client/application/src/components/routing/SidebarItem.css create mode 100644 devtools/client/application/src/components/routing/SidebarItem.js create mode 100644 devtools/client/application/src/components/routing/moz.build create mode 100644 devtools/client/application/src/components/service-workers/Registration.css create mode 100644 devtools/client/application/src/components/service-workers/Registration.js create mode 100644 devtools/client/application/src/components/service-workers/RegistrationList.css create mode 100644 devtools/client/application/src/components/service-workers/RegistrationList.js create mode 100644 devtools/client/application/src/components/service-workers/RegistrationListEmpty.js create mode 100644 devtools/client/application/src/components/service-workers/Worker.css create mode 100644 devtools/client/application/src/components/service-workers/Worker.js create mode 100644 devtools/client/application/src/components/service-workers/WorkersPage.js create mode 100644 devtools/client/application/src/components/service-workers/moz.build create mode 100644 devtools/client/application/src/components/ui/UIButton.css create mode 100644 devtools/client/application/src/components/ui/UIButton.js create mode 100644 devtools/client/application/src/components/ui/moz.build create mode 100644 devtools/client/application/src/constants.js create mode 100644 devtools/client/application/src/create-store.js create mode 100644 devtools/client/application/src/middleware/event-telemetry.js create mode 100644 devtools/client/application/src/middleware/moz.build create mode 100644 devtools/client/application/src/modules/application-services.js create mode 100644 devtools/client/application/src/modules/l10n.js create mode 100644 devtools/client/application/src/modules/moz.build create mode 100644 devtools/client/application/src/moz.build create mode 100644 devtools/client/application/src/reducers/index.js create mode 100644 devtools/client/application/src/reducers/manifest-state.js create mode 100644 devtools/client/application/src/reducers/moz.build create mode 100644 devtools/client/application/src/reducers/page-state.js create mode 100644 devtools/client/application/src/reducers/ui-state.js create mode 100644 devtools/client/application/src/reducers/workers-state.js create mode 100644 devtools/client/application/src/types/index.js create mode 100644 devtools/client/application/src/types/manifest.js create mode 100644 devtools/client/application/src/types/moz.build create mode 100644 devtools/client/application/src/types/routing.js create mode 100644 devtools/client/application/src/types/service-workers.js create mode 100644 devtools/client/application/test/browser/browser.ini create mode 100644 devtools/client/application/test/browser/browser_application_panel_debug-service-worker.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_list-domain-workers.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_list-multiple-workers-same-registration.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_list-several-workers.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_list-single-worker.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_list-unicode.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_list-workers-empty.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_manifest-display.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_manifest-load.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_manifest-open-json.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_manifest-reload.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_open-links.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_sidebar.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_start-service-worker.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_target-switching.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_telemetry-debug-worker.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_telemetry-select-page.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_telemetry-start-worker.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_telemetry-unregister-worker.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_unregister-worker.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_viewsource-service-worker.js create mode 100644 devtools/client/application/test/browser/browser_application_panel_worker-states.js create mode 100644 devtools/client/application/test/browser/head.js create mode 100644 devtools/client/application/test/browser/resources/manifest/icon.svg create mode 100644 devtools/client/application/test/browser/resources/manifest/load-fail.html create mode 100644 devtools/client/application/test/browser/resources/manifest/load-no-manifest.html create mode 100644 devtools/client/application/test/browser/resources/manifest/load-ok-icons.html create mode 100644 devtools/client/application/test/browser/resources/manifest/load-ok-json-error.html create mode 100644 devtools/client/application/test/browser/resources/manifest/load-ok-manifest-link.html create mode 100644 devtools/client/application/test/browser/resources/manifest/load-ok-warnings.html create mode 100644 devtools/client/application/test/browser/resources/manifest/load-ok.html create mode 100644 devtools/client/application/test/browser/resources/manifest/manifest.json create mode 100644 devtools/client/application/test/browser/resources/service-workers/controlled-install-sw.js create mode 100644 devtools/client/application/test/browser/resources/service-workers/controlled-install.html create mode 100644 devtools/client/application/test/browser/resources/service-workers/debug-sw.js create mode 100644 devtools/client/application/test/browser/resources/service-workers/debug.html create mode 100644 devtools/client/application/test/browser/resources/service-workers/dynamic-registration.html create mode 100644 devtools/client/application/test/browser/resources/service-workers/empty-sw.js create mode 100644 devtools/client/application/test/browser/resources/service-workers/empty.html create mode 100644 devtools/client/application/test/browser/resources/service-workers/scope-page.html create mode 100644 devtools/client/application/test/browser/resources/service-workers/simple-unicode.html create mode 100644 devtools/client/application/test/browser/resources/service-workers/simple.html create mode 100644 devtools/client/application/test/node/.eslintrc.js create mode 100644 devtools/client/application/test/node/actions/actions_application_panel-manifest.test.js create mode 100644 devtools/client/application/test/node/babel.config.js create mode 100644 devtools/client/application/test/node/components/__snapshots__/components_application_panel-App.test.js.snap create mode 100644 devtools/client/application/test/node/components/components_application_panel-App.test.js create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-Manifest.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestColorItem.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestEmpty.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestIconItem.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestIssue.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestIssueList.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestItem.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestJsonLink.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestLoader.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestPage.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestSection.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/__snapshots__/components_application_panel-ManifestUrlItem.test.js.snap create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-Manifest.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestColorItem.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestEmpty.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestIconItem.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestIssue.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestIssueList.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestItem.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestJsonLink.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestLoader.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestPage.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestSection.test.js create mode 100644 devtools/client/application/test/node/components/manifest/components_application_panel-ManifestUrlItem.test.js create mode 100644 devtools/client/application/test/node/components/routing/__snapshots__/components_application_panel-PageSwitcher.test.js.snap create mode 100644 devtools/client/application/test/node/components/routing/__snapshots__/components_application_panel-Sidebar.test.js.snap create mode 100644 devtools/client/application/test/node/components/routing/__snapshots__/components_application_panel-SidebarItem.test.js.snap create mode 100644 devtools/client/application/test/node/components/routing/components_application_panel-PageSwitcher.test.js create mode 100644 devtools/client/application/test/node/components/routing/components_application_panel-Sidebar.test.js create mode 100644 devtools/client/application/test/node/components/routing/components_application_panel-SidebarItem.test.js create mode 100644 devtools/client/application/test/node/components/service-workers/__snapshots__/components_application_panel-Registration.test.js.snap create mode 100644 devtools/client/application/test/node/components/service-workers/__snapshots__/components_application_panel-RegistrationList.test.js.snap create mode 100644 devtools/client/application/test/node/components/service-workers/__snapshots__/components_application_panel-RegistrationListEmpty.test.js.snap create mode 100644 devtools/client/application/test/node/components/service-workers/__snapshots__/components_application_panel-Worker.test.js.snap create mode 100644 devtools/client/application/test/node/components/service-workers/__snapshots__/components_application_panel-WorkersPage.test.js.snap create mode 100644 devtools/client/application/test/node/components/service-workers/components_application_panel-Registration.test.js create mode 100644 devtools/client/application/test/node/components/service-workers/components_application_panel-RegistrationList.test.js create mode 100644 devtools/client/application/test/node/components/service-workers/components_application_panel-RegistrationListEmpty.test.js create mode 100644 devtools/client/application/test/node/components/service-workers/components_application_panel-Worker.test.js create mode 100644 devtools/client/application/test/node/components/service-workers/components_application_panel-WorkersPage.test.js create mode 100644 devtools/client/application/test/node/fixtures/data/constants.js create mode 100644 devtools/client/application/test/node/helpers.js create mode 100644 devtools/client/application/test/node/jest.config.js create mode 100644 devtools/client/application/test/node/package.json create mode 100644 devtools/client/application/test/node/setup.js create mode 100644 devtools/client/application/test/node/yarn.lock create mode 100644 devtools/client/application/test/xpcshell/.eslintrc.js create mode 100644 devtools/client/application/test/xpcshell/test_manifest_reducer.js create mode 100644 devtools/client/application/test/xpcshell/test_page_reducer.js create mode 100644 devtools/client/application/test/xpcshell/test_ui_reducer.js create mode 100644 devtools/client/application/test/xpcshell/test_workers_reducer.js create mode 100644 devtools/client/application/test/xpcshell/xpcshell-head.js create mode 100644 devtools/client/application/test/xpcshell/xpcshell.ini (limited to 'devtools/client/application') diff --git a/devtools/client/application/README.md b/devtools/client/application/README.md new file mode 100644 index 0000000000..c7abb926f3 --- /dev/null +++ b/devtools/client/application/README.md @@ -0,0 +1,334 @@ +# Application + +## About the Application panel + +The Application panel is a Firefox Developer Tools panel meant to allow the inspection and debugging of features usually present in Progressive Web Apps, such as service workers or the Web App Manifest. + +## Technical overview + +The Application panel is a React + Redux web app. + +### Source directory structure + +The application panel lives in the `devtools/client/application` directory. Inside this root directory, the most relevant subdirectories and files are: + +``` +. +├── application.css -> root CSS stylesheet +├── initializer.js -> panel initialization +├── src +│ ├── actions -> Redux actions +│ ├── components -> React components +│ ├── modules -> Business logic and helpers +│ └── reducers -> Redux reducers and states +└── test + ├── browser -> mochitests (e2e/integration) + ├── node -> Jest unit tests + └── xpcshell -> xpcshell unit tests +``` + +### Panel registration + +The panel is defined in `devtools/client/application/panel.js` – which in turn calls the `.bootstrap()` method defined in `devtools/client/application/initializer.js`. + +The panel is registered along the rest of the Developer Tools panels, in `devtools/client/definitions.js`. + +### Localization + +The panel uses the [fluent-react](https://github.com/projectfluent/fluent.js/wiki/React-Bindings) library. The localization file is located at `devtools/client/locales/en-US/application.ftl` and it follows [Fluent syntax](https://projectfluent.org/fluent/guide/). + +You should read the [Fluent for Firefox developers](https://firefox-source-docs.mozilla.org/l10n/fluent/tutorial.html) and [Guidelines for Fluent Reviewers](https://firefox-source-docs.mozilla.org/intl/l10n/l10n/fluent_review.html) guides. + +#### Adding a new string + +If you need to localize a text, add a new message ID to the localization file (`devtoos/client/en-US/application.ftl`). Then you can use this ID as a prop for Fluent's `` component or `getString()` function. + +When using ID's from the React code, always write the full ID instead of building it with concatenation, interpolation, etc. (this makes localing ID's easier afterwards). For instance, let's say you have two ID's, `error-message` and `warning-message`, and you need to use one or the other depending on a condition. + +✅ **Do:** + +```js +const localizationIds = { + error: "error-message", + warning: "warning-message", +}; + +const id = localizationIds[messageLevel]; +``` + +❌ **Don't:** + +```js +const id = `${messageLevel}-message`; +``` + +#### Updating an existing string + +If you need to modify an existing string, you need to create a new ID and don't remove the previous one. For instance, if we had this string: + +``` +some-localized-string = This will be modified later +``` + +And we need to update the content, we would create a new ID and remove the previous one intact: + +```diff +- some-localized-string = This will be modified later ++ some-localized-string2 = This is the updated string +``` + +Within the React component code, you would use the newly created ID. + +```js +const localizedText = l10n.getString("some-localized-string2"); +``` + +### React components + +Components are located in the `devtools/client/application/src/components` directory. + +Each component has a single `.js` file, plus an optional `.css` file, so each component is responsible of handling their own styles. + +- The `App` component is the root component of the Application panel. +- In `components/service-workers` are the components that render all of the UI related to inspect and debug service workers. +- In `components/manifest` are the components that render everything related to inspecting a Web App Manifest. +- In the `components/routing` directory there are components related to switching from one section of the panel to the other, like a sidebar or a page switcher container. +- Inside the `components/ui` directory there are generic UI components that can be reused from other parts of the panel. + +### Redux + +The Application panel uses Redux to handle app state and communication between components. + +#### Substates + +The Redux state is set up in `devtools/client/application/src/create-store.js`. The state contains the following substates: + +- `workers`: contains data related to inspecting and debugging service workers. +- `manifest`: contains state related to inspecting the Web App Manifest. +- `page`: contains general data related to the web page that is being inspected. +- `ui`: contains data related to the UI that don't really fit any other state. + +#### Actions + +Synchronous actions are regular Redux actions. Their type is defined in the general constants file (`devtools/client/application/src/constants.js`). + +**Asynchronous** actions are achieved thanks to the **thunk middleware**. They follow a three-action pattern `*_START`, `*_SUCCESS`, `*_FAILURE`. For instance: + +```js +function fooAction() { + return async ({ dispatch, getState }) => { + dispatch({ type: FOO_START }); + + try { + const result = await foo(); + dispatch({ type: FOO_SUCCESS }); + } + catch (err) { + console.error(err); + dispatch({ type: FOO_FAILURE }); + } + } +} +``` + +#### Middleware + +We are using the following middlewares with Redux: + +- [redux-thunk](https://github.com/reduxjs/redux-thunk): This is a shared middleware used by other DevTools modules that allows to dispatch asynchronous actions. + +### Constants + +We are sharing some constants / enum-like constants across the source. They are located in `devtools/client/application/src/constants.js`. For values that are not shared, they should stay within their relevant scope/file. + +## Tests + +You should read DevTools' general [guidelines for automated tests](https://firefox-source-docs.mozilla.org/devtools/tests/README.html). + +### Mochitests (e2e / integration) + +End to end and integration tests are made with **Mochitests**. These tests open a browser and will load an HTML and open the toolbox with the Application panel. + +These tests are located in `devtools/client/application/test/browser`. + +Besides the usual DevTools test helpers, the Application panel adds some other helper functions in `devtools/client/application/test/browser/head.js` + +### Unit tests with xpcshell + +We are using xpcshell unit tests for the **Redux reducers** in `devtools/client/application/test/xpcshell`. + +Other unit tests that don't need Enzyme or other npm modules should be added here too. + +### Unit tests with Jest + +We are using Jest with Enzyme to test **React components** and **Redux actions** in `devtools/client/application/test/node`. Some considerations: + +- There are some **stubs/mocks** for some libraries and modules. These are placed in `devtools/client/application/test/node/fixtures`. +- The **localization system is mocked**. For `` components, the Enzyme snapshots will reflect the localization ID. Ex: ``. The actual localized string will not be rendered with `.shallow()`. Calls to `getstring()` will return the string ID that we pass as an argument. +- The **redux store is mocked** as well. To create a fake store to test a component that uses `connect()` to fetch data from the store, use the helper `setupStore()` included in `devtools/client/application/test/node/helpers.js`. + +#### Snapshots + +Most Jest tests will involve a snapshot matching expectation. + +**Snapshots should be produced with [`shallow()`](https://airbnb.io/enzyme/docs/api/shallow.html)** and _not_ `mount()`, to ensure that we are only testing the current component. + +**Components that are wrapped** with `connect()` or other wrapper components, need their snapshot to be rendered with [`dive()`](https://airbnb.io/enzyme/docs/api/ShallowWrapper/dive.html) (one call to `dive()` per wrapper component). + +## CSS + +We are using a BEM-like style for the following reasons: + +- To avoid collision between the styles of components. +- To have a consistent methodology on how to use CSS. +- To ensure we have rules with low specificity and thus styles are easier to override and maintain. + +### Stylesheet organization + +#### File structure + +**Each component has its own CSS stylesheet**, in the same directory and with the same name as the JavaScript file, only with a `.css` extension. So `Foo.js` would have a `Foo.css` stylesheet. + +These stylesheets are imported from `devtools/client/application/application.css` in alphabetical order –BEM-like naming and low specificity, when done right, should ensure that styles work regardless of the order the stylesheets are included. + +#### Base styles + +Another important stylesheet is `devtools/client/application/base.css`, which is the one that is imported first from `application.css`, regardless the alphabetical order. In this stylesheet we do: + +- Variables definitions +- Utility classes +- Some styles that are applied to the whole panel, like some resets or default values. + +#### External stylesheets imported in the panel + +Besides the usual user-agent styles, all DevTools panels automatically import the stylesheets located at `devtools/client/themes/`. The most relevant for the Application panel are: + +- `devtools/client/themes/variables.css`: variables are defined here +- `devtools/client/themes/common.css`: rules that are applied to every panel + +In the Application panel, we are not using some of the classes and rules defined in `common.css`, since they don't follow the BEM convention and some of them have high specificity. However, there are rules defined at the element level and this will get applied to the markup we use. + +From `variables.css`, at the moment we mainly use color names. See the section below for details. Other variables available there that contain values for common elements (like heights, widths, etc.) should also be used when we implement those components. + +### Colors and themes + +All DevTools panels should support both **light and dark themes**. The active theme can be changed by the user at DevTools Settings. + +The way this is handled is that a `.theme-light` or `.theme-dark` class is automatically added to the root `` element of each panel. Then, in `variables.css`, there are some CSS variables with different values depending on which of those classes the root element has. + +- We should use the colors defined in `variables.css`. +- If the other panels are using a particular color for an element we also have, we should re-use the same color. +- If needed, we can create a CSS variable in `base.css` that takes the value of another color variable defined in `variables.css` +- If the desired color is not available in `variables.css`, we can create a new one, but we have to define values for both light and dark themes. + +#### Writing CSS selectors + +As mentioned earlier, we are using a system to create rules similar to [BEM](http://getbem.com/naming/), although not strictly identical. + +#### Low specificity rules + +Rules should have **the lowest specifity** that is possible. In practice, this means that we should try to use a **single class selector** for writing the rule. Ex: + +```css +.manifest-item { + /* ... */ +} +``` + +Note that **pseudoclasses are pseudoselectors are OK** to use. + +#### Hierarchy + +When an element is semantically the child of another element, we should also use a single class selector. In BEM, this is achieved by separating potential class names with a double underscore `__`, so we have a single classname. + +✅ **Do:** + +```css +.manifest-item { /* ... */ } +.manifest-item__value { /* ... */ } +``` + +❌ **Don't:** + +```css +.manifest-item { /* ... */ } +.manifest-item .value { /* ... */ } +``` + +We should not go deeper than one level of `__`. We don't have to replicate the whole DOM structure: + +- If the style rule should be independent of the parent, it does not need to use an `__`. +- If the style rule does not make sense on its own, and it will be scoped to a particular section of the DOM tree, don't replicate the whole DOM structure and use the top-level ancestor class name instead. + +For instance, if we have the following HTML markup and we have to choose a class name for the `
` element: + +```html +
  • +
    +
    + +``` + +✅ **Do:** + +```css +.worker__meta-name { /* ... */ } +``` + +❌ **Don't:** + +```css +.worker__data__meta-name { /* ... */ } +``` + +#### Style variations + +Sometimes we have a component that should change its style depending on its state, or we have some rules that allow us to customize further how something looks. For instance, we could have a generic rule for buttons, and then some extra rules for primary buttons, or for tiny ones. + +In BEM, style variants are created with a double hyphen `--`. For example: + +```css +.ui-button { /* styles for buttons */ } +.ui-button--micro { /* specific styles for tiny buttons */ } +``` + +Then, in the component, _both_ classes are to be used. + +```html +