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

Side by Side Diff: Source/devtools/front_end/sdk/BlackboxSupport.js

Issue 458583004: DevTools: Remove autogenerated blackbox patterns upon Unblackbox user action. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 WebInspector.BlackboxSupport = function() 5 WebInspector.BlackboxSupport = function()
6 { 6 {
7 } 7 }
8 8
9 /** 9 /**
10 * @param {string} url 10 * @param {string} url
11 * @return {string}
12 */
13 WebInspector.BlackboxSupport._urlToRegExpString = function(url)
14 {
15 var name = new WebInspector.ParsedURL(url).lastPathComponent;
16 return "/" + name.escapeForRegExp() + (url.endsWith(name) ? "$" : "\\b");
17 }
18
19 /**
20 * @param {string} url
11 */ 21 */
12 WebInspector.BlackboxSupport.blackboxURL = function(url) 22 WebInspector.BlackboxSupport.blackboxURL = function(url)
13 { 23 {
14 var regexPatterns = WebInspector.settings.skipStackFramesPattern.getAsArray( ); 24 var regexPatterns = WebInspector.settings.skipStackFramesPattern.getAsArray( );
15 var name = new WebInspector.ParsedURL(url).lastPathComponent; 25 var regexValue = WebInspector.BlackboxSupport._urlToRegExpString(url);
16 var regexValue = "/" + name.escapeForRegExp() + (url.endsWith(name) ? "$" : "\\b");
17 var found = false; 26 var found = false;
18 for (var i = 0; i < regexPatterns.length; ++i) { 27 for (var i = 0; i < regexPatterns.length; ++i) {
19 var item = regexPatterns[i]; 28 var item = regexPatterns[i];
20 if (item.pattern === regexValue) { 29 if (item.pattern === regexValue) {
21 item.disabled = false; 30 item.disabled = false;
22 found = true; 31 found = true;
23 break; 32 break;
24 } 33 }
25 } 34 }
26 if (!found) 35 if (!found)
27 regexPatterns.push({ pattern: regexValue }); 36 regexPatterns.push({ pattern: regexValue });
28 WebInspector.settings.skipStackFramesPattern.setAsArray(regexPatterns); 37 WebInspector.settings.skipStackFramesPattern.setAsArray(regexPatterns);
29 } 38 }
30 39
31 /** 40 /**
32 * @param {string} url 41 * @param {string} url
33 */ 42 */
34 WebInspector.BlackboxSupport.unblackboxURL = function(url) 43 WebInspector.BlackboxSupport.unblackboxURL = function(url)
35 { 44 {
36 var regexPatterns = WebInspector.settings.skipStackFramesPattern.getAsArray( ); 45 var regexPatterns = WebInspector.settings.skipStackFramesPattern.getAsArray( );
46 var regexValue = WebInspector.BlackboxSupport._urlToRegExpString(url);
47 regexPatterns = regexPatterns.filter(function(item) {
48 return item.pattern !== regexValue;
49 });
37 for (var i = 0; i < regexPatterns.length; ++i) { 50 for (var i = 0; i < regexPatterns.length; ++i) {
38 var item = regexPatterns[i]; 51 var item = regexPatterns[i];
39 if (item.disabled) 52 if (item.disabled)
40 continue; 53 continue;
41 try { 54 try {
42 var regex = new RegExp(item.pattern); 55 var regex = new RegExp(item.pattern);
43 if (regex.test(url)) 56 if (regex.test(url))
44 item.disabled = true; 57 item.disabled = true;
45 } catch (e) { 58 } catch (e) {
46 } 59 }
47 } 60 }
48 WebInspector.settings.skipStackFramesPattern.setAsArray(regexPatterns); 61 WebInspector.settings.skipStackFramesPattern.setAsArray(regexPatterns);
49 } 62 }
50 63
51 /** 64 /**
52 * @param {string} url 65 * @param {string} url
53 * @return {boolean} 66 * @return {boolean}
54 */ 67 */
55 WebInspector.BlackboxSupport.isBlackboxedURL = function(url) 68 WebInspector.BlackboxSupport.isBlackboxedURL = function(url)
56 { 69 {
57 var regex = WebInspector.settings.skipStackFramesPattern.asRegExp(); 70 var regex = WebInspector.settings.skipStackFramesPattern.asRegExp();
58 return (url && regex) ? regex.test(url) : false; 71 return (url && regex) ? regex.test(url) : false;
59 } 72 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698