1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=8 sw=4 et tw=99:
3 : */
4 :
5 : #include "tests.h"
6 : #include "jsdbgapi.h"
7 :
8 : const char code[] =
9 : "xx = 1; \n\
10 : \n\
11 : try { \n\
12 : debugger; \n\
13 : \n\
14 : xx += 1; \n\
15 : } \n\
16 : catch (e) \n\
17 : { \n\
18 : xx += 1; \n\
19 : }\n\
20 : //@sourceMappingURL=http://example.com/path/to/source-map.json";
21 :
22 :
23 : static bool
24 1 : CharsMatch(const jschar *p, const char *q) {
25 44 : while (*q) {
26 42 : if (*p++ != *q++)
27 0 : return false;
28 : }
29 1 : return true;
30 : }
31 :
32 : // Bug 670958 - fix JS_GetScriptLineExtent, among others
33 4 : BEGIN_TEST(testScriptInfo)
34 : {
35 1 : unsigned startLine = 1000;
36 :
37 1 : JSScript *script = JS_CompileScript(cx, global, code, strlen(code), __FILE__, startLine);
38 :
39 1 : CHECK(script);
40 :
41 1 : jsbytecode *start = JS_LineNumberToPC(cx, script, startLine);
42 1 : CHECK_EQUAL(JS_GetScriptBaseLineNumber(cx, script), startLine);
43 1 : CHECK_EQUAL(JS_PCToLineNumber(cx, script, start), startLine);
44 1 : CHECK_EQUAL(JS_GetScriptLineExtent(cx, script), 10);
45 1 : CHECK(strcmp(JS_GetScriptFilename(cx, script), __FILE__) == 0);
46 1 : CHECK(CharsMatch(JS_GetScriptSourceMap(cx, script), "http://example.com/path/to/source-map.json"));
47 :
48 1 : return true;
49 : }
50 2 : END_TEST(testScriptInfo)
|