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

Unified Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js

Issue 2270633003: DevTools: Warn when non-top context is selected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/ui/toolbar.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js
diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js
index 8073bead6351b1c6aa60d160cfd4e4749698734d..4ed570ea4849863487cd0bed51ccad4fb7c916d6 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleContextSelector.js
@@ -87,6 +87,7 @@ WebInspector.ConsoleContextSelector.prototype = {
{
var executionContext = /** @type {!WebInspector.ExecutionContext} */ (event.data);
this._executionContextCreated(executionContext);
+ this._updateSelectionWarning();
},
/**
@@ -98,6 +99,7 @@ WebInspector.ConsoleContextSelector.prototype = {
var option = this._optionByExecutionContext.get(executionContext);
if (option)
option.text = this._titleFor(executionContext);
+ this._updateSelectionWarning();
},
/**
@@ -116,6 +118,7 @@ WebInspector.ConsoleContextSelector.prototype = {
{
var executionContext = /** @type {!WebInspector.ExecutionContext} */ (event.data);
this._executionContextDestroyed(executionContext);
+ this._updateSelectionWarning();
},
/**
@@ -139,6 +142,41 @@ WebInspector.ConsoleContextSelector.prototype = {
var option = this._selectedOption();
var newContext = option ? option.__executionContext : null;
WebInspector.context.setFlavor(WebInspector.ExecutionContext, newContext);
+ this._updateSelectionWarning();
+ },
+
+ _updateSelectionWarning: function()
+ {
+ var executionContext = WebInspector.context.flavor(WebInspector.ExecutionContext);
+ this._selectElement.parentElement.classList.toggle("warning", !this._isTopContext(executionContext) && this._hasTopContext())
+ },
+
+ /**
+ * @param {?WebInspector.ExecutionContext} executionContext
+ * @return {boolean}
+ */
+ _isTopContext: function(executionContext)
+ {
+ if (!executionContext || !executionContext.isDefault)
+ return false;
+ var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(executionContext.target());
+ var frame = executionContext.frameId && resourceTreeModel && resourceTreeModel.frameForId(executionContext.frameId);
+ if (!frame)
+ return false;
+ return frame.isMainFrame();
+ },
+
+ /**
+ * @return {boolean}
+ */
+ _hasTopContext: function()
+ {
+ var options = this._selectElement.options;
+ for (var i = 0; i < options.length; i++){
+ if (this._isTopContext(options[i].__executionContext))
+ return true;
+ }
+ return false;
},
/**
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/ui/toolbar.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698