1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "mozilla/Utf8.h" // mozilla::Utf8Unit
12 #include "js/CompilationAndEvaluation.h" // JS::Compile
13 #include "js/SourceText.h" // JS::Source{Ownership,Text}
14 #include "jsapi-tests/tests.h"
15 #include "util/Text.h"
17 static const char code
[] =
29 //@ sourceMappingURL=http://example.com/path/to/source-map.json";
31 BEGIN_TEST(testScriptInfo
) {
32 unsigned startLine
= 1000;
34 JS::CompileOptions
options(cx
);
35 options
.setFileAndLine(__FILE__
, startLine
);
37 JS::SourceText
<mozilla::Utf8Unit
> srcBuf
;
38 CHECK(srcBuf
.init(cx
, code
, js_strlen(code
), JS::SourceOwnership::Borrowed
));
40 JS::RootedScript
script(cx
, JS::Compile(cx
, options
, srcBuf
));
43 CHECK_EQUAL(JS_GetScriptBaseLineNumber(cx
, script
), startLine
);
44 CHECK(strcmp(JS_GetScriptFilename(script
), __FILE__
) == 0);
48 static bool CharsMatch(const char16_t
* p
, const char* q
) {
56 END_TEST(testScriptInfo
)