Bug 1400115 - Part 3: Add test. r?gl,pbro draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Tue, 17 Oct 2017 10:27:51 +0900
changeset 681130 ec19101c6fc27231f683ea55c6a06fc0417f9e1e
parent 681129 bde8f17a2f48d3e8245693410ded84b68fa1001e
child 681131 749c17ecca5e273e7e478f3018cc669a85a62e8a
push id84767
push userbmo:dakatsuka@mozilla.com
push dateTue, 17 Oct 2017 01:29:29 +0000
reviewersgl, pbro
bugs1400115
milestone58.0a1
Bug 1400115 - Part 3: Add test. r?gl,pbro MozReview-Commit-ID: LIpkVybR8GA
devtools/client/inspector/animation/moz.build
devtools/client/inspector/animation/test/.eslintrc.js
devtools/client/inspector/animation/test/browser.ini
devtools/client/inspector/animation/test/browser_animation_inspector_exists.js
devtools/client/inspector/animation/test/head.js
--- 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,7 @@
+[DEFAULT]
+tags = devtools
+subsuite = devtools
+support-files =
+  head.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,51 @@
+/* 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 ../../../inspector/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);
+
+// Enable new animation inspector.
+Services.prefs.setBoolPref("devtools.new-animationinspector.enabled", true);
+
+// Auto clean-up when a test ends
+registerCleanupFunction(async function () {
+  while (gBrowser.tabs.length > 1) {
+    gBrowser.removeCurrentTab();
+  }
+});
+
+// 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)
+registerCleanupFunction(() => {
+  Services.prefs.clearUserPref("devtools.new-animationinspector.enabled");
+});
+
+const TAB_NAME = "newanimationinspector";
+
+/**
+ * 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.querySelector("#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);
+};