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/. */
7 // Because this function is used from SessionDataHelpers.jsm,
8 // this has to be a JSM.
10 var EXPORTED_SYMBOLS = ["validateBreakpointLocation"];
13 * Given a breakpoint location object, throws if the breakpoint look invalid
15 function validateBreakpointLocation({ sourceUrl, sourceId, line, column }) {
16 if (!sourceUrl && !sourceId) {
18 `Breakpoints expect to have either a sourceUrl or a sourceId.`
21 if (sourceUrl && typeof sourceUrl != "string") {
23 `Breakpoints expect to have sourceUrl string, got ${typeof sourceUrl} instead.`
26 // sourceId may be undefined for some sources keyed by URL
27 if (sourceId && typeof sourceId != "string") {
29 `Breakpoints expect to have sourceId string, got ${typeof sourceId} instead.`
32 if (typeof line != "number") {
34 `Breakpoints expect to have line number, got ${typeof line} instead.`
37 if (typeof column != "number") {
39 `Breakpoints expect to have column number, got ${typeof column} instead.`
44 // Allow this JSM to also be loaded as a CommonJS module
45 // Because this module is used from the worker thread,
46 // and workers can't load JSMs.
47 if (typeof module == "object") {
48 module.exports.validateBreakpointLocation = validateBreakpointLocation;