Revert "Removed support deprecated (//@|/*@) source(URL|MappingURL)="

A lot of deverlopers use deprecated sourceURL syntax. We should add console warning message before removing this.
Original CL: https://codereview.chromium.org/1495633002/

BUG=chromium:558998
LOG=Y
R=yangguo@chromium.org,hablich@chromium.org,adamk@chromium.org

Review URL: https://codereview.chromium.org/1654223003

Cr-Commit-Position: refs/heads/master@{#33709}
This commit is contained in:
kozyatinskiy 2016-02-03 10:45:01 -08:00 committed by Commit bot
parent ee4efed740
commit 3c3d7e7be8
9 changed files with 31 additions and 23 deletions

View File

@ -1610,7 +1610,8 @@ class V8_EXPORT StackFrame {
/**
* Returns the name of the resource that contains the script for the
* function for this StackFrame or sourceURL value if the script name
* is undefined and its source ends with //# sourceURL=... string.
* is undefined and its source ends with //# sourceURL=... string or
* deprecated //@ sourceURL=... string.
*/
Local<String> GetScriptNameOrSourceURL() const;

View File

@ -432,10 +432,11 @@ function ScriptLineEnd(n) {
* If sourceURL comment is available returns sourceURL comment contents.
* Otherwise, script name is returned. See
* http://fbug.googlecode.com/svn/branches/firebug1.1/docs/ReleaseNotes_1.1.txt
* and Source Map Revision 3 proposal for details on using //# sourceURL
* comment to identify scripts that don't have name.
* and Source Map Revision 3 proposal for details on using //# sourceURL and
* deprecated //@ sourceURL comment to identify scripts that don't have name.
*
* @return {?string} script name if present, value for //# sourceURL comment.
* @return {?string} script name if present, value for //# sourceURL comment or
* deprecated //@ sourceURL comment otherwise.
*/
function ScriptNameOrSourceURL() {
if (this.source_url) return this.source_url;

View File

@ -357,7 +357,7 @@ Token::Value Scanner::SkipSourceURLComment() {
void Scanner::TryToParseSourceURLComment() {
// Magic comments are of the form: //[#]\s<name>=\s*<value>\s*.* and this
// Magic comments are of the form: //[#@]\s<name>=\s*<value>\s*.* and this
// function will just return if it cannot parse a magic comment.
if (c0_ < 0 || !unicode_cache_->IsWhiteSpace(c0_)) return;
Advance();
@ -578,7 +578,7 @@ void Scanner::Scan() {
Advance();
if (c0_ == '/') {
Advance();
if (c0_ == '#') {
if (c0_ == '#' || c0_ == '@') {
Advance();
token = SkipSourceURLComment();
} else {

View File

@ -17260,6 +17260,8 @@ TEST(SourceURLInStackTrace) {
i::ScopedVector<char> code(1024);
i::SNPrintF(code, source, "//# sourceURL=eval_url");
CHECK(CompileRun(code.start())->IsUndefined());
i::SNPrintF(code, source, "//@ sourceURL=eval_url");
CHECK(CompileRun(code.start())->IsUndefined());
}
@ -17340,6 +17342,8 @@ TEST(InlineScriptWithSourceURLInStackTrace) {
i::ScopedVector<char> code(1024);
i::SNPrintF(code, source, "//# sourceURL=source_url");
CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined());
i::SNPrintF(code, source, "//@ sourceURL=source_url");
CHECK(CompileRunWithOrigin(code.start(), "url", 0, 1)->IsUndefined());
}
@ -17384,6 +17388,8 @@ TEST(DynamicWithSourceURLInStackTrace) {
i::ScopedVector<char> code(1024);
i::SNPrintF(code, source, "//# sourceURL=source_url");
CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
i::SNPrintF(code, source, "//@ sourceURL=source_url");
CHECK(CompileRunWithOrigin(code.start(), "url", 0, 0)->IsUndefined());
}

View File

@ -86,9 +86,9 @@ test(test1, 58);
test(test2, 65);
test(test3, 72);
eval(test1.toString() + "//# sourceUrl=foo");
eval(test2.toString() + "//# sourceUrl=foo");
eval(test3.toString() + "//# sourceUrl=foo");
eval(test1.toString() + "//@ sourceUrl=foo");
eval(test2.toString() + "//@ sourceUrl=foo");
eval(test3.toString() + "//@ sourceUrl=foo");
test(test1, 2);
test(test2, 3);

View File

@ -15,20 +15,20 @@ function test(expectation, f) {
/*
(function() {
1 + reference_error //# sourceURL=evaltest
1 + reference_error //@ sourceURL=evaltest
})
*/
test("2:5", new Function(
'1 + reference_error //# sourceURL=evaltest'));
'1 + reference_error //@ sourceURL=evaltest'));
/*
(function(x
/\**\/) {
1 + reference_error //# sourceURL=evaltest
1 + reference_error //@ sourceURL=evaltest
})
*/
test("4:6", new Function(
'x', '\n 1 + reference_error //# sourceURL=evaltest'));
'x', '\n 1 + reference_error //@ sourceURL=evaltest'));
/*
(function(x
@ -36,24 +36,24 @@ test("4:6", new Function(
,y
/\**\/) {
1 + reference_error //# sourceURL=evaltest
1 + reference_error //@ sourceURL=evaltest
})
*/
test("7:6", new Function(
'x\n\n', "z//\n", "y", '\n 1 + reference_error //# sourceURL=evaltest'));
'x\n\n', "z//\n", "y", '\n 1 + reference_error //@ sourceURL=evaltest'));
/*
(function(x/\*,z//
,y*\/
/\**\/) {
1 + reference_error //# sourceURL=evaltest
1 + reference_error //@ sourceURL=evaltest
})
*/
test("4:5", new Function(
'x/*', "z//\n", "y*/", '1 + reference_error //# sourceURL=evaltest'));
'x/*', "z//\n", "y*/", '1 + reference_error //@ sourceURL=evaltest'));
/*
(function () {
1 + reference_error //# sourceURL=evaltest5
1 + reference_error //@ sourceURL=evaltest5
})
*/
test("2:6", eval(
'(function () {\n 1 + reference_error //# sourceURL=evaltest\n})'));
'(function () {\n 1 + reference_error //@ sourceURL=evaltest\n})'));

View File

@ -29,7 +29,7 @@ function install() {
eval("this.dynamic = function dynamic() { \n" +
" print(\"> dynamic\"); // Break\n" +
"}\n" +
"//# sourceURL=dynamicScript");
"//@ sourceURL=dynamicScript");
}
install();
@ -53,4 +53,4 @@ Debug.setListener(null);
assertNull(exception);
assertEquals(2, break_count);
//# sourceURL=staticScript
//@ sourceURL=staticScript

View File

@ -8,7 +8,7 @@ var source =
"var foo = function foo() {\n" +
" return 1;\n" +
"}\n" +
"//# sourceURL=test";
"//@ sourceURL=test";
Debug = debug.Debug;
Debug.setListener(listener);

View File

@ -69,7 +69,7 @@ function testEvalWithSourceURL() {
function testNestedEvalWithSourceURL() {
var x = "FAIL";
var innerEval = 'function Inner() { eval(x); }\n//# sourceURL=res://inner-eval';
var innerEval = 'function Inner() { eval(x); }\n//@ sourceURL=res://inner-eval';
eval("function Outer() { eval(innerEval); Inner(); }; Outer();\n//# sourceURL=res://outer-eval");
}