Bug 1400115 - Part 3: Add test. r?gl,pbro
MozReview-Commit-ID: LIpkVybR8GA
--- a/devtools/client/inspector/animation/moz.build
+++ b/devtools/client/inspector/animation/moz.build
@@ -1,11 +1,13 @@
# 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/.
DIRS += [
'components'
]
+BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
+
DevToolsModules(
'animation.js'
)
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/.eslintrc.js
@@ -0,0 +1,6 @@
+"use strict";
+
+module.exports = {
+ // Extend from the shared list of defined globals for mochitests.
+ "extends": "../../../../.eslintrc.mochitests.js"
+};
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/browser.ini
@@ -0,0 +1,12 @@
+[DEFAULT]
+tags = devtools
+subsuite = devtools
+support-files =
+ head.js
+ !/devtools/client/framework/test/shared-head.js
+ !/devtools/client/inspector/test/head.js
+ !/devtools/client/inspector/test/shared-head.js
+ !/devtools/client/shared/test/test-actor-registry.js
+ !/devtools/client/shared/test/test-actor.js
+
+[browser_animation_inspector_exists.js]
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/browser_animation_inspector_exists.js
@@ -0,0 +1,12 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test whether AnimationInspector and base pane exists.
+
+add_task(async function () {
+ const { animationInspector, panel } = await openAnimationInspector();
+ ok(animationInspector, "AnimationInspector should exist");
+ ok(panel, "Main animation-inspector panel should exist");
+});
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/head.js
@@ -0,0 +1,49 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint no-unused-vars: [2, {"vars": "local", "args": "none"}] */
+
+"use strict";
+
+/* import-globals-from ../../test/head.js */
+// Import the inspector's head.js first (which itself imports shared-head.js).
+Services.scriptloader.loadSubScript(
+ "chrome://mochitests/content/browser/devtools/client/inspector/test/head.js", this);
+
+const TAB_NAME = "newanimationinspector";
+
+// Enable new animation inspector.
+Services.prefs.setBoolPref("devtools.new-animationinspector.enabled", true);
+
+// Auto clean-up when a test ends.
+// Clean-up all prefs that might have been changed during a test run
+// (safer here because if the test fails, then the pref is never reverted)
+// Also, remove tested tab.
+registerCleanupFunction(() => {
+ Services.prefs.clearUserPref("devtools.new-animationinspector.enabled");
+ while (gBrowser.tabs.length > 1) {
+ gBrowser.removeCurrentTab();
+ }
+});
+
+/**
+ * Open the toolbox, with the inspector tool visible and the animationinspector
+ * sidebar selected.
+ *
+ * @return {Promise} that resolves when the inspector is ready.
+ */
+const openAnimationInspector = async function () {
+ const { inspector, toolbox } = await openInspectorSidebarTab(TAB_NAME);
+ const { animationinspector: animationInspector } = inspector;
+ const panel = inspector.panelWin.document.getElementById("animation-container");
+ return { toolbox, inspector, animationInspector, panel };
+};
+
+/**
+ * Close the toolbox.
+ *
+ * @return {Promise} that resolves when the toolbox has closed.
+ */
+const closeAnimationInspector = async function () {
+ const target = TargetFactory.forTab(gBrowser.selectedTab);
+ return gDevTools.closeToolbox(target);
+};