| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 3ce54cf574cad7a83e3bffb9c8d3310a0d6c6720..d90d384a75bce5d0f1f70499210954af3150765b 100644
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -22652,3 +22652,67 @@ TEST(ScriptNameAndLineNumber) {
|
| int line_number = script->GetUnboundScript()->GetLineNumber(0);
|
| CHECK_EQ(13, line_number);
|
| }
|
| +
|
| +
|
| +void SourceURLHelper(const char* source, const char* expected_source_url,
|
| + const char* expected_source_mapping_url) {
|
| + Local<Script> script = v8_compile(source);
|
| + if (expected_source_url != NULL) {
|
| + v8::String::Utf8Value url(script->GetUnboundScript()->GetSourceURL());
|
| + CHECK_EQ(expected_source_url, *url);
|
| + } else {
|
| + CHECK(script->GetUnboundScript()->GetSourceURL()->IsUndefined());
|
| + }
|
| + if (expected_source_mapping_url != NULL) {
|
| + v8::String::Utf8Value url(
|
| + script->GetUnboundScript()->GetSourceMappingURL());
|
| + CHECK_EQ(expected_source_mapping_url, *url);
|
| + } else {
|
| + CHECK(script->GetUnboundScript()->GetSourceMappingURL()->IsUndefined());
|
| + }
|
| +}
|
| +
|
| +
|
| +TEST(ScriptSourceURLAndSourceMappingURL) {
|
| + LocalContext env;
|
| + v8::Isolate* isolate = env->GetIsolate();
|
| + v8::HandleScope scope(isolate);
|
| + SourceURLHelper("function foo() {}\n"
|
| + "//# sourceURL=bar1.js\n", "bar1.js", NULL);
|
| + SourceURLHelper("function foo() {}\n"
|
| + "//# sourceMappingURL=bar2.js\n", NULL, "bar2.js");
|
| +
|
| + // Both sourceURL and sourceMappingURL.
|
| + SourceURLHelper("function foo() {}\n"
|
| + "//# sourceURL=bar3.js\n"
|
| + "//# sourceMappingURL=bar4.js\n", "bar3.js", "bar4.js");
|
| +
|
| + // Two source URLs; the first one is ignored.
|
| + SourceURLHelper("function foo() {}\n"
|
| + "//# sourceURL=ignoreme.js\n"
|
| + "//# sourceURL=bar5.js\n", "bar5.js", NULL);
|
| + SourceURLHelper("function foo() {}\n"
|
| + "//# sourceMappingURL=ignoreme.js\n"
|
| + "//# sourceMappingURL=bar6.js\n", NULL, "bar6.js");
|
| +
|
| + // SourceURL or sourceMappingURL in the middle of the script.
|
| + SourceURLHelper("function foo() {}\n"
|
| + "//# sourceURL=bar7.js\n"
|
| + "function baz() {}\n", "bar7.js", NULL);
|
| + SourceURLHelper("function foo() {}\n"
|
| + "//# sourceMappingURL=bar8.js\n"
|
| + "function baz() {}\n", NULL, "bar8.js");
|
| +
|
| + // Too much whitespace.
|
| + SourceURLHelper("function foo() {}\n"
|
| + "//# sourceURL=bar9.js\n"
|
| + "//# sourceMappingURL=bar10.js\n", NULL, NULL);
|
| + SourceURLHelper("function foo() {}\n"
|
| + "//# sourceURL =bar11.js\n"
|
| + "//# sourceMappingURL =bar12.js\n", NULL, NULL);
|
| +
|
| + // Not too much whitespace.
|
| + SourceURLHelper("function foo() {}\n"
|
| + "//# sourceURL= bar11.js \n"
|
| + "//# sourceMappingURL= bar12.js \n", "bar11.js", "bar12.js");
|
| +}
|
|
|