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

Unified Diff: third_party/WebKit/Source/devtools/front_end/bindings/BlackboxSupport.js

Issue 1663723002: [DevTools] Add sourceMap support for blackboxing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@call-set-blackboxed-ranges-on-script-parsed
Patch Set: Created 4 years, 10 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/bindings/BlackboxSupport.js
diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxSupport.js b/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxSupport.js
deleted file mode 100644
index e86856063748d4198d5a0c74a1ed5da855ecf3c9..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Source/devtools/front_end/bindings/BlackboxSupport.js
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @constructor
- */
-WebInspector.BlackboxManager = function()
-{
- WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
- WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this._patternChanged.bind(this));
- WebInspector.moduleSetting("skipContentScripts").addChangeListener(this._patternChanged.bind(this));
-}
-
-WebInspector.BlackboxManager.prototype = {
- /**
- * @param {!WebInspector.Event} event
- */
- _parsedScriptSource: function(event)
- {
- var script = /** @type {!WebInspector.Script} */ (event.data);
- this._blackboxScriptIfNeeded(script);
- },
-
- _patternChanged: function()
- {
- for (var debuggerModel of WebInspector.DebuggerModel.instances()) {
- for (var scriptId in debuggerModel.scripts)
- this._blackboxScriptIfNeeded(debuggerModel.scripts[scriptId]);
- }
- },
-
- /**
- * @param {!WebInspector.Script} script
- */
- _blackboxScriptIfNeeded: function(script)
- {
- if (WebInspector.BlackboxSupport.isBlackboxed(script.sourceURL, script.isContentScript()))
- script.setBlackboxedRanges([ { line: 0, column: 0 } ]);
- else
- script.setBlackboxedRanges([]);
- }
-}
-
-WebInspector.BlackboxSupport = {}
-
-/**
- * @param {string} url
- * @return {string}
- */
-WebInspector.BlackboxSupport._urlToRegExpString = function(url)
-{
- var parsedURL = new WebInspector.ParsedURL(url);
- if (parsedURL.isAboutBlank() || parsedURL.isDataURL())
- return "";
- if (!parsedURL.isValid)
- return "^" + url.escapeForRegExp() + "$";
- var name = parsedURL.lastPathComponent;
- if (name)
- name = "/" + name;
- else if (parsedURL.folderPathComponents)
- name = parsedURL.folderPathComponents + "/";
- if (!name)
- name = parsedURL.host;
- if (!name)
- return "";
- var scheme = parsedURL.scheme;
- var prefix = "";
- if (scheme && scheme !== "http" && scheme !== "https") {
- prefix = "^" + scheme + "://";
- if (scheme === "chrome-extension")
- prefix += parsedURL.host + "\\b";
- prefix += ".*";
- }
- return prefix + name.escapeForRegExp() + (url.endsWith(name) ? "$" : "\\b");
-}
-
-/**
- * @param {string} url
- * @return {boolean}
- */
-WebInspector.BlackboxSupport.canBlackboxURL = function(url)
-{
- return !!WebInspector.BlackboxSupport._urlToRegExpString(url);
-}
-
-/**
- * @param {string} url
- */
-WebInspector.BlackboxSupport.blackboxURL = function(url)
-{
- var regexPatterns = WebInspector.moduleSetting("skipStackFramesPattern").getAsArray();
- var regexValue = WebInspector.BlackboxSupport._urlToRegExpString(url);
- if (!regexValue)
- return;
- var found = false;
- for (var i = 0; i < regexPatterns.length; ++i) {
- var item = regexPatterns[i];
- if (item.pattern === regexValue) {
- item.disabled = false;
- found = true;
- break;
- }
- }
- if (!found)
- regexPatterns.push({ pattern: regexValue });
- WebInspector.moduleSetting("skipStackFramesPattern").setAsArray(regexPatterns);
-}
-
-/**
- * @param {string} url
- * @param {boolean} isContentScript
- */
-WebInspector.BlackboxSupport.unblackbox = function(url, isContentScript)
-{
- if (isContentScript)
- WebInspector.moduleSetting("skipContentScripts").set(false);
-
- var regexPatterns = WebInspector.moduleSetting("skipStackFramesPattern").getAsArray();
- var regexValue = WebInspector.BlackboxSupport._urlToRegExpString(url);
- if (!regexValue)
- return;
- regexPatterns = regexPatterns.filter(function(item) {
- return item.pattern !== regexValue;
- });
- for (var i = 0; i < regexPatterns.length; ++i) {
- var item = regexPatterns[i];
- if (item.disabled)
- continue;
- try {
- var regex = new RegExp(item.pattern);
- if (regex.test(url))
- item.disabled = true;
- } catch (e) {
- }
- }
- WebInspector.moduleSetting("skipStackFramesPattern").setAsArray(regexPatterns);
-}
-
-/**
- * @param {string} url
- * @return {boolean}
- */
-WebInspector.BlackboxSupport.isBlackboxedURL = function(url)
-{
- var regex = WebInspector.moduleSetting("skipStackFramesPattern").asRegExp();
- return regex && regex.test(url);
-}
-
-/**
- * @param {string} url
- * @param {boolean} isContentScript
- * @return {boolean}
- */
-WebInspector.BlackboxSupport.isBlackboxed = function(url, isContentScript)
-{
- if (isContentScript && WebInspector.moduleSetting("skipContentScripts").get())
- return true;
- return WebInspector.BlackboxSupport.isBlackboxedURL(url);
-}
-
-/**
- * @param {function(!WebInspector.Event)} listener
- * @param {!Object=} thisObject
- */
-WebInspector.BlackboxSupport.addChangeListener = function(listener, thisObject)
-{
- WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(listener, thisObject);
-}
-
-/**
- * @param {function(!WebInspector.Event)} listener
- * @param {!Object=} thisObject
- */
-WebInspector.BlackboxSupport.removeChangeListener = function(listener, thisObject)
-{
- WebInspector.moduleSetting("skipStackFramesPattern").removeChangeListener(listener, thisObject);
-}

Powered by Google App Engine
This is Rietveld 408576698