WebInspector.SourcesPanel = function(workspaceForTest)
{
WebInspector.Panel.call(this, "sources");
- this.registerRequiredCSS("sourcesPanel.css");
+ this.registerRequiredCSS("sources/sourcesPanel.css");
new WebInspector.UpgradeFileSystemDropTarget(this.element);
this._workspace = workspaceForTest || WebInspector.workspace;
this._sourcesView.registerShortcuts(this.registerShortcuts.bind(this));
this._sourcesView.show(this.editorView.mainElement());
- this._debugSidebarResizeWidgetElement = document.createElementWithClass("div", "resizer-widget");
+ this._debugSidebarResizeWidgetElement = createElementWithClass("div", "resizer-widget");
this._debugSidebarResizeWidgetElement.id = "scripts-debug-sidebar-resizer-widget";
this._splitView.addEventListener(WebInspector.SplitView.Events.ShowModeChanged, this._updateDebugSidebarResizeWidget, this);
this._updateDebugSidebarResizeWidget();
this._splitView.installResizer(this._debugSidebarResizeWidgetElement);
- // FIXME: This is a temporary solution which should be removed as soon as the documentation module is released from experiment.
- if (Runtime.experiments.isEnabled("documentation"))
- self.runtime.loadModule("documentation");
-
this.sidebarPanes = {};
this.sidebarPanes.threads = new WebInspector.ThreadsSidebarPane();
this.sidebarPanes.watchExpressions = new WebInspector.WatchExpressionsSidebarPane();
WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame, this._consoleCommandEvaluatedInSelectedCallFrame, this);
WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.GlobalObjectCleared, this._debuggerReset, this);
WebInspector.targetManager.observeTargets(this);
+ new WebInspector.WorkspaceMappingTip(this, this._workspace);
+ WebInspector.extensionServer.addEventListener(WebInspector.ExtensionServer.Events.SidebarPaneAdded, this._extensionSidebarPaneAdded, this);
}
WebInspector.SourcesPanel.minToolbarWidth = 215;
-WebInspector.SourcesPanel._infobarSymbol = Symbol("infobar");
-
WebInspector.SourcesPanel.prototype = {
/**
* @param {?WebInspector.Target} target
} else if (details.reason === WebInspector.DebuggerModel.BreakReason.XHR) {
this.sidebarPanes.xhrBreakpoints.highlightBreakpoint(details.auxData["breakpointURL"]);
this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a XMLHttpRequest."));
- } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exception)
+ } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Exception) {
this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on exception: '%s'.", details.auxData["description"]));
- else if (details.reason === WebInspector.DebuggerModel.BreakReason.Assert)
+ } else if (details.reason === WebInspector.DebuggerModel.BreakReason.PromiseRejection) {
+ this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on promise rejection: '%s'.", details.auxData["description"]));
+ } else if (details.reason === WebInspector.DebuggerModel.BreakReason.Assert) {
this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on assertion."));
- else if (details.reason === WebInspector.DebuggerModel.BreakReason.CSPViolation)
+ } else if (details.reason === WebInspector.DebuggerModel.BreakReason.CSPViolation) {
this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a script blocked due to Content Security Policy directive: \"%s\".", details.auxData["directiveText"]));
- else if (details.reason === WebInspector.DebuggerModel.BreakReason.DebugCommand)
+ } else if (details.reason === WebInspector.DebuggerModel.BreakReason.DebugCommand) {
this.sidebarPanes.callstack.setStatus(WebInspector.UIString("Paused on a debugged function"));
- else {
+ } else {
if (details.callFrames.length)
WebInspector.debuggerWorkspaceBinding.createCallFrameLiveLocation(details.callFrames[0], didGetUILocation.bind(this));
else
_showEditor: function(forceShowInPanel)
{
- WebInspector.inspectorView.showPanel("sources");
+ WebInspector.inspectorView.setCurrentPanel(this);
},
/**
{
var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (event.data);
this._editorChanged(uiSourceCode);
- if (Runtime.experiments.isEnabled("suggestUsingWorkspace")) {
- if (this._editorSelectedTimer)
- clearTimeout(this._editorSelectedTimer);
- this._editorSelectedTimer = setTimeout(this._updateSuggestedMappingInfobar.bind(this, uiSourceCode), 3000);
- }
- },
-
- /**
- * @param {!WebInspector.UISourceCode} uiSourceCode
- */
- _updateSuggestedMappingInfobar: function(uiSourceCode)
- {
- if (!this.isShowing())
- return;
- if (uiSourceCode[WebInspector.SourcesPanel._infobarSymbol])
- return;
-
- // First try mapping filesystem -> network.
- var uiSourceCodeFrame = this._sourcesView.viewForFile(uiSourceCode);
- if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem) {
- var hasMappings = !!uiSourceCode.url;
- if (hasMappings)
- return;
-
- var targets = WebInspector.targetManager.targets();
- for (var i = 0; i < targets.length; ++i)
- targets[i].resourceTreeModel.forAllResources(matchResource.bind(this));
- }
-
- /**
- * @param {!WebInspector.Resource} resource
- * @return {boolean}
- * @this {WebInspector.SourcesPanel}
- */
- function matchResource(resource)
- {
- if (resource.contentURL().endsWith(uiSourceCode.name())) {
- createMappingInfobar.call(this, false);
- return true;
- }
- return false;
- }
-
- // Then map network -> filesystem.
- if (uiSourceCode.project().type() === WebInspector.projectTypes.Network || uiSourceCode.project().type() === WebInspector.projectTypes.ContentScripts) {
- if (this._workspace.uiSourceCodeForURL(uiSourceCode.url) !== uiSourceCode)
- return;
-
- var filesystemProjects = this._workspace.projectsForType(WebInspector.projectTypes.FileSystem);
- for (var i = 0; i < filesystemProjects.length; ++i) {
- var name = uiSourceCode.name();
- var fsUiSourceCodes = filesystemProjects[i].uiSourceCodes();
- for (var j = 0; j < fsUiSourceCodes.length; ++j) {
- if (fsUiSourceCodes[j].name() === name) {
- createMappingInfobar.call(this, true);
- return;
- }
- }
- }
-
- // There are no matching filesystems. Suggest adding a filesystem in case of localhost.
- var originURL = uiSourceCode.originURL().asParsedURL();
- if (originURL && originURL.host === "localhost")
- createWorkspaceInfobar();
- }
-
- /**
- * @param {boolean} isNetwork
- * @this {WebInspector.SourcesPanel}
- */
- function createMappingInfobar(isNetwork)
- {
- var title;
- if (isNetwork)
- title = WebInspector.UIString("Map network resource '%s' to workspace?", uiSourceCode.originURL());
- else
- title = WebInspector.UIString("Map workspace resource '%s' to network?", uiSourceCode.path());
-
- var infobar = new WebInspector.UISourceCodeFrame.Infobar(WebInspector.UISourceCodeFrame.Infobar.Level.Info, title);
- infobar.createDetailsRowMessage(WebInspector.UIString("You can map files in your workspace to the ones loaded over the network. As a result, changes made in DevTools will be persisted to disk."));
- infobar.createDetailsRowMessage(WebInspector.UIString("Use context menu to establish the mapping at any time."));
- var actionLink = infobar.createDetailsRowMessage("").createChild("a");
- actionLink.href = "";
- actionLink.onclick = establishTheMapping.bind(this);
- actionLink.textContent = WebInspector.UIString("Establish the mapping now...");
- appendInfobar(infobar);
- }
-
- /**
- * @param {?Event} event
- * @this {WebInspector.SourcesPanel}
- */
- function establishTheMapping(event)
- {
- event.consume(true);
- if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem)
- this._mapFileSystemToNetwork(uiSourceCode);
- else
- this._mapNetworkToFileSystem(uiSourceCode);
- }
-
- function createWorkspaceInfobar()
- {
- var infobar = new WebInspector.UISourceCodeFrame.Infobar(WebInspector.UISourceCodeFrame.Infobar.Level.Info, WebInspector.UIString("Serving from the file system? Add your files into the workspace."));
- infobar.createDetailsRowMessage(WebInspector.UIString("If you add files into your DevTools workspace, your changes will be persisted to disk."));
- infobar.createDetailsRowMessage(WebInspector.UIString("To add a folder into the workspace, drag and drop it into the Sources panel."));
- appendInfobar(infobar);
- }
-
- /**
- * @param {!WebInspector.UISourceCodeFrame.Infobar} infobar
- */
- function appendInfobar(infobar)
- {
- infobar.createDetailsRowMessage("").createChild("br");
- var rowElement = infobar.createDetailsRowMessage(WebInspector.UIString("For more information on workspaces, refer to the "));
- var a = rowElement.createChild("a");
- a.textContent = "workspaces documentation";
- a.href = "https://developer.chrome.com/devtools/docs/workspaces";
- rowElement.createTextChild(".");
- uiSourceCode[WebInspector.SourcesPanel._infobarSymbol] = infobar;
- uiSourceCodeFrame.attachInfobars([infobar]);
- }
},
/**
_createDebugToolbar: function()
{
- var debugToolbar = document.createElementWithClass("div", "scripts-debug-toolbar");
+ var debugToolbar = createElementWithClass("div", "scripts-debug-toolbar");
var title, handler;
var platformSpecificModifier = WebInspector.KeyboardShortcut.Modifiers.CtrlOrMeta;
_createDebugToolbarDrawer: function()
{
- var debugToolbarDrawer = document.createElementWithClass("div", "scripts-debug-toolbar-drawer");
+ var debugToolbarDrawer = createElementWithClass("div", "scripts-debug-toolbar-drawer");
var label = WebInspector.UIString("Pause On Caught Exceptions");
var setting = WebInspector.settings.pauseOnCaughtException;
/**
* @param {string} buttonId
* @param {string} buttonTitle
- * @param {function(!Event=):boolean} handler
+ * @param {function(!Event=)} handler
* @param {!Array.<!WebInspector.KeyboardShortcut.Descriptor>} shortcuts
* @return {!WebInspector.StatusBarButton}
*/
*/
_createButtonAndRegisterShortcutsForAction: function(buttonId, buttonTitle, actionId)
{
- /**
- * @return {boolean}
- */
function handler()
{
- return WebInspector.actionRegistry.execute(actionId);
+ WebInspector.actionRegistry.execute(actionId);
}
var shortcuts = WebInspector.shortcutRegistry.shortcutDescriptorsForAction(actionId);
return this._createButtonAndRegisterShortcuts(buttonId, buttonTitle, handler, shortcuts);
/**
* @param {!WebInspector.UISourceCode} uiSourceCode
*/
- _mapFileSystemToNetwork: function(uiSourceCode)
+ mapFileSystemToNetwork: function(uiSourceCode)
{
WebInspector.SelectUISourceCodeForProjectTypesDialog.show(uiSourceCode.name(), [WebInspector.projectTypes.Network, WebInspector.projectTypes.ContentScripts], mapFileSystemToNetwork.bind(this), this.editorView.mainElement())
},
/**
- * @param {!WebInspector.UISourceCode} uiSourceCode
- */
- _removeNetworkMapping: function(uiSourceCode)
- {
- if (confirm(WebInspector.UIString("Are you sure you want to remove network mapping?"))) {
- this._workspace.removeMapping(uiSourceCode);
- this._suggestReload();
- }
- },
-
- /**
* @param {!WebInspector.UISourceCode} networkUISourceCode
*/
- _mapNetworkToFileSystem: function(networkUISourceCode)
+ mapNetworkToFileSystem: function(networkUISourceCode)
{
WebInspector.SelectUISourceCodeForProjectTypesDialog.show(networkUISourceCode.name(), [WebInspector.projectTypes.FileSystem], mapNetworkToFileSystem.bind(this), this.editorView.mainElement())
},
/**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ */
+ _removeNetworkMapping: function(uiSourceCode)
+ {
+ if (confirm(WebInspector.UIString("Are you sure you want to remove network mapping?"))) {
+ this._workspace.removeMapping(uiSourceCode);
+ this._suggestReload();
+ }
+ },
+
+ /**
* @param {!WebInspector.ContextMenu} contextMenu
* @param {!WebInspector.UISourceCode} uiSourceCode
*/
if (uiSourceCode.project().type() === WebInspector.projectTypes.FileSystem) {
var hasMappings = !!uiSourceCode.url;
if (!hasMappings)
- contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Map to network resource\u2026" : "Map to Network Resource\u2026"), this._mapFileSystemToNetwork.bind(this, uiSourceCode));
+ contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Map to network resource\u2026" : "Map to Network Resource\u2026"), this.mapFileSystemToNetwork.bind(this, uiSourceCode));
else
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove network mapping" : "Remove Network Mapping"), this._removeNetworkMapping.bind(this, uiSourceCode));
}
if (!this._workspace.projects().filter(filterProject).length)
return;
if (this._workspace.uiSourceCodeForURL(uiSourceCode.url) === uiSourceCode)
- contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Map to file system resource\u2026" : "Map to File System Resource\u2026"), this._mapNetworkToFileSystem.bind(this, uiSourceCode));
+ contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Map to file system resource\u2026" : "Map to File System Resource\u2026"), this.mapNetworkToFileSystem.bind(this, uiSourceCode));
}
},
if (!currentExecutionContext)
return;
- currentExecutionContext.evaluate("this", "", false, true, false, false, didGetGlobalObject.bind(null, currentExecutionContext.target()));
+ currentExecutionContext.globalObject("", false, false, didGetGlobalObject);
/**
- * @param {!WebInspector.Target} target
* @param {?WebInspector.RemoteObject} global
* @param {boolean=} wasThrown
*/
- function didGetGlobalObject(target, global, wasThrown)
+ function didGetGlobalObject(global, wasThrown)
{
/**
* @suppressReceiverCheck
}
if (wasThrown || !global)
- failedToSave(target, global);
+ failedToSave(global);
else
global.callFunction(remoteFunction, [WebInspector.RemoteObject.toCallArgument(remoteObject)], didSave.bind(null, global));
}
*/
function didSave(global, result, wasThrown)
{
- var currentExecutionContext = WebInspector.context.flavor(WebInspector.ExecutionContext);
global.release();
- if (!currentExecutionContext || wasThrown || !result || result.type !== "string")
- failedToSave(global.target(), result);
+ if (wasThrown || !result || result.type !== "string")
+ failedToSave(result);
else
WebInspector.ConsoleModel.evaluateCommandInConsole(currentExecutionContext, result.value);
}
/**
- * @param {!WebInspector.Target} target
* @param {?WebInspector.RemoteObject} result
*/
- function failedToSave(target, result)
+ function failedToSave(result)
{
var message = WebInspector.UIString("Failed to save to temp variable.");
if (result) {
this.sidebarPaneView = splitView;
}
- for (var i = 0; i < this._extensionSidebarPanes.length; ++i)
- this._extensionSidebarPanesContainer.addPane(this._extensionSidebarPanes[i]);
+
+ var extensionSidebarPanes = WebInspector.extensionServer.sidebarPanes();
+ for (var i = 0; i < extensionSidebarPanes.length; ++i)
+ this._addExtensionSidebarPane(extensionSidebarPanes[i]);
this.sidebarPaneView.show(this._splitView.sidebarElement());
this.sidebarPanes.threads.expand();
},
/**
- * @param {string} id
- * @param {!WebInspector.SidebarPane} pane
+ * @param {!WebInspector.Event} event
*/
- addExtensionSidebarPane: function(id, pane)
+ _extensionSidebarPaneAdded: function(event)
{
- this._extensionSidebarPanes.push(pane);
- this._extensionSidebarPanesContainer.addPane(pane);
- this.setHideOnDetach();
+ var pane = /** @type {!WebInspector.ExtensionSidebarPane} */ (event.data);
+ this._addExtensionSidebarPane(pane);
+ },
+
+ /**
+ * @param {!WebInspector.ExtensionSidebarPane} pane
+ */
+ _addExtensionSidebarPane: function(pane)
+ {
+ if (pane.panelName() === this.name) {
+ this.setHideOnDetach();
+ this._extensionSidebarPanesContainer.addPane(pane);
+ }
},
/**
{
if (!this._sidebarPaneStack)
return;
- this._sidebarPaneStack.togglePaneHidden(this.sidebarPanes.threads, WebInspector.targetManager.targets().length < 2);
+ // FIXME(413886): We could remove worker frontend check here once we support explicit threads and do not send main thread for service/shared workers to frontend.
+ this._sidebarPaneStack.togglePaneHidden(this.sidebarPanes.threads, WebInspector.targetManager.targets().length < 2 || WebInspector.isWorkerFrontend());
},
__proto__: WebInspector.Panel.prototype
*/
appendApplicableItems: function(event, contextMenu, target)
{
- WebInspector.inspectorView.panel("sources").appendApplicableItems(event, contextMenu, target);
+ WebInspector.SourcesPanel.instance().appendApplicableItems(event, contextMenu, target);
}
}
WebInspector.SourcesPanel.UILocationRevealer.prototype = {
/**
* @param {!Object} uiLocation
+ * @return {!Promise}
*/
reveal: function(uiLocation)
{
- if (uiLocation instanceof WebInspector.UILocation)
- /** @type {!WebInspector.SourcesPanel} */ (WebInspector.inspectorView.panel("sources")).showUILocation(uiLocation);
+ if (uiLocation instanceof WebInspector.UILocation) {
+ WebInspector.SourcesPanel.instance().showUILocation(uiLocation);
+ return Promise.resolve();
+ }
+ return Promise.rejectWithError("Internal error: not a ui location");
}
}
WebInspector.SourcesPanel.UISourceCodeRevealer.prototype = {
/**
* @param {!Object} uiSourceCode
+ * @return {!Promise}
*/
reveal: function(uiSourceCode)
{
- if (uiSourceCode instanceof WebInspector.UISourceCode)
- /** @type {!WebInspector.SourcesPanel} */ (WebInspector.inspectorView.panel("sources")).showUISourceCode(uiSourceCode);
+ if (uiSourceCode instanceof WebInspector.UISourceCode) {
+ WebInspector.SourcesPanel.instance().showUISourceCode(uiSourceCode);
+ return Promise.resolve();
+ }
+ return Promise.rejectWithError("Internal error: not a ui source code");
+ }
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.Revealer}
+ */
+WebInspector.SourcesPanel.DebuggerPausedDetailsRevealer = function()
+{
+}
+
+WebInspector.SourcesPanel.DebuggerPausedDetailsRevealer.prototype = {
+ /**
+ * @param {!Object} object
+ * @return {!Promise}
+ */
+ reveal: function(object)
+ {
+ WebInspector.inspectorView.setCurrentPanel(WebInspector.SourcesPanel.instance());
+ return Promise.resolve();
}
}
*/
handleAction: function()
{
- var panel = /** @type {?WebInspector.SourcesPanel} */ (WebInspector.inspectorView.showPanel("sources"));
- if (!panel)
- return false;
+ var panel = WebInspector.SourcesPanel.instance();
+ WebInspector.inspectorView.setCurrentPanel(panel);
panel.showGoToSourceDialog();
return true;
}
var disabled = forbidden || (status === "disabled");
this._disableJSInfo.classList.toggle("hidden", !forbidden);
- this._disableJSCheckbox.checked = disabled;
this._disableJSCheckbox.disabled = forbidden;
+ if (!forbidden && WebInspector.settings.javaScriptDisabled.get() !== disabled)
+ WebInspector.settings.javaScriptDisabled.set(disabled);
}
},
*/
handleAction: function()
{
- var panel = /** @type {?WebInspector.SourcesPanel} */ (WebInspector.inspectorView.showPanel("sources"));
- if (!panel)
- return false;
+ var panel = WebInspector.SourcesPanel.instance();
+ WebInspector.inspectorView.setCurrentPanel(panel);
panel.togglePause();
return true;
}
}
+
+WebInspector.SourcesPanel.show = function()
+{
+ WebInspector.inspectorView.setCurrentPanel(WebInspector.SourcesPanel.instance());
+}
+
+/**
+ * @return {!WebInspector.SourcesPanel}
+ */
+WebInspector.SourcesPanel.instance = function()
+{
+ if (!WebInspector.SourcesPanel._instanceObject)
+ WebInspector.SourcesPanel._instanceObject = new WebInspector.SourcesPanel();
+ return WebInspector.SourcesPanel._instanceObject;
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.PanelFactory}
+ */
+WebInspector.SourcesPanelFactory = function()
+{
+}
+
+WebInspector.SourcesPanelFactory.prototype = {
+ /**
+ * @return {!WebInspector.Panel}
+ */
+ createPanel: function()
+ {
+ return WebInspector.SourcesPanel.instance();
+ }
+}