Demo/bin/Debug/front_end/components/ExecutionContextModel.js
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
// Copyright 2015 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
* @implements {WebInspector.TargetManager.Observer}
* @param {!Element} selectElement
*/
WebInspector.ExecutionContextModel = function(selectElement)
{
this._selectElement = selectElement;
/**
* @type {!Map.<!WebInspector.ExecutionContext, !Element>}
*/
this._optionByExecutionContext = new Map();
WebInspector.targetManager.observeTargets(this);
WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextCreated, this._onExecutionContextCreated, this);
WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebInspector.RuntimeModel.Events.ExecutionContextDestroyed, this._onExecutionContextDestroyed, this);
WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.FrameNavigated, this._onFrameNavigated, this);
this._selectElement.addEventListener("change", this._executionContextChanged.bind(this), false);
WebInspector.context.addFlavorChangeListener(WebInspector.ExecutionContext, this._executionContextChangedExternally, this);
}
WebInspector.ExecutionContextModel.prototype = {
/**
* @param {!WebInspector.ExecutionContext} executionContext
* @return {string}
*/
_titleFor: function(executionContext)
{
var result;
if (executionContext.isMainWorldContext) {
if (executionContext.frameId) {
var frame = executionContext.target().resourceTreeModel.frameForId(executionContext.frameId);
result = frame ? frame.displayName() : (executionContext.origin || executionContext.name);
} else {
var parsedUrl = executionContext.origin.asParsedURL();
var name = parsedUrl? parsedUrl.lastPathComponentWithFragment() : executionContext.name;
result = executionContext.target().decorateLabel(name);
}
} else {
result = "\u00a0\u00a0\u00a0\u00a0" + (executionContext.name || executionContext.origin);
}
var maxLength = 50;
return result.trimMiddle(maxLength);
},
/**
* @param {!WebInspector.ExecutionContext} executionContext
*/
_executionContextCreated: function(executionContext)
{
// FIXME(413886): We never want to show execution context for the main thread of shadow page in service/shared worker frontend.
// This check could be removed once we do not send this context to frontend.
if (executionContext.target().isServiceWorker())
return;
后面还有 127 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。