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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 var sourceURLLineIndex = source.lastIndexOf("\n", sourceURLIndex); 83 var sourceURLLineIndex = source.lastIndexOf("\n", sourceURLIndex);
84 if (sourceURLLineIndex === -1) 84 if (sourceURLLineIndex === -1)
85 return source; 85 return source;
86 var sourceURLLine = source.substr(sourceURLLineIndex + 1).split("\n", 1)[0]; 86 var sourceURLLine = source.substr(sourceURLLineIndex + 1).split("\n", 1)[0];
87 if (sourceURLLine.search(WebInspector.Script.sourceURLRegex) === -1) 87 if (sourceURLLine.search(WebInspector.Script.sourceURLRegex) === -1)
88 return source; 88 return source;
89 return source.substr(0, sourceURLLineIndex) + source.substr(sourceURLLineInd ex + sourceURLLine.length + 1); 89 return source.substr(0, sourceURLLineIndex) + source.substr(sourceURLLineInd ex + sourceURLLine.length + 1);
90 } 90 }
91 91
92 /**
93 * @param {!WebInspector.Script} script
94 * @param {string} source
95 */
96 WebInspector.Script._reportDeprecatedCommentIfNeeded = function(script, source)
97 {
98 var consoleModel = script.target().consoleModel;
99 if (!consoleModel)
100 return;
101 var linesToCheck = 5;
102 var offset = source.lastIndexOf("\n");
103 while (linesToCheck && offset !== -1)
104 offset = source.lastIndexOf("\n", offset - 1);
dgozman 2016/08/12 19:06:04 linesToCheck--
kozy 2016/08/12 19:24:36 Done.
105 offset = offset !== -1 ? offset : 0;
106 var sourceTail = source.substr(offset);
107 if (sourceTail.search(/^[\040\t]*\/\/@ source(mapping)?url=/mi) === -1)
dgozman 2016/08/12 19:06:04 Let's not do anything if sourceTail is longer than
kozy 2016/08/12 19:24:36 Done.
108 return;
109 var text = WebInspector.UIString("'//@ sourceURL' and '//@ sourceMappingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead .");
110 var msg = new WebInspector.ConsoleMessage(script.target(), WebInspector.Cons oleMessage.MessageSource.JS, WebInspector.ConsoleMessage.MessageLevel.Warning, t ext, undefined, undefined, undefined, undefined, undefined, undefined, undefined , undefined, undefined, script.scriptId);
dgozman 2016/08/12 19:06:04 nit: can we have lineNumber and columnNumber so th
kozy 2016/08/12 19:24:36 I'd like to avoid full scan of documents for new l
111 consoleModel.addMessage(msg);
112 }
92 113
93 WebInspector.Script.prototype = { 114 WebInspector.Script.prototype = {
94 /** 115 /**
95 * @return {boolean} 116 * @return {boolean}
96 */ 117 */
97 isContentScript: function() 118 isContentScript: function()
98 { 119 {
99 return this._isContentScript; 120 return this._isContentScript;
100 }, 121 },
101 122
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 this.target().debuggerAgent().getScriptSource(this.scriptId, didGetScrip tSource.bind(this)); 178 this.target().debuggerAgent().getScriptSource(this.scriptId, didGetScrip tSource.bind(this));
158 return promise; 179 return promise;
159 180
160 /** 181 /**
161 * @this {WebInspector.Script} 182 * @this {WebInspector.Script}
162 * @param {?Protocol.Error} error 183 * @param {?Protocol.Error} error
163 * @param {string} source 184 * @param {string} source
164 */ 185 */
165 function didGetScriptSource(error, source) 186 function didGetScriptSource(error, source)
166 { 187 {
188 WebInspector.Script._reportDeprecatedCommentIfNeeded(this, source);
167 this._source = WebInspector.Script._trimSourceURLComment(error ? "" : source); 189 this._source = WebInspector.Script._trimSourceURLComment(error ? "" : source);
168 callback(this._source); 190 callback(this._source);
169 } 191 }
170 }, 192 },
171 193
172 /** 194 /**
173 * @override 195 * @override
174 * @param {string} query 196 * @param {string} query
175 * @param {boolean} caseSensitive 197 * @param {boolean} caseSensitive
176 * @param {boolean} isRegex 198 * @param {boolean} isRegex
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 { 339 {
318 if (error) 340 if (error)
319 console.error(error); 341 console.error(error);
320 fulfill(!error); 342 fulfill(!error);
321 } 343 }
322 } 344 }
323 }, 345 },
324 346
325 __proto__: WebInspector.SDKObject.prototype 347 __proto__: WebInspector.SDKObject.prototype
326 } 348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698