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

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);
105 --linesToCheck;
106 }
107 offset = offset !== -1 ? offset : 0;
108 var sourceTail = source.substr(offset);
109 if (sourceTail.length > 5000)
110 return;
111 if (sourceTail.search(/^[\040\t]*\/\/@ source(mapping)?url=/mi) === -1)
112 return;
113 var text = WebInspector.UIString("'//@ sourceURL' and '//@ sourceMappingURL' are deprecated, please use '//# sourceURL=' and '//# sourceMappingURL=' instead .");
114 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);
115 consoleModel.addMessage(msg);
116 }
92 117
93 WebInspector.Script.prototype = { 118 WebInspector.Script.prototype = {
94 /** 119 /**
95 * @return {boolean} 120 * @return {boolean}
96 */ 121 */
97 isContentScript: function() 122 isContentScript: function()
98 { 123 {
99 return this._isContentScript; 124 return this._isContentScript;
100 }, 125 },
101 126
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 this.target().debuggerAgent().getScriptSource(this.scriptId, didGetScrip tSource.bind(this)); 182 this.target().debuggerAgent().getScriptSource(this.scriptId, didGetScrip tSource.bind(this));
158 return promise; 183 return promise;
159 184
160 /** 185 /**
161 * @this {WebInspector.Script} 186 * @this {WebInspector.Script}
162 * @param {?Protocol.Error} error 187 * @param {?Protocol.Error} error
163 * @param {string} source 188 * @param {string} source
164 */ 189 */
165 function didGetScriptSource(error, source) 190 function didGetScriptSource(error, source)
166 { 191 {
192 WebInspector.Script._reportDeprecatedCommentIfNeeded(this, source);
167 this._source = WebInspector.Script._trimSourceURLComment(error ? "" : source); 193 this._source = WebInspector.Script._trimSourceURLComment(error ? "" : source);
168 callback(this._source); 194 callback(this._source);
169 } 195 }
170 }, 196 },
171 197
172 /** 198 /**
173 * @override 199 * @override
174 * @param {string} query 200 * @param {string} query
175 * @param {boolean} caseSensitive 201 * @param {boolean} caseSensitive
176 * @param {boolean} isRegex 202 * @param {boolean} isRegex
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 { 343 {
318 if (error) 344 if (error)
319 console.error(error); 345 console.error(error);
320 fulfill(!error); 346 fulfill(!error);
321 } 347 }
322 } 348 }
323 }, 349 },
324 350
325 __proto__: WebInspector.SDKObject.prototype 351 __proto__: WebInspector.SDKObject.prototype
326 } 352 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698