Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(679)

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/Script.js

Issue 2235743004: [DevTools] Removed deprecatedCommentWasUsed flag from protocol scriptParsed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sdk/Script.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/Script.js b/third_party/WebKit/Source/devtools/front_end/sdk/Script.js
index 2e91baca71521197080ab9a35f26e38a67655e46..e30ea6495a46273b4a3f43b5a7ed9527b3289dcb 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/Script.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/Script.js
@@ -89,6 +89,31 @@ WebInspector.Script._trimSourceURLComment = function(source)
return source.substr(0, sourceURLLineIndex) + source.substr(sourceURLLineIndex + sourceURLLine.length + 1);
}
+/**
+ * @param {!WebInspector.Script} script
+ * @param {string} source
+ */
+WebInspector.Script._reportDeprecatedCommentIfNeeded = function(script, source)
+{
+ var consoleModel = script.target().consoleModel;
+ if (!consoleModel)
+ return;
+ var linesToCheck = 5;
+ var offset = source.lastIndexOf("\n");
+ while (linesToCheck && offset !== -1) {
+ offset = source.lastIndexOf("\n", offset - 1);
+ --linesToCheck;
+ }
+ offset = offset !== -1 ? offset : 0;
+ var sourceTail = source.substr(offset);
+ if (sourceTail.length > 5000)
+ return;
+ if (sourceTail.search(/^[\040\t]*\/\/@ source(mapping)?url=/mi) === -1)
+ return;
+ var text = WebInspector.UIString("'//@ sourceURL' and '//@ sourceMappingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead.");
+ var msg = new WebInspector.ConsoleMessage(script.target(), WebInspector.ConsoleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageLevel.Warning, text, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, script.scriptId);
+ consoleModel.addMessage(msg);
+}
WebInspector.Script.prototype = {
/**
@@ -164,6 +189,7 @@ WebInspector.Script.prototype = {
*/
function didGetScriptSource(error, source)
{
+ WebInspector.Script._reportDeprecatedCommentIfNeeded(this, source);
this._source = WebInspector.Script._trimSourceURLComment(error ? "" : source);
callback(this._source);
}

Powered by Google App Engine
This is Rietveld 408576698