michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "js/OldDebugAPI.h" michael@0: #include "jsapi-tests/tests.h" michael@0: michael@0: const char code[] = michael@0: "xx = 1; \n\ michael@0: \n\ michael@0: try { \n\ michael@0: debugger; \n\ michael@0: \n\ michael@0: xx += 1; \n\ michael@0: } \n\ michael@0: catch (e) \n\ michael@0: { \n\ michael@0: xx += 1; \n\ michael@0: }\n\ michael@0: //@ sourceMappingURL=http://example.com/path/to/source-map.json"; michael@0: michael@0: // Bug 670958 - fix JS_GetScriptLineExtent, among others michael@0: BEGIN_TEST(testScriptInfo) michael@0: { michael@0: unsigned startLine = 1000; michael@0: michael@0: JS::CompileOptions options(cx); michael@0: options.setFileAndLine(__FILE__, startLine); michael@0: JS::RootedScript script(cx, JS_CompileScript(cx, global, code, strlen(code), michael@0: options)); michael@0: michael@0: CHECK(script); michael@0: michael@0: jsbytecode *start = JS_LineNumberToPC(cx, script, startLine); michael@0: CHECK_EQUAL(JS_GetScriptBaseLineNumber(cx, script), startLine); michael@0: CHECK_EQUAL(JS_PCToLineNumber(cx, script, start), startLine); michael@0: CHECK_EQUAL(JS_GetScriptLineExtent(cx, script), 11); michael@0: CHECK(strcmp(JS_GetScriptFilename(script), __FILE__) == 0); michael@0: const jschar *sourceMap = JS_GetScriptSourceMap(cx, script); michael@0: CHECK(sourceMap); michael@0: CHECK(CharsMatch(sourceMap, "http://example.com/path/to/source-map.json")); michael@0: michael@0: return true; michael@0: } michael@0: static bool michael@0: CharsMatch(const jschar *p, const char *q) michael@0: { michael@0: while (*q) { michael@0: if (*p++ != *q++) michael@0: return false; michael@0: } michael@0: return true; michael@0: } michael@0: END_TEST(testScriptInfo)