WebKit Bugzilla
Attachment 372249 Details for
Bug 195847
: Web Inspector: provide a way to inject "bootstrap" JavaScript into the page as the first script executed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
[Patch] WIP
195847.diff (text/plain), 27.23 KB, created by
Devin Rousso
on 2019-06-17 09:30:19 PDT
(
hide
)
Description:
[Patch] WIP
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2019-06-17 09:30:19 PDT
Size:
27.23 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/inspector/protocol/Page.json b/Source/JavaScriptCore/inspector/protocol/Page.json >index 769bf4b3b8f..2dd18958294 100644 >--- a/Source/JavaScriptCore/inspector/protocol/Page.json >+++ b/Source/JavaScriptCore/inspector/protocol/Page.json >@@ -250,6 +250,13 @@ > { "name": "visible", "type": "boolean", "description": "True for showing compositing borders." } > ] > }, >+ { >+ "name": "setBootstrapScript", >+ "description": "FIXME", >+ "parameters": [ >+ { "name": "source", "type": "string", "optional": true, "description": "FIXME" } >+ ] >+ }, > { > "name": "snapshotNode", > "description": "Capture a snapshot of the specified node that does not include unrelated layers.", >diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp >index fb75d19c8b6..78a72959c78 100644 >--- a/Source/WebCore/inspector/InspectorInstrumentation.cpp >+++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp >@@ -110,15 +110,19 @@ static Frame* frameForScriptExecutionContext(ScriptExecutionContext& context) > > void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, DOMWrapperWorld& world) > { >- if (PageDebuggerAgent* debuggerAgent = instrumentingAgents.pageDebuggerAgent()) { >- if (&world == &mainThreadNormalWorld() && frame.isMainFrame()) >- debuggerAgent->didClearMainFrameWindowObject(); >+ if (&world != &mainThreadNormalWorld()) >+ return; >+ >+ if (frame.isMainFrame()) { >+ if (auto* pageDebuggerAgent = instrumentingAgents.pageDebuggerAgent()) >+ pageDebuggerAgent->didClearMainFrameWindowObject(); > } > >- if (PageRuntimeAgent* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent()) { >- if (&world == &mainThreadNormalWorld()) >- pageRuntimeAgent->didCreateMainWorldContext(frame); >- } >+ if (auto* pageRuntimeAgent = instrumentingAgents.pageRuntimeAgent()) >+ pageRuntimeAgent->didClearWindowObjectInWorld(frame); >+ >+ if (auto* pageAgent = instrumentingAgents.inspectorPageAgent()) >+ pageAgent->didClearWindowObjectInWorld(frame); > } > > bool InspectorInstrumentation::isDebuggerPausedImpl(InstrumentingAgents& instrumentingAgents) >diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp >index c6762e6386e..681eec16886 100644 >--- a/Source/WebCore/inspector/agents/InspectorPageAgent.cpp >+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.cpp >@@ -37,6 +37,7 @@ > #include "Cookie.h" > #include "CookieJar.h" > #include "CustomHeaderFields.h" >+#include "DOMWrapperWorld.h" > #include "Document.h" > #include "DocumentLoader.h" > #include "Frame.h" >@@ -58,6 +59,7 @@ > #include "RenderObject.h" > #include "RenderTheme.h" > #include "ScriptController.h" >+#include "ScriptSourceCode.h" > #include "SecurityOrigin.h" > #include "Settings.h" > #include "StyleScope.h" >@@ -66,10 +68,12 @@ > #include <JavaScriptCore/ContentSearchUtilities.h> > #include <JavaScriptCore/IdentifiersFactory.h> > #include <JavaScriptCore/RegularExpression.h> >+#include <JavaScriptCore/SourceProvider.h> > #include <wtf/ListHashSet.h> > #include <wtf/Stopwatch.h> > #include <wtf/text/Base64.h> > #include <wtf/text/StringBuilder.h> >+#include <wtf/text/TextPosition.h> > > #if ENABLE(APPLICATION_MANIFEST) > #include "CachedApplicationManifest.h" >@@ -892,6 +896,14 @@ void InspectorPageAgent::applyEmulatedMedia(String& media) > media = m_emulatedMedia; > } > >+void InspectorPageAgent::didClearWindowObjectInWorld(Frame& frame) >+{ >+ if (!m_bootstrapScript) >+ return; >+ >+ frame.script().evaluate(ScriptSourceCode(m_bootstrapScript.value(), URL(), TextPosition(), JSC::SourceProviderSourceType::Module)); >+} >+ > void InspectorPageAgent::getCompositingBordersVisible(ErrorString&, bool* outParam) > { > *outParam = m_inspectedPage.settings().showDebugBorders() || m_inspectedPage.settings().showRepaintCounter(); >@@ -903,6 +915,16 @@ void InspectorPageAgent::setCompositingBordersVisible(ErrorString&, bool visible > m_inspectedPage.settings().setShowRepaintCounter(visible); > } > >+void InspectorPageAgent::setBootstrapScript(ErrorString&, const String* optionalSource) >+{ >+ if (!optionalSource || optionalSource->isEmpty()) { >+ m_bootstrapScript = WTF::nullopt; >+ return; >+ } >+ >+ m_bootstrapScript = *optionalSource; >+} >+ > void InspectorPageAgent::snapshotNode(ErrorString& errorString, int nodeId, String* outDataURL) > { > InspectorDOMAgent* domAgent = m_instrumentingAgents.inspectorDOMAgent(); >diff --git a/Source/WebCore/inspector/agents/InspectorPageAgent.h b/Source/WebCore/inspector/agents/InspectorPageAgent.h >index 0ff4578b4e0..8b89108702f 100644 >--- a/Source/WebCore/inspector/agents/InspectorPageAgent.h >+++ b/Source/WebCore/inspector/agents/InspectorPageAgent.h >@@ -106,6 +106,7 @@ public: > void setForcedAppearance(ErrorString&, const String&) final; > void getCompositingBordersVisible(ErrorString&, bool* out_param) final; > void setCompositingBordersVisible(ErrorString&, bool) final; >+ void setBootstrapScript(ErrorString&, const String* optionalSource) final; > void snapshotNode(ErrorString&, int nodeId, String* outDataURL) final; > void snapshotRect(ErrorString&, int x, int y, int width, int height, const String& coordinateSystem, String* outDataURL) final; > void archive(ErrorString&, String* data) final; >@@ -123,6 +124,7 @@ public: > void defaultAppearanceDidChange(bool useDarkAppearance); > void applyUserAgentOverride(String&); > void applyEmulatedMedia(String&); >+ void didClearWindowObjectInWorld(Frame&); > void didPaint(RenderObject&, const LayoutRect&); > void didLayout(); > void didScroll(); >@@ -160,6 +162,7 @@ private: > String m_userAgentOverride; > String m_emulatedMedia; > String m_forcedAppearance; >+ Optional<String> m_bootstrapScript; > bool m_isFirstLayoutAfterOnLoad { false }; > bool m_showPaintRects { false }; > }; >diff --git a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp >index 33d7a12d5bc..b5785b3b70c 100644 >--- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp >+++ b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.cpp >@@ -83,7 +83,7 @@ void PageRuntimeAgent::disable(ErrorString& errorString) > InspectorRuntimeAgent::disable(errorString); > } > >-void PageRuntimeAgent::didCreateMainWorldContext(Frame& frame) >+void PageRuntimeAgent::didClearWindowObjectInWorld(Frame& frame) > { > auto* pageAgent = m_instrumentingAgents.inspectorPageAgent(); > if (!pageAgent) >diff --git a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h >index 93a76cc11d2..ef6c3e87d1f 100644 >--- a/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h >+++ b/Source/WebCore/inspector/agents/page/PageRuntimeAgent.h >@@ -59,7 +59,7 @@ public: > void evaluate(ErrorString&, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* returnByValue, const bool* generatePreview, const bool* saveResult, const bool* emulateUserGesture, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Optional<bool>& wasThrown, Optional<int>& savedResultIndex) final; > > // InspectorInstrumentation >- void didCreateMainWorldContext(Frame&); >+ void didClearWindowObjectInWorld(Frame&); > > private: > Inspector::InjectedScript injectedScriptForEval(ErrorString&, const int* executionContextId) override; >diff --git a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >index 9a3c9ea4c4a..1712148ef0a 100644 >--- a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >+++ b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >@@ -293,6 +293,7 @@ localizedStrings["Copy as cURL"] = "Copy as cURL"; > localizedStrings["Could not fetch properties. Object may no longer exist."] = "Could not fetch properties. Object may no longer exist."; > localizedStrings["Count"] = "Count"; > localizedStrings["Create Breakpoint"] = "Create Breakpoint"; >+localizedStrings["Create Resource"] = "Create Resource"; > localizedStrings["Create a new tab"] = "Create a new tab"; > localizedStrings["Cross-Origin Restrictions"] = "Cross-Origin Restrictions"; > localizedStrings["Current"] = "Current"; >@@ -589,6 +590,7 @@ localizedStrings["Initial Velocity"] = "Initial Velocity"; > localizedStrings["Initiated"] = "Initiated"; > localizedStrings["Initiator"] = "Initiator"; > localizedStrings["Input: "] = "Input: "; >+localizedStrings["Inspector Bootstrap Script"] = "Inspector Bootstrap Script"; > localizedStrings["Inspector Style Sheet"] = "Inspector Style Sheet"; > localizedStrings["Instances"] = "Instances"; > localizedStrings["Invalid"] = "Invalid"; >diff --git a/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js b/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js >index 59bfe8c668b..4a480fe865b 100644 >--- a/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js >+++ b/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js >@@ -44,6 +44,7 @@ WI.NetworkManager = class NetworkManager extends WI.Object > this._downloadingSourceMaps = new Set; > > this._localResourcesMap = new Map; >+ this._bootstrapScriptSetting = new WI.Setting("bootstrap-script", null); > > WI.notifications.addEventListener(WI.Notification.ExtraDomainsActivated, this._extraDomainsActivated, this); > WI.Frame.addEventListener(WI.Frame.Event.MainResourceDidChange, this._handleFrameMainResourceDidChange, this); >@@ -56,6 +57,11 @@ WI.NetworkManager = class NetworkManager extends WI.Object > return InspectorFrontendHost.supportsShowCertificate && window.NetworkAgent && NetworkAgent.getSerializedCertificate; > } > >+ static supportsBootstrapScript() >+ { >+ return !!InspectorBackend.domains.Page.setBootstrapScript; >+ } >+ > static synthesizeImportError(message) > { > message = WI.UIString("HAR Import Error: %s").format(message); >@@ -78,6 +84,9 @@ WI.NetworkManager = class NetworkManager extends WI.Object > if (target.PageAgent) { > target.PageAgent.enable(); > target.PageAgent.getResourceTree(this._processMainFrameResourceTreePayload.bind(this)); >+ >+ if (target.PageAgent.setBootstrapScript && this._bootstrapScriptSetting.value) >+ target.PageAgent.setBootstrapScript(this._bootstrapScriptSetting.value); > } > > if (target.ServiceWorkerAgent) >@@ -635,6 +644,26 @@ WI.NetworkManager = class NetworkManager extends WI.Object > target.adoptResource(resource); > } > >+ get bootstrapScript() >+ { >+ console.assert(NetworkManager.supportsBootstrapScript()); >+ >+ return this._bootstrapScriptSetting.value; >+ } >+ >+ set bootstrapScript(source) >+ { >+ console.assert(NetworkManager.supportsBootstrapScript()); >+ console.assert(!source || typeof source === "string"); >+ >+ this._bootstrapScriptSetting.value = source; >+ >+ for (let target of WI.targets) { >+ if (target.PageAgent && target.PageAgent.setBootstrapScript) >+ target.PageAgent.setBootstrapScript(this._bootstrapScriptSetting.value || undefined); >+ } >+ } >+ > processHAR({json, error}) > { > if (error) { >diff --git a/Source/WebInspectorUI/UserInterface/Views/CanvasSidebarPanel.js b/Source/WebInspectorUI/UserInterface/Views/CanvasSidebarPanel.js >index c294e22215a..fb81348449a 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/CanvasSidebarPanel.js >+++ b/Source/WebInspectorUI/UserInterface/Views/CanvasSidebarPanel.js >@@ -278,7 +278,7 @@ WI.CanvasSidebarPanel = class CanvasSidebarPanel extends WI.NavigationSidebarPan > const activatedByDefault = false; > const defaultToolTip = WI.UIString("Only show visual actions"); > const activatedToolTip = WI.UIString("Show all actions"); >- this.filterBar.addFilterBarButton("recording-show-visual-only", filterFunction, activatedByDefault, defaultToolTip, activatedToolTip, "Images/Paint.svg", 15, 15); >+ this.filterBar.addFilterFunctionActivateButton("recording-show-visual-only", filterFunction, activatedByDefault, defaultToolTip, activatedToolTip, "Images/Paint.svg", 15, 15); > } > > // Private >diff --git a/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js b/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js >index 9bb6a68485e..87d829e740c 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js >+++ b/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js >@@ -144,7 +144,7 @@ WI.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WI.NavigationSideba > return false; > } > >- this.filterBar.addFilterBarButton("debugger-show-resources-with-issues-only", showResourcesWithIssuesOnlyFilterFunction.bind(this), false, WI.UIString("Only show resources with issues"), WI.UIString("Show all resources"), "Images/Errors.svg", 15, 15); >+ this.filterBar.addFilterFunctionActivateButton("debugger-show-resources-with-issues-only", showResourcesWithIssuesOnlyFilterFunction.bind(this), false, WI.UIString("Only show resources with issues"), WI.UIString("Show all resources"), "Images/Errors.svg", 15, 15); > > this._breakpointsContentTreeOutline = this.contentTreeOutline; > >diff --git a/Source/WebInspectorUI/UserInterface/Views/FilterBar.js b/Source/WebInspectorUI/UserInterface/Views/FilterBar.js >index 93223de9070..df483fa964f 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/FilterBar.js >+++ b/Source/WebInspectorUI/UserInterface/Views/FilterBar.js >@@ -131,12 +131,17 @@ WI.FilterBar = class FilterBar extends WI.Object > this._inputField.value = null; // Get the placeholder to show again. > } > >- addFilterBarButton(identifier, filterFunction, activatedByDefault, defaultToolTip, activatedToolTip, image, imageWidth, imageHeight) >+ addFilterBarNavigationItem(navigationItem) >+ { >+ this._filtersNavigationBar.addNavigationItem(navigationItem); >+ } >+ >+ addFilterFunctionActivateButton(identifier, filterFunction, activatedByDefault, defaultToolTip, activatedToolTip, image, imageWidth, imageHeight) > { > var filterBarButton = new WI.FilterBarButton(identifier, filterFunction, activatedByDefault, defaultToolTip, activatedToolTip, image, imageWidth, imageHeight); > filterBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._handleFilterBarButtonClicked, this); > filterBarButton.addEventListener(WI.FilterBarButton.Event.ActivatedStateToggled, this._handleFilterButtonToggled, this); >- this._filtersNavigationBar.addNavigationItem(filterBarButton); >+ this.addFilterBarNavigationItem(filterBarButton); > if (filterBarButton.activated) { > this._filterFunctionsMap.set(filterBarButton.identifier, filterBarButton.filterFunction); > this._handleFilterChanged(); >diff --git a/Source/WebInspectorUI/UserInterface/Views/ResourceIcons.css b/Source/WebInspectorUI/UserInterface/Views/ResourceIcons.css >index a16bc58ceb7..8d9fe474318 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/ResourceIcons.css >+++ b/Source/WebInspectorUI/UserInterface/Views/ResourceIcons.css >@@ -43,7 +43,8 @@ > content: image-set(url(../Images/DocumentCSS.png) 1x, url(../Images/DocumentCSS@2x.png) 2x); > } > >-.resource-icon.resource-type-script .icon { >+.resource-icon.resource-type-script .icon, >+.bootstrap-script .icon { > content: image-set(url(../Images/DocumentJS.png) 1x, url(../Images/DocumentJS@2x.png) 2x); > } > >@@ -102,7 +103,8 @@ > content: image-set(url(../Images/DocumentCSSLarge.png) 1x, url(../Images/DocumentCSSLarge@2x.png) 2x); > } > >-.large .resource-icon.resource-type-script .icon { >+.large .resource-icon.resource-type-script .icon, >+.large .bootstrap-script .icon { > content: image-set(url(../Images/DocumentJSLarge.png) 1x, url(../Images/DocumentJSLarge@2x.png) 2x); > } > >diff --git a/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js b/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js >index 1bd1dc6bc6e..934295cfc25 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js >@@ -32,6 +32,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > > this._workerTargetTreeElementMap = new Map; > this._mainFrameTreeElement = null; >+ this._bootstrapScriptTreeElement = null; > this._extensionScriptsFolderTreeElement = null; > this._extraScriptsFolderTreeElement = null; > this._anonymousScriptsFolderTreeElement = null; >@@ -228,6 +229,12 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > this._resourcesTreeOutline.includeSourceMapResourceChildren = true; > this.contentView.element.insertBefore(this._resourcesTreeOutline.element, this._resourcesNavigationBar.element.nextSibling); > >+ if (WI.NetworkManager.supportsBootstrapScript() || InspectorBackend.domains.CSS) { >+ let createResourceButtonNavigationItem = new WI.ButtonNavigationItem("create-resource", WI.UIString("Create Resource"), "Images/Plus15.svg", 15, 15); >+ createResourceButtonNavigationItem.element.addEventListener("mousedown", this._handleCreateResourceButtonNavigationItemMouseDown.bind(this)); >+ this.filterBar.addFilterBarNavigationItem(createResourceButtonNavigationItem); >+ } >+ > let onlyShowResourcesWithIssuesFilterFunction = (treeElement) => { > if (treeElement.treeOutline !== this._resourcesTreeOutline) > return true; >@@ -244,7 +251,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > return false; > }; > const activatedByDefault = false; >- this.filterBar.addFilterBarButton("sources-only-show-resources-with-issues", onlyShowResourcesWithIssuesFilterFunction, activatedByDefault, WI.UIString("Only show resources with issues"), WI.UIString("Show all resources"), "Images/Errors.svg", 15, 15); >+ this.filterBar.addFilterFunctionActivateButton("sources-only-show-resources-with-issues", onlyShowResourcesWithIssuesFilterFunction, activatedByDefault, WI.UIString("Only show resources with issues"), WI.UIString("Show all resources"), "Images/Errors.svg", 15, 15); > > WI.settings.resourceGroupingMode.addEventListener(WI.Setting.Event.Changed, this._handleResourceGroupingModeChanged, this); > >@@ -390,8 +397,35 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > } > > let firstTreeElement = this._resourcesTreeOutline.children[0]; >- if (firstTreeElement) >- this.showDefaultContentViewForTreeElement(firstTreeElement); >+ if (!firstTreeElement) >+ return; >+ >+ if (firstTreeElement === this._bootstrapScriptTreeElement) { >+ this._showBootstrapScriptContentView(); >+ return; >+ } >+ >+ this.showDefaultContentViewForTreeElement(firstTreeElement); >+ } >+ >+ saveStateToCookie(cookie) >+ { >+ if (this._bootstrapScriptTreeElement && this._bootstrapScriptTreeElement.selected) { >+ cookie.__bootstrapScript = true; >+ return; >+ } >+ >+ super.saveStateToCookie(cookie); >+ } >+ >+ restoreStateFromCookie(cookie, relaxedMatchDelay) >+ { >+ if (cookie.__bootstrapScript) { >+ this._showBootstrapScriptContentView(); >+ return; >+ } >+ >+ super.restoreStateFromCookie(cookie, relaxedMatchDelay); > } > > treeElementForRepresentedObject(representedObject) >@@ -441,6 +475,11 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > if (treeElement) > return treeElement; > >+ if (representedObject === WI.networkManager.bootstrapScript) { >+ this._updateBootstrapScriptTreeElement(); >+ return this._bootstrapScriptTreeElement; >+ } >+ > // Only special case Script objects. > if (!(representedObject instanceof WI.Script)) { > console.error("Didn't find a TreeElement for representedObject", representedObject); >@@ -574,6 +613,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > _compareTreeElements(a, b) > { > const rankFunctions = [ >+ (treeElement) => treeElement === this._bootstrapScriptTreeElement || treeElement.representedObject.__bootstrapScript, > (treeElement) => treeElement instanceof WI.CSSStyleSheetTreeElement && treeElement.representedObject.isInspectorStyleSheet(), > (treeElement) => treeElement === this._mainFrameTreeElement, > (treeElement) => treeElement instanceof WI.FrameTreeElement, >@@ -634,7 +674,8 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > break; > } > >- this._resourcesTreeOutline.insertChild(this._mainFrameTreeElement, 0); >+ let index = insertionIndexForObjectInListSortedByFunction(this._mainFrameTreeElement, this._resourcesTreeOutline.children, this._boundCompareTreeElements); >+ this._resourcesTreeOutline.insertChild(this._mainFrameTreeElement, index); > > // Cookie restoration will attempt to re-select the resource we were showing. > // Give it time to do that before selecting the main frame resource. >@@ -1395,6 +1436,39 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > return false; > } > >+ _updateBootstrapScriptTreeElement(force = false) >+ { >+ if (!WI.NetworkManager.supportsBootstrapScript()) >+ return; >+ >+ if (!WI.networkManager.bootstrapScript && !force) >+ return; >+ >+ if (this._bootstrapScriptTreeElement) >+ return; >+ >+ SourcesNavigationSidebarPanel.__bootstrapScriptRepresentedObject = {__bootstrapScript: true}; >+ const subtitle = null; >+ this._bootstrapScriptTreeElement = new WI.GeneralTreeElement(["bootstrap-script"], WI.UIString("Inspector Bootstrap Script"), subtitle, SourcesNavigationSidebarPanel.__bootstrapScriptRepresentedObject); >+ >+ let index = insertionIndexForObjectInListSortedByFunction(this._bootstrapScriptTreeElement, this._resourcesTreeOutline.children, this._boundCompareTreeElements); >+ this._resourcesTreeOutline.insertChild(this._bootstrapScriptTreeElement, index); >+ } >+ >+ _showBootstrapScriptContentView() >+ { >+ let contentView = new WI.TextContentView(WI.networkManager.bootstrapScript, "text/javascript", {readOnly: false}); >+ >+ let contentChangedDebouncer = new Debouncer((event) => { >+ WI.networkManager.bootstrapScript = contentView.textEditor.string; >+ }); >+ contentView.textEditor.addEventListener(WI.TextEditor.Event.ContentDidChange, (event) => { >+ contentChangedDebouncer.delayForTime(250, event); >+ }); >+ >+ this.contentBrowser.showContentView(contentView); >+ } >+ > _handleResourceTypeScopeBarSelectionChanged(event) > { > this.updateFilter(); >@@ -1484,6 +1558,11 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > } > } > >+ if (treeElement === this._bootstrapScriptTreeElement) { >+ this._showBootstrapScriptContentView(); >+ return; >+ } >+ > console.error("Unknown tree element", treeElement); > } > >@@ -1575,6 +1654,36 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > contextMenu.show(); > } > >+ _handleCreateResourceButtonNavigationItemMouseDown(event) >+ { >+ if (this._ignoreCreateResourceMouseDown) >+ return; >+ >+ this._ignoreCreateResourceMouseDown = true; >+ >+ let contextMenu = WI.ContextMenu.createFromEvent(event); >+ contextMenu.addBeforeShowCallback(() => { >+ this._ignoreCreateResourceMouseDown = false; >+ }); >+ >+ if (WI.NetworkManager.supportsBootstrapScript()) { >+ contextMenu.appendItem(WI.UIString("Inspector Bootstrap Script"), () => { >+ this._updateBootstrapScriptTreeElement(true); >+ this._bootstrapScriptTreeElement.revealAndSelect(); >+ }, !!this._bootstrapScriptTreeElement); >+ } >+ >+ if (InspectorBackend.domains.CSS) { >+ contextMenu.appendItem(WI.UIString("Inspector Style Sheet"), () => { >+ WI.cssManager.preferredInspectorStyleSheetForFrame(WI.networkManager.mainFrame, (styleSheet) => { >+ WI.showRepresentedObject(styleSheet); >+ }); >+ }, WI.cssManager.inspectorStyleSheetsForFrame(WI.networkManager.mainFrame).length); >+ } >+ >+ contextMenu.show(); >+ } >+ > _handleResourceGroupingModeChanged(event) > { > this._workerTargetTreeElementMap.clear(); >@@ -1599,6 +1708,8 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W > if (script.sourceMaps.length && WI.SourcesNavigationSidebarPanel.shouldPlaceResourcesAtTopLevel()) > this._resourcesTreeOutline.disclosureButtons = true; > } >+ >+ this._updateBootstrapScriptTreeElement(); > } > > _handleFrameMainResourceDidChange(event) >diff --git a/Source/WebInspectorUI/UserInterface/Views/TextContentView.js b/Source/WebInspectorUI/UserInterface/Views/TextContentView.js >index 37bc50381eb..7a9bd9c5418 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/TextContentView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/TextContentView.js >@@ -25,7 +25,7 @@ > > WI.TextContentView = class TextContentView extends WI.ContentView > { >- constructor(string, mimeType) >+ constructor(string, mimeType, options = {}) > { > super(string); > >@@ -55,7 +55,7 @@ WI.TextContentView = class TextContentView extends WI.ContentView > this._codeCoverageButtonNavigationItem.enabled = false; > this._codeCoverageButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low; > >- this._textEditor.readOnly = true; >+ this._textEditor.readOnly = options.readOnly !== undefined ? options.readOnly : true; > this._textEditor.mimeType = mimeType; > this._textEditor.string = string; > this._prettyPrintButtonNavigationItem.enabled = this._textEditor.canBeFormatted(); >diff --git a/Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js b/Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js >index 2f9f53beb78..2bbb060c558 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/TextResourceContentView.js >@@ -215,7 +215,7 @@ WI.TextResourceContentView = class TextResourceContentView extends WI.ResourceCo > this._codeCoverageButtonNavigationItem.enabled = this._textEditor.canShowCoverageHints(); > this._codeCoverageButtonNavigationItem.activated = WI.settings.enableControlFlowProfiler.value; > >- if (!this._textEditor.string) >+ if (!this._textEditor.string && this._textEditor.readOnly) > this.showGenericNoContentMessage(); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 195847
:
372249
|
381401
|
381402
|
381415
|
381442
|
381451
|
381627
|
381628
|
381631
|
381660
|
381766
|
381767