2014-08-14 01:13:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Apple Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
{
|
2016-09-05 05:02:38 +00:00
|
|
|
"extends": "eslint:recommended",
|
2014-08-14 01:13:15 +00:00
|
|
|
"env": {
|
|
|
|
"browser": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
"worker": true,
|
2017-10-13 23:52:34 +00:00
|
|
|
"es6": true,
|
|
|
|
},
|
|
|
|
"parserOptions": {
|
2021-02-18 20:46:59 +00:00
|
|
|
"ecmaVersion": 2021,
|
2014-08-14 01:13:15 +00:00
|
|
|
},
|
|
|
|
"globals": {
|
2017-10-13 23:52:34 +00:00
|
|
|
// Namespace
|
|
|
|
"WI": true,
|
|
|
|
|
2016-09-05 05:01:57 +00:00
|
|
|
// WebInspector
|
|
|
|
"AsyncTestSuite": true,
|
2019-02-25 03:04:01 +00:00
|
|
|
"Debouncer": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
"Formatter": true,
|
|
|
|
"FormatterContentBuilder": true,
|
|
|
|
"FrontendTestHarness": true,
|
|
|
|
"InspectorBackend": true,
|
|
|
|
"InspectorBackendClass": true,
|
|
|
|
"InspectorFrontendAPI": true,
|
|
|
|
"InspectorFrontendHost": true,
|
|
|
|
"InspectorProtocol": true,
|
|
|
|
"InspectorTest": true,
|
2019-03-11 21:56:32 +00:00
|
|
|
"Multimap": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
"ProtocolTest": true,
|
|
|
|
"ProtocolTestHarness": true,
|
|
|
|
"SyncTestSuite": true,
|
|
|
|
"TestHarness": true,
|
|
|
|
"TestSuite": true,
|
2019-02-25 03:04:01 +00:00
|
|
|
"Throttler": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
|
|
|
|
// Externals
|
|
|
|
"CodeMirror": true,
|
2017-10-13 23:52:34 +00:00
|
|
|
"THREE": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
"esprima": true,
|
|
|
|
|
2017-10-13 23:52:34 +00:00
|
|
|
// Formatters
|
2019-06-06 23:35:12 +00:00
|
|
|
"CSSFormatter": true,
|
2017-10-13 23:52:34 +00:00
|
|
|
"ESTreeWalker": true,
|
|
|
|
"EsprimaFormatter": true,
|
|
|
|
"FormatterWorker": true,
|
|
|
|
|
|
|
|
// Heap Snapshot
|
|
|
|
"HeapSnapshot": true,
|
|
|
|
"HeapSnapshotDiff": true,
|
|
|
|
"HeapSnapshotWorker": true,
|
|
|
|
|
2016-09-05 05:01:57 +00:00
|
|
|
// DOM
|
|
|
|
"CSSPrimitiveValue": true,
|
|
|
|
"Exception": true,
|
2015-03-30 16:29:18 +00:00
|
|
|
"WebKitPoint": true,
|
2018-09-10 23:47:05 +00:00
|
|
|
"SQLError": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
|
|
|
|
// Utilities
|
2017-10-13 23:52:34 +00:00
|
|
|
"appendWebInspectorConsoleEvaluationSourceURL": true,
|
|
|
|
"appendWebInspectorSourceURL": true,
|
|
|
|
"clamp": true,
|
|
|
|
"doubleQuotedString": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
"ellipsis": true,
|
|
|
|
"emDash": true,
|
|
|
|
"enDash": true,
|
2017-10-13 23:52:34 +00:00
|
|
|
"figureDash": true,
|
|
|
|
"handlePromiseException": true,
|
2015-03-30 16:29:18 +00:00
|
|
|
"insertionIndexForObjectInListSortedByFunction": true,
|
2017-10-13 23:52:34 +00:00
|
|
|
"insertObjectIntoSortedArray": true,
|
|
|
|
"isEmptyObject": true,
|
|
|
|
"isEnterKey": true,
|
2015-03-30 16:29:18 +00:00
|
|
|
"isFunctionStringNativeCode": true,
|
2017-10-13 23:52:34 +00:00
|
|
|
"isTextLikelyMinified": true,
|
Web Inspector: provide a way to inject "bootstrap" JavaScript into the page as the first script executed
https://bugs.webkit.org/show_bug.cgi?id=195847
<rdar://problem/48950551>
Reviewed by Joseph Pecoraro.
Source/JavaScriptCore:
When debugging webpages, it's often useful to be able to swizzle various functions in order
to add extra logs for when they're called (e.g. `Event.prototype.preventDefault`). Sometimes
this can be difficult, such as if the page saves a copy of the function and references that
instead, in which case it would be helpful to have a way to guarantee that the swizzled code
is the first thing evaluated after the context is created.
This change adds support for that concept, which has been named Inspector Bootstrap Script.
Once created, it will be injected as the first user script to every new global object that
is created afterwards. Modifications to the Inspector Bootstrap Script take effect for all
new global objects created _after_ the modification happened.
* inspector/protocol/Page.json:
Add `setBoostrapScript` command.
Source/WebCore:
When debugging webpages, it's often useful to be able to swizzle various functions in order
to add extra logs for when they're called (e.g. `Event.prototype.preventDefault`). Sometimes
this can be difficult, such as if the page saves a copy of the function and references that
instead, in which case it would be helpful to have a way to guarantee that the swizzled code
is the first thing evaluated after the context is created.
This change adds support for that concept, which has been named Inspector Bootstrap Script.
Once created, it will be injected as the first user script to every new global object that
is created afterwards. Modifications to the Inspector Bootstrap Script take effect for all
new global objects created _after_ the modification happened.
Tests: inspector/page/setBootstrapScript-main-frame.html
inspector/page/setBootstrapScript-sub-frame.html
* inspector/agents/InspectorPageAgent.h:
* inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::setBootstrapScript): Added.
(WebCore::InspectorPageAgent::didClearWindowObjectInWorld): Added.
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didClearWindowObjectInWorldImpl):
* inspector/agents/page/PageDebuggerAgent.h:
* inspector/agents/page/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::didClearWindowObjectInWorld): Added.
(WebCore::PageDebuggerAgent::didClearMainFrameWindowObject): Deleted.
* inspector/agents/page/PageRuntimeAgent.h:
* inspector/agents/page/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::didClearWindowObjectInWorld): Added.
(WebCore::PageRuntimeAgent::didCreateMainWorldContext): Deleted.
Rename existing global object creation "notifications" for more consistency between agents.
Source/WebInspectorUI:
When debugging webpages, it's often useful to be able to swizzle various functions in order
to add extra logs for when they're called (e.g. `Event.prototype.preventDefault`). Sometimes
this can be difficult, such as if the page saves a copy of the function and references that
instead, in which case it would be helpful to have a way to guarantee that the swizzled code
is the first thing evaluated after the context is created.
This change adds support for that concept, which has been named Inspector Bootstrap Script.
Once created, it will be injected as the first user script to every new global object that
is created afterwards. Modifications to the Inspector Bootstrap Script take effect for all
new global objects created _after_ the modification happened.
* UserInterface/Controllers/NetworkManager.js:
(WI.NetworkManager):
(WI.NetworkManager.supportsBootstrapScript): Added.
(WI.NetworkManager.get bootstrapScriptURL): Added.
(WI.NetworkManager.get bootstrapScriptSourceObjectStoreKey): Added.
(WI.NetworkManager.prototype.initializeTarget):
(WI.NetworkManager.prototype.get bootstrapScript): Added.
(WI.NetworkManager.prototype.get bootstrapScriptEnabled): Added.
(WI.NetworkManager.prototype.set bootstrapScriptEnabled): Added.
(WI.NetworkManager.prototype.async createBootstrapScript): Added.
(WI.NetworkManager.prototype.destroyBootstrapScript): Added.
(WI.NetworkManager.prototype._processServiceWorkerConfiguration):
(WI.NetworkManager.prototype._handleBootstrapScriptContentDidChange): Added.
* UserInterface/Models/LocalScript.js:
(WI.LocalScript):
(WI.LocalScript.prototype.get editable): Added.
(WI.LocalScript.prototype.get supportsScriptBlackboxing): Added.
(WI.LocalScript.prototype.requestContentFromBackend):
(WI.LocalScript.prototype.handleCurrentRevisionContentChange): Added.
* UserInterface/Views/ScriptContentView.js:
(WI.ScriptContentView):
(WI.ScriptContentView.prototype._contentWillPopulate):
(WI.ScriptContentView.prototype._contentDidPopulate):
(WI.ScriptContentView.prototype._handleTextEditorContentDidChange): Added.
Support editing of `WI.LocalScript` that are specifically marked as such.
* UserInterface/Models/Script.js:
(WI.Script):
(WI.Script.prototype.get displayName):
(WI.Script.prototype.get displayURL):
(WI.Script.prototype.isMainResource):
(WI.Script.prototype._resolveResource):
* UserInterface/Views/SourceCodeTextEditor.js:
(WI.SourceCodeTextEditor.prototype.customPerformSearch):
(WI.SourceCodeTextEditor.prototype._createTypeTokenAnnotator):
(WI.SourceCodeTextEditor.prototype._createBasicBlockAnnotator):
Allow a `WI.Script` to not have an associated `WI.Target`, specifically for `WI.LocalScript`.
* UserInterface/Views/SourcesNavigationSidebarPanel.js:
(WI.SourcesNavigationSidebarPanel):
(WI.SourcesNavigationSidebarPanel.prototype.treeElementForRepresentedObject):
(WI.SourcesNavigationSidebarPanel.prototype.createContentTreeOutline):
(WI.SourcesNavigationSidebarPanel.prototype._compareTreeElements):
(WI.SourcesNavigationSidebarPanel.prototype._addLocalOverride): Added.
(WI.SourcesNavigationSidebarPanel.prototype._removeResourceOverride): Added.
(WI.SourcesNavigationSidebarPanel.prototype._populateCreateResourceContextMenu):
(WI.SourcesNavigationSidebarPanel.prototype._handleBootstrapScriptCreated): Added.
(WI.SourcesNavigationSidebarPanel.prototype._handleBootstrapScriptDestroyed): Added.
(WI.SourcesNavigationSidebarPanel.prototype._handleLocalResourceOverrideAdded):
(WI.SourcesNavigationSidebarPanel.prototype._handleLocalResourceOverrideRemoved):
(WI.SourcesNavigationSidebarPanel.prototype._handleDebuggerPaused):
(WI.SourcesNavigationSidebarPanel.prototype._handleDebuggerResumed):
(WI.SourcesNavigationSidebarPanel.prototype._addLocalResourceOverride): Removed.
(WI.SourcesNavigationSidebarPanel.prototype._removeLocalResourceOverride): Removed.
Add an item in the create resource context menu for creating/focusing the bootstrap script.
* UserInterface/Views/ScriptTreeElement.js:
(WI.ScriptTreeElement):
* UserInterface/Views/BootstrapScriptTreeElement.js: Added.
(WI.BootstrapScriptTreeElement):
(WI.BootstrapScriptTreeElement.prototype.onattach):
(WI.BootstrapScriptTreeElement.prototype.ondetach):
(WI.BootstrapScriptTreeElement.prototype.ondelete):
(WI.BootstrapScriptTreeElement.prototype.onspace):
(WI.BootstrapScriptTreeElement.prototype.canSelectOnMouseDown):
(WI.BootstrapScriptTreeElement.prototype.populateContextMenu):
(WI.BootstrapScriptTreeElement.prototype.updateStatus):
(WI.BootstrapScriptTreeElement.prototype._handleNetworkManagerBootstrapScriptToggled):
* UserInterface/Views/BootstrapScriptTreeElement.css: Added.
(.item.script.bootstrap .status > input[type="checkbox"]):
* UserInterface/Views/LocalResourceOverrideTreeElement.css:
(.item.resource.override .status > input[type="checkbox"]): Added.
(.item.resource.override .status > div): Removed.
Don't show the full bootstrap script URL. Instead, show "Inspector Bootstrap Script".
* UserInterface/Views/OpenResourceDialog.js:
(WI.OpenResourceDialog.prototype.didPresentDialog):
Show the bootstrap script in the open resource dialog.
* UserInterface/Base/Utilities.js:
(isWebInspectorBootstrapScript): Added.
* UserInterface/Controllers/DebuggerManager.js:
(WI.DebuggerManager.prototype.scriptDidFail):
* UserInterface/Base/ObjectStore.js:
(WI.ObjectStore.static _open):
(WI.ObjectStore.prototype.async get): Added.
Add a generalized object store that can be used for one-off values that need the larger
storage capacity of `IndexedDB`.
* .eslintrc:
* Localizations/en.lproj/localizedStrings.js:
LayoutTests:
* inspector/page/setBootstrapScript-main-frame.html: Added.
* inspector/page/setBootstrapScript-main-frame-expected.txt: Added.
* inspector/page/setBootstrapScript-sub-frame.html: Added.
* inspector/page/setBootstrapScript-sub-frame-expected.txt: Added.
* inspector/page/resources/bootstrap-iframe.html: Added.
Canonical link: https://commits.webkit.org/216764@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251531 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-24 06:54:49 +00:00
|
|
|
"isWebInspectorBootstrapScript": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
"isWebInspectorConsoleEvaluationScript": true,
|
2017-10-13 23:52:34 +00:00
|
|
|
"isWebInspectorInternalScript": true,
|
|
|
|
"isWebKitInternalScript": true,
|
|
|
|
"multiplicationSign": true,
|
|
|
|
"parseMIMEType": true,
|
|
|
|
"resolveDotsInPath": true,
|
|
|
|
"simpleGlobStringToRegExp": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
"timestamp": true,
|
2017-10-13 23:52:34 +00:00
|
|
|
"zeroWidthSpace": true,
|
|
|
|
|
|
|
|
// DOM Utilities
|
|
|
|
"createSVGElement": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
|
|
|
|
// URL Utilities
|
2015-03-30 16:29:18 +00:00
|
|
|
"absoluteURL": true,
|
2016-09-05 05:01:57 +00:00
|
|
|
"parseDataURL": true,
|
|
|
|
"parseLocationQueryParameters": true,
|
2017-10-13 23:52:34 +00:00
|
|
|
"parseQueryString": true,
|
|
|
|
"parseSecurityOrigin": true,
|
|
|
|
"parseURL": true,
|
|
|
|
"relativePath": true,
|
|
|
|
"removeURLFragment": true,
|
|
|
|
|
|
|
|
// Formatter Utilities
|
|
|
|
"isECMAScriptLineTerminator": true,
|
|
|
|
"isECMAScriptWhitespace": true,
|
|
|
|
|
|
|
|
// Debug
|
|
|
|
"handleInternalException": true,
|
|
|
|
|
|
|
|
// CodeMirror
|
|
|
|
"createCodeMirrorColorTextMarkers": true,
|
|
|
|
"createCodeMirrorCubicBezierTextMarkers": true,
|
|
|
|
"createCodeMirrorGradientTextMarkers": true,
|
|
|
|
"createCodeMirrorSpringTextMarkers": true,
|
2014-08-14 01:13:15 +00:00
|
|
|
},
|
|
|
|
"rules": {
|
2016-09-05 05:02:38 +00:00
|
|
|
"array-bracket-spacing": [2, "never"],
|
|
|
|
"block-spacing": [2, "always"],
|
|
|
|
"comma-dangle": [2, "only-multiline"],
|
|
|
|
"comma-spacing": [2, {"before": false, "after": true}],
|
|
|
|
"comma-style": [2, "last"],
|
2014-09-10 19:15:28 +00:00
|
|
|
"consistent-return": 2,
|
2014-09-10 22:13:59 +00:00
|
|
|
"curly": 0,
|
2015-03-30 16:29:18 +00:00
|
|
|
"dot-notation": 0,
|
2016-09-05 05:02:38 +00:00
|
|
|
"eol-last": 2,
|
2014-09-10 22:13:59 +00:00
|
|
|
"eqeqeq": 2,
|
2021-02-04 17:34:56 +00:00
|
|
|
"indent": ["error", 4],
|
2016-09-05 05:02:38 +00:00
|
|
|
"func-call-spacing": [2, "never"],
|
|
|
|
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
|
|
|
|
"keyword-spacing": [2, {"before": true, "after": true}],
|
2015-03-30 16:29:18 +00:00
|
|
|
"new-cap": 0,
|
2014-09-10 22:13:59 +00:00
|
|
|
"new-parens": 0,
|
|
|
|
"no-console": 0,
|
|
|
|
"no-constant-condition": 0,
|
2014-09-16 19:54:12 +00:00
|
|
|
"no-extra-bind": 2,
|
2016-09-05 05:01:57 +00:00
|
|
|
"no-extra-parens": [2, "all", {"nestedBinaryExpressions": false}],
|
2014-09-09 17:31:18 +00:00
|
|
|
"no-extra-semi": 2,
|
2016-09-05 05:02:38 +00:00
|
|
|
"no-global-assign": 2,
|
2015-03-30 16:29:18 +00:00
|
|
|
"no-inner-declarations": 0,
|
2016-09-05 05:02:38 +00:00
|
|
|
"no-multi-spaces": 2,
|
2015-03-30 16:29:18 +00:00
|
|
|
"no-new": 0,
|
2014-09-10 22:13:59 +00:00
|
|
|
"no-proto": 0,
|
2015-03-30 16:29:18 +00:00
|
|
|
"no-redeclare": 0,
|
2014-09-10 22:13:59 +00:00
|
|
|
"no-return-assign": 2,
|
2021-02-04 17:34:56 +00:00
|
|
|
"no-return-await": 2,
|
2016-09-05 05:02:38 +00:00
|
|
|
"no-self-compare": 2,
|
2015-03-30 16:29:18 +00:00
|
|
|
"no-shadow": 0,
|
2014-09-09 19:46:41 +00:00
|
|
|
"no-trailing-spaces": 2,
|
2015-03-26 00:46:57 +00:00
|
|
|
"no-undef": 2,
|
2014-08-14 01:13:15 +00:00
|
|
|
"no-underscore-dangle": 0,
|
2014-09-10 22:13:59 +00:00
|
|
|
"no-unused-expressions": 2,
|
2016-09-05 05:01:57 +00:00
|
|
|
"no-unused-vars": [2, {"vars": "all", "args": "none"}],
|
2015-03-30 16:29:18 +00:00
|
|
|
"no-use-before-define": 0,
|
2016-09-05 05:02:38 +00:00
|
|
|
"object-curly-spacing": [2, "never"],
|
2014-09-10 22:13:59 +00:00
|
|
|
"quotes": [2, "double"],
|
|
|
|
"semi": 2,
|
2016-09-05 05:02:38 +00:00
|
|
|
"semi-spacing": [2, {"before": false, "after": true}],
|
2014-09-10 22:13:59 +00:00
|
|
|
"space-infix-ops": 2,
|
2016-09-05 05:02:38 +00:00
|
|
|
"spaced-comment": [2, "always"],
|
2014-09-10 22:13:59 +00:00
|
|
|
"strict": 0,
|
|
|
|
"valid-typeof": 2,
|
2014-08-14 01:13:15 +00:00
|
|
|
}
|
|
|
|
}
|