tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_jsterm_error_docs.js (1435B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const TEST_URI = "data:text/html,<!DOCTYPE html>Test error documentation";
      7 
      8 add_task(async function () {
      9  const hud = await openNewTabAndConsole(TEST_URI);
     10 
     11  // Check that errors with entries in errordocs.js display links next to their messages.
     12  const ErrorDocs = require("resource://devtools/server/actors/errordocs.js");
     13 
     14  const ErrorDocStatements = {
     15    JSMSG_BAD_RADIX: "(42).toString(0);",
     16    JSMSG_BAD_ARRAY_LENGTH: "([]).length = -1",
     17    JSMSG_NEGATIVE_REPETITION_COUNT: "'abc'.repeat(-1);",
     18    JSMSG_PRECISION_RANGE: "77.1234.toExponential(-1);",
     19  };
     20 
     21  for (const [errorMessageName, expression] of Object.entries(
     22    ErrorDocStatements
     23  )) {
     24    const errorUrl = ErrorDocs.GetURL({ errorMessageName });
     25    const title = errorUrl.split("?")[0];
     26 
     27    await clearOutput(hud);
     28 
     29    const { node } = await executeAndWaitForErrorMessage(
     30      hud,
     31      expression,
     32      "RangeError:"
     33    );
     34    const learnMoreLink = node.querySelector(".learn-more-link");
     35    ok(
     36      learnMoreLink,
     37      `There is a [Learn More] link for "${errorMessageName}" error`
     38    );
     39    is(
     40      learnMoreLink.title,
     41      title,
     42      `The link has the expected "${title}" title`
     43    );
     44    is(
     45      learnMoreLink.href,
     46      errorUrl,
     47      `The link has the expected "${errorUrl}" href value`
     48    );
     49  }
     50 });