Bug 1408870 - Enable browser_jsterm_history_persist.js on the new console frontend; r=bgrins. draft
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Mon, 16 Oct 2017 18:18:32 +0200
changeset 681370 4af9df28f45455c341c11f4c8f87e4d735d52d30
parent 680795 5939b5f4b990f4daf7ca76381f164c75c2628315
child 681387 88e635cc71b4d870b1430fd9284e643b27969e41
push id84802
push userbmo:nchevobbe@mozilla.com
push dateTue, 17 Oct 2017 07:09:30 +0000
reviewersbgrins
bugs1408870
milestone58.0a1
Bug 1408870 - Enable browser_jsterm_history_persist.js on the new console frontend; r=bgrins. Cleaning jsterm history from previous test so it does not interfere with this one. Also clearing history at the beginning of the test so we are future-proof. MozReview-Commit-ID: 33OCfaSiskw
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_dollar.js
devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_persist.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -196,17 +196,16 @@ skip-if = true # Bug 1406060
 skip-if = true #	Bug 1403188
 # old console skip-if = e10s # Bug 1042253 - webconsole e10s tests
 [browser_jsterm_copy_command.js]
 skip-if = true
 subsuite = clipboard
 # old console skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
 [browser_jsterm_dollar.js]
 [browser_jsterm_history_persist.js]
-skip-if = true # Bug 1408870
 [browser_jsterm_inspect.js]
 [browser_jsterm_no_autocompletion_on_defined_variables.js]
 skip-if = true # Bug 1408872
 [browser_jsterm_no_input_and_tab_key_pressed.js]
 [browser_netmonitor_shows_reqs_in_webconsole.js]
 [browser_webconsole.js]
 skip-if = true #	Bug 1404829
 [browser_webconsole_No_input_change_and_Tab_key_pressed.js]
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_dollar.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_dollar.js
@@ -10,16 +10,19 @@
 
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "new-console-output/test/mochitest/test-jsterm-dollar.html";
 
 add_task(function* () {
   let hud = yield openNewTabAndConsole(TEST_URI);
   yield test$(hud);
   yield test$$(hud);
+
+  // Clear history to not affect next tests.
+  yield hud.jsterm.clearHistory();
 });
 
 async function test$(hud) {
   hud.jsterm.clearOutput();
   const msg = await hud.jsterm.execute("$(document.body)");
   ok(msg.textContent.includes("<p>"), "jsterm output is correct for $()");
 }
 
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_persist.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_history_persist.js
@@ -11,46 +11,45 @@
 requestLongerTimeout(2);
 
 const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " +
                  "persisting history - bug 943306";
 const INPUT_HISTORY_COUNT = 10;
 
 add_task(function* () {
   info("Setting custom input history pref to " + INPUT_HISTORY_COUNT);
-  Services.prefs.setIntPref("devtools.webconsole.inputHistoryCount",
-                            INPUT_HISTORY_COUNT);
+  Services.prefs.setIntPref("devtools.webconsole.inputHistoryCount", INPUT_HISTORY_COUNT);
 
   // First tab: run a bunch of commands and then make sure that you can
   // navigate through their history.
-  yield loadTab(TEST_URI);
-  let hud1 = yield openConsole();
-  is(JSON.stringify(hud1.jsterm.history), "[]",
-     "No history on first tab initially");
+  let hud1 = yield openNewTabAndConsole(TEST_URI);
+
+  // Clearing history that might have been set in previous tests.
+  yield hud1.jsterm.clearHistory();
+
+  is(JSON.stringify(hud1.jsterm.history), "[]", "No history on first tab initially");
   yield populateInputHistory(hud1);
   is(JSON.stringify(hud1.jsterm.history),
      '["0","1","2","3","4","5","6","7","8","9"]',
      "First tab has populated history");
 
   // Second tab: Just make sure that you can navigate through the history
   // generated by the first tab.
-  yield loadTab(TEST_URI);
-  let hud2 = yield openConsole();
+  let hud2 = yield openNewTabAndConsole(TEST_URI);
   is(JSON.stringify(hud2.jsterm.history),
      '["0","1","2","3","4","5","6","7","8","9"]',
      "Second tab has populated history");
-  yield testNaviatingHistoryInUI(hud2);
+  yield testNavigatingHistoryInUI(hud2);
   is(JSON.stringify(hud2.jsterm.history),
      '["0","1","2","3","4","5","6","7","8","9",""]',
      "An empty entry has been added in the second tab due to history perusal");
 
   // Third tab: Should have the same history as first tab, but if we run a
   // command, then the history of the first and second shouldn't be affected
-  yield loadTab(TEST_URI);
-  let hud3 = yield openConsole();
+  let hud3 = yield openNewTabAndConsole(TEST_URI);
   is(JSON.stringify(hud3.jsterm.history),
      '["0","1","2","3","4","5","6","7","8","9"]',
      "Third tab has populated history");
 
   // Set input value separately from execute so UP arrow accurately navigates
   // history.
   hud3.jsterm.setInputValue('"hello from third tab"');
   hud3.jsterm.execute();
@@ -63,28 +62,25 @@ add_task(function* () {
      "Second tab history hasn't changed due to command in third tab");
   is(JSON.stringify(hud3.jsterm.history),
      '["1","2","3","4","5","6","7","8","9","\\"hello from third tab\\""]',
      "Third tab has updated history (and purged the first result) after " +
      "running a command");
 
   // Fourth tab: Should have the latest command from the third tab, followed
   // by the rest of the history from the first tab.
-  yield loadTab(TEST_URI);
-  let hud4 = yield openConsole();
+  let hud4 = yield openNewTabAndConsole(TEST_URI);
   is(JSON.stringify(hud4.jsterm.history),
      '["1","2","3","4","5","6","7","8","9","\\"hello from third tab\\""]',
      "Fourth tab has most recent history");
 
   yield hud4.jsterm.clearHistory();
-  is(JSON.stringify(hud4.jsterm.history), "[]",
-     "Clearing history for a tab works");
+  is(JSON.stringify(hud4.jsterm.history), "[]", "Clearing history for a tab works");
 
-  yield loadTab(TEST_URI);
-  let hud5 = yield openConsole();
+  let hud5 = yield openNewTabAndConsole(TEST_URI);
   is(JSON.stringify(hud5.jsterm.history), "[]",
      "Clearing history carries over to a new tab");
 
   info("Clearing custom input history pref");
   Services.prefs.clearUserPref("devtools.webconsole.inputHistoryCount");
 });
 
 /**
@@ -93,25 +89,25 @@ add_task(function* () {
  */
 function* populateInputHistory(hud) {
   let jsterm = hud.jsterm;
 
   for (let i = 0; i < INPUT_HISTORY_COUNT; i++) {
     // Set input value separately from execute so UP arrow accurately navigates
     // history.
     jsterm.setInputValue(i);
-    jsterm.execute();
+    yield jsterm.execute();
   }
 }
 
 /**
  * Check pressing up results in history traversal like:
  *  [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
  */
-function* testNaviatingHistoryInUI(hud) {
+function testNavigatingHistoryInUI(hud) {
   let jsterm = hud.jsterm;
   jsterm.focus();
 
   // Count backwards from original input and make sure that pressing up
   // restores this.
   for (let i = INPUT_HISTORY_COUNT - 1; i >= 0; i--) {
     EventUtils.synthesizeKey("VK_UP", {});
     is(jsterm.getInputValue(), i, "Pressing up restores last input");