Bug 1403454 - Migrate browser_webconsole_script_errordoc_urls.js to the new frontend r=jdescottes
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Tue, 13 Feb 2018 11:30:05 +0000
changeset 456107 17454f8c2ea8a1a600a95207b6856976178494a7
parent 456106 f7e2a78331801fd50fddc617fc08e422f7f5cf25
child 456108 26101dcb2ecee47b91637fb053f63c2412c59ad3
push id8799
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 16:46:23 +0000
treeherdermozilla-beta@15334014dc67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1403454
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1403454 - Migrate browser_webconsole_script_errordoc_urls.js to the new frontend r=jdescottes MozReview-Commit-ID: 6BBCqrmRelw
devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_script_errordoc_urls.js
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini
@@ -331,18 +331,16 @@ subsuite = clipboard
 [browser_webconsole_output_order.js]
 [browser_webconsole_persist.js]
 [browser_webconsole_reopen_closed_tab.js]
 [browser_webconsole_repeat_different_objects.js]
 [browser_webconsole_repeated_messages_accuracy.js]
 skip-if = true #	Bug 1403450
 [browser_webconsole_sandbox_update_after_navigation.js]
 [browser_webconsole_script_errordoc_urls.js]
-skip-if = true #	Bug 1403454
-# old console skip-if = e10s # Bug 1042253 - webconsole tests disabled with e10s
 [browser_webconsole_scroll.js]
 [browser_webconsole_select_all.js]
 [browser_webconsole_show_subresource_security_errors.js]
 [browser_webconsole_shows_reqs_in_netmonitor.js]
 [browser_webconsole_sourcemap_css.js]
 [browser_webconsole_sourcemap_error.js]
 [browser_webconsole_sourcemap_invalid.js]
 [browser_webconsole_sourcemap_nosource.js]
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_script_errordoc_urls.js
+++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_script_errordoc_urls.js
@@ -1,67 +1,72 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
+/* import-globals-from head.js */
+
 // Ensure that [Learn More] links appear alongside any errors listed
 // in "errordocs.js". Note: this only tests script execution.
 
 "use strict";
 
 const ErrorDocs = require("devtools/server/actors/errordocs");
+const TEST_URI = "data:text/html;charset=utf8,errordoc tests";
 
 function makeURIData(script) {
   return `data:text/html;charset=utf8,<script>${script}</script>`;
 }
 
 const TestData = [
   {
     jsmsg: "JSMSG_READ_ONLY",
     script: "'use strict'; (Object.freeze({name: 'Elsa', score: 157})).score = 0;",
     isException: true,
+    expected: 'TypeError: "score" is read-only',
   },
   {
     jsmsg: "JSMSG_STMT_AFTER_RETURN",
     script: "function a() { return; 1 + 1; };",
     isException: false,
+    expected: "unreachable code after return statement",
   }
 ];
 
-add_task(function* () {
-  yield loadTab("data:text/html;charset=utf8,errordoc tests");
+add_task(async function () {
+  let hud = await openNewTabAndConsole(TEST_URI);
 
-  let hud = yield openConsole();
-
-  for (let i = 0; i < TestData.length; i++) {
-    yield testScriptError(hud, TestData[i]);
+  for (let data of TestData) {
+    await testScriptError(hud, data);
   }
 });
 
-function* testScriptError(hud, testData) {
-  if (testData.isException === true) {
+async function testScriptError(hud, testData) {
+  let isE10s = Services.appinfo.browserTabsRemoteAutostart;
+  if (testData.isException && !isE10s) {
     expectUncaughtException();
   }
 
-  BrowserTestUtils.loadURI(gBrowser.selectedBrowser, makeURIData(testData.script));
+  await loadDocument(makeURIData(testData.script));
+
+  let msg = "the expected error message was displayed";
+  info(`waiting for ${msg} to be displayed`);
+  await waitFor(() => findMessage(hud, testData.expected));
+  ok(true, msg);
 
-  yield waitForMessages({
-    webconsole: hud,
-    messages: [
-      {
-        category: CATEGORY_JS
-      }
-    ]
-  });
+  // grab the most current error doc URL.
+  let urlObj = new URL(ErrorDocs.GetURL({ errorMessageName: testData.jsmsg }));
+
+  // strip all params from the URL.
+  let url = `${urlObj.origin}${urlObj.pathname}`;
 
-  // grab the most current error doc URL
-  let url = ErrorDocs.GetURL({ errorMessageName: testData.jsmsg });
-
-  let hrefs = {};
-  for (let link of hud.jsterm.outputNode.querySelectorAll("a")) {
-    hrefs[link.href] = true;
+  // Gather all URLs displayed in the console. [Learn More] links have no href
+  // but have the URL in the title attribute.
+  let hrefs = new Set();
+  for (let link of hud.ui.outputNode.querySelectorAll("a")) {
+    hrefs.add(link.title);
   }
 
-  ok(url in hrefs, `Expected a link to ${url}.`);
+  ok(hrefs.has(url), `Expected a link to ${url}.`);
 
   hud.jsterm.clearOutput();
 }