Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/xpconnect/tests/unit/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  test_error_to_exception.js   Sprache: JAVA

 
/* 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/. */


add_task(async function() {
  // Throwing an error inside a JS callback in xpconnect should preserve
  // the columnNumber.

  const tests = [
    // Parser error.
    {
      throwError() {
        eval("a b");
      },
      messagePattern: /unexpected token/,
      lineNumber: 1,
      columnNumber: 3,
    },
    // Runtime error.
    {
      throwError() { // line = 21
        not_found();
      },
      messagePattern: /is not defined/,
      lineNumber: 22,
      columnNumber: 9,
    },
  ];

  for (const test of tests) {
    const { promise, resolve } = Promise.withResolvers();
    const listener = {
      observe(msg) {
        if (msg instanceof Ci.nsIScriptError) {
          resolve(msg);
        }
      }
    };

    try {
      Services.console.registerListener(listener);

      try {
        const obs = Cc["@mozilla.org/observer-service;1"]
              .getService(Ci.nsIObserverService);
        obs.addObserver(test.throwError, "test-obs"false);
        obs.notifyObservers(null"test-obs");
      } catch {}

      const msg = await promise;
      Assert.stringMatches(msg.errorMessage, test.messagePattern);
      Assert.equal(msg.lineNumber, test.lineNumber);
      Assert.equal(msg.columnNumber, test.columnNumber);
    } finally {
      Services.console.unregisterListener(listener);
    }
  }
});

Messung V0.5
C=73 H=98 G=86

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.