1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 add_task(async function() {
6 // Throwing an error inside a JS callback in xpconnect should preserve
15 messagePattern: /unexpected token/,
21 throwError() { // line = 21
24 messagePattern: /is not defined/,
30 for (const test of tests) {
31 const { promise, resolve } = Promise.withResolvers();
34 if (msg instanceof Ci.nsIScriptError) {
41 Services.console.registerListener(listener);
44 const obs = Cc["@mozilla.org/observer-service;1"]
45 .getService(Ci.nsIObserverService);
46 obs.addObserver(test.throwError, "test-obs", false);
47 obs.notifyObservers(null, "test-obs");
50 const msg = await promise;
51 Assert.stringMatches(msg.errorMessage, test.messagePattern);
52 Assert.equal(msg.lineNumber, test.lineNumber);
53 Assert.equal(msg.columnNumber, test.columnNumber);
55 Services.console.unregisterListener(listener);