summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/client/debugger/src/test
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/src/test')
-rw-r--r--devtools/client/debugger/src/test/__mocks__/request-animation-frame.js10
-rw-r--r--devtools/client/debugger/src/test/__mocks__/styleMock.js7
-rw-r--r--devtools/client/debugger/src/test/__mocks__/svgMock.js7
-rw-r--r--devtools/client/debugger/src/test/fixtures/README.md3
-rw-r--r--devtools/client/debugger/src/test/fixtures/foobar.json56
-rw-r--r--devtools/client/debugger/src/test/fixtures/index.js3
-rw-r--r--devtools/client/debugger/src/test/shim.js16
-rw-r--r--devtools/client/debugger/src/test/tests-setup.js79
8 files changed, 181 insertions, 0 deletions
diff --git a/devtools/client/debugger/src/test/__mocks__/request-animation-frame.js b/devtools/client/debugger/src/test/__mocks__/request-animation-frame.js
new file mode 100644
index 0000000000..a656eaa91b
--- /dev/null
+++ b/devtools/client/debugger/src/test/__mocks__/request-animation-frame.js
@@ -0,0 +1,10 @@
+/* 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/>. */
+
+// @flow
+
+global.requestAnimationFrame = function(cb) {
+ cb();
+ return null;
+};
diff --git a/devtools/client/debugger/src/test/__mocks__/styleMock.js b/devtools/client/debugger/src/test/__mocks__/styleMock.js
new file mode 100644
index 0000000000..4bc9e41135
--- /dev/null
+++ b/devtools/client/debugger/src/test/__mocks__/styleMock.js
@@ -0,0 +1,7 @@
+/* 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/>. */
+
+// @flow
+
+module.exports = {};
diff --git a/devtools/client/debugger/src/test/__mocks__/svgMock.js b/devtools/client/debugger/src/test/__mocks__/svgMock.js
new file mode 100644
index 0000000000..3fe0d5e6c8
--- /dev/null
+++ b/devtools/client/debugger/src/test/__mocks__/svgMock.js
@@ -0,0 +1,7 @@
+/* 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/>. */
+
+// @flow
+
+module.exports = "<svg></svg>";
diff --git a/devtools/client/debugger/src/test/fixtures/README.md b/devtools/client/debugger/src/test/fixtures/README.md
new file mode 100644
index 0000000000..ea907643e3
--- /dev/null
+++ b/devtools/client/debugger/src/test/fixtures/README.md
@@ -0,0 +1,3 @@
+## Fixtures
+
+Fixtures used for unit tests
diff --git a/devtools/client/debugger/src/test/fixtures/foobar.json b/devtools/client/debugger/src/test/fixtures/foobar.json
new file mode 100644
index 0000000000..f225bf1f7a
--- /dev/null
+++ b/devtools/client/debugger/src/test/fixtures/foobar.json
@@ -0,0 +1,56 @@
+{
+ "sources": {
+ "sources": {
+ "fooSourceActor": {
+ "id": "fooSourceActor",
+ "url": "http://example.com/foo/foo.js",
+ "filename": "foo.js",
+ "pathname": "foo/foo.js"
+ },
+ "barSourceActor": {
+ "id": "barSourceActor",
+ "url": "http://example.com/bar/bar.js",
+ "filename": "bar.js",
+ "pathname": "bar/bar.js"
+ },
+ "bazzSourceActor": {
+ "id": "bazzSourceActor",
+ "url": "http://example.com/bazz/bazz.js",
+ "filename": "bazz.js",
+ "pathname": "bazz/bazz.js"
+ }
+ },
+ "sourcesText": {
+ "fooSourceActor": {
+ "contentType": "text/javascript",
+ "text": "function() {\n return foo;\n}"
+ },
+ "barSourceActor": {
+ "contentType": "text/javascript",
+ "text": "function() {\n return bar;\n}"
+ },
+ "bazzSourceActor": {
+ "contentType": "text/javascript",
+ "text": "function() {\n return bazz;\n}"
+ }
+ }
+ },
+ "breakpoints": {
+ "breakpoints": {
+ "fooBreakpointActor": {
+ "id": "fooBreakpointActor",
+ "location": {
+ "sourceId": "fooSourceActor",
+ "line": 16
+ }
+ },
+ "barBreakpointActor": {
+ "id": "barBreakpointActor",
+ "location": {
+ "sourceId": "barSourceActor",
+ "line": 18
+ }
+ }
+ }
+ }
+}
diff --git a/devtools/client/debugger/src/test/fixtures/index.js b/devtools/client/debugger/src/test/fixtures/index.js
new file mode 100644
index 0000000000..a0efc568b0
--- /dev/null
+++ b/devtools/client/debugger/src/test/fixtures/index.js
@@ -0,0 +1,3 @@
+import foobarJson from "./foobar.json";
+
+export const foobar = foobarJson;
diff --git a/devtools/client/debugger/src/test/shim.js b/devtools/client/debugger/src/test/shim.js
new file mode 100644
index 0000000000..3aadaefe0a
--- /dev/null
+++ b/devtools/client/debugger/src/test/shim.js
@@ -0,0 +1,16 @@
+/* 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/>. */
+
+const {
+ setMocksInGlobal,
+} = require("devtools/client/shared/test-helpers/shared-node-helpers");
+setMocksInGlobal();
+
+const { LocalizationHelper } = require("devtools/shared/l10n");
+global.L10N = new LocalizationHelper(
+ "devtools/client/locales/debugger.properties"
+);
+
+const { URL } = require("url");
+global.URL = URL;
diff --git a/devtools/client/debugger/src/test/tests-setup.js b/devtools/client/debugger/src/test/tests-setup.js
new file mode 100644
index 0000000000..689b5ac9b6
--- /dev/null
+++ b/devtools/client/debugger/src/test/tests-setup.js
@@ -0,0 +1,79 @@
+/* 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/>. */
+
+// @flow
+
+// $FlowIgnore
+global.Worker = require("workerjs");
+
+import path from "path";
+import Enzyme from "enzyme";
+// $FlowIgnore
+import Adapter from "enzyme-adapter-react-16";
+import { setupHelper } from "../utils/dbg";
+import { prefs } from "../utils/prefs";
+
+import { startSourceMapWorker, stopSourceMapWorker } from "devtools-source-map";
+
+import {
+ start as startPrettyPrintWorker,
+ stop as stopPrettyPrintWorker,
+} from "../workers/pretty-print";
+
+import { ParserDispatcher } from "../workers/parser";
+import {
+ start as startSearchWorker,
+ stop as stopSearchWorker,
+} from "../workers/search";
+import { clearDocuments } from "../utils/editor";
+
+const rootPath = path.join(__dirname, "../../");
+
+Enzyme.configure({ adapter: new Adapter() });
+
+global.jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
+
+function formatException(reason, p) {
+ console && console.log("Unhandled Rejection at:", p, "reason:", reason);
+}
+
+export const parserWorker = new ParserDispatcher();
+export const evaluationsParser = new ParserDispatcher();
+
+beforeAll(() => {
+ startSourceMapWorker(
+ path.join(rootPath, "node_modules/devtools-source-map/src/worker.js"),
+ ""
+ );
+ startPrettyPrintWorker(
+ path.join(rootPath, "src/workers/pretty-print/worker.js")
+ );
+ parserWorker.start(path.join(rootPath, "src/workers/parser/worker.js"));
+ evaluationsParser.start(path.join(rootPath, "src/workers/parser/worker.js"));
+ startSearchWorker(path.join(rootPath, "src/workers/search/worker.js"));
+ process.on("unhandledRejection", formatException);
+});
+
+afterAll(() => {
+ stopSourceMapWorker();
+ stopPrettyPrintWorker();
+ parserWorker.stop();
+ evaluationsParser.stop();
+ stopSearchWorker();
+ process.removeListener("unhandledRejection", formatException);
+});
+
+afterEach(() => {});
+
+beforeEach(async () => {
+ parserWorker.clear();
+ evaluationsParser.clear();
+ clearDocuments();
+ prefs.projectDirectoryRoot = "";
+ prefs.projectDirectoryRootName = "";
+ prefs.expressions = [];
+
+ // Ensures window.dbg is there to track telemetry
+ setupHelper({ selectors: {} });
+});