Bug 1473332 - Add a DAMP test for console autocomplete; r=ochameau. draft
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Thu, 05 Jul 2018 17:44:10 +0200
changeset 815537 4f347b67656ce7d07b3ffac8ab3b100fc972a9df
parent 815516 ffb7b5015fc331bdc4c5e6ab52b9de669faa8864
push id115537
push userbmo:nchevobbe@mozilla.com
push dateMon, 09 Jul 2018 08:54:16 +0000
reviewersochameau
bugs1473332
milestone63.0a1
Bug 1473332 - Add a DAMP test for console autocomplete; r=ochameau. MozReview-Commit-ID: 34PqIBot2ZK
testing/talos/talos/tests/devtools/addon/content/damp-tests.js
testing/talos/talos/tests/devtools/addon/content/tests/webconsole/autocomplete.js
--- a/testing/talos/talos/tests/devtools/addon/content/damp-tests.js
+++ b/testing/talos/talos/tests/devtools/addon/content/damp-tests.js
@@ -82,16 +82,20 @@ module.exports = [
     path: "debugger/custom.js"
   },
   // Run individual tests covering a very precise tool feature.
   {
     name: "console.bulklog",
     path: "webconsole/bulklog.js",
     description: "Measure time for a bunch of sync console.log statements to appear"
   }, {
+    name: "console.autocomplete",
+    path: "webconsole/autocomplete.js",
+    description: "Measure time for autocomplete popup to appear, be updated and closed"
+  }, {
     name: "console.streamlog",
     path: "webconsole/streamlog.js",
     description: "Measure rAF on page during a stream of console.log statements"
   }, {
     name: "console.objectexpand",
     path: "webconsole/objectexpand.js",
     description: "Measure time to expand a large object and close the console"
   }, {
new file mode 100644
--- /dev/null
+++ b/testing/talos/talos/tests/devtools/addon/content/tests/webconsole/autocomplete.js
@@ -0,0 +1,53 @@
+/* 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/. */
+
+"use strict";
+
+const {
+  openToolbox,
+  closeToolboxAndLog,
+  runTest,
+  testSetup,
+  testTeardown,
+} = require("../head");
+
+const TEST_NAME = "console.autocomplete";
+
+
+module.exports = async function() {
+  await testSetup(`data:text/html,<meta charset=utf8><script>
+    const items = Array.from({length: 100}).reduce((res, _, i) => ({
+      ...res,
+      ["item" + i.toString().padStart(2, "0")]: i
+    }), {});
+
+    /*
+     * Create an object with a null prototype in order to not have the autocomplete
+     * popup polluted by Object prototype methods.
+     */
+    window.autocompleteTest = Object.create(null,
+      Object.getOwnPropertyDescriptors(items));
+  </script>`);
+
+  const toolbox = await openToolbox("webconsole");
+  const { hud } = toolbox.getPanel("webconsole");
+  const { jsterm } = hud;
+  const { autocompletePopup } = jsterm;
+
+  const onPopUpOpened = autocompletePopup.once("popup-opened");
+
+  jsterm.setInputValue("window.autocompleteTest.");
+
+  const test = runTest(TEST_NAME);
+  // setInputValue does not trigger the autocompletion; we need to call `complete` in
+  // order to display the popup.
+  jsterm.complete(jsterm.COMPLETE_HINT_ONLY);
+  await onPopUpOpened;
+  test.done();
+
+  await closeToolboxAndLog(TEST_NAME, toolbox);
+  await testTeardown();
+};
+
+