WebKit Bugzilla
Attachment 368415 Details for
Bug 195834
: Can't use $0, $1 etc when inspecting Google Docs pages because the content uses these for function names
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-195834-20190427164651.patch (text/plain), 45.69 KB, created by
Devin Rousso
on 2019-04-27 16:46:51 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2019-04-27 16:46:51 PDT
Size:
45.69 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 28aeca460ca65580a9ae60e98de7e15fada6d41b..b5a29d1bf6d19ad1d0139179b18428460cbea927 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,36 @@ >+2019-04-27 Devin Rousso <drousso@apple.com> >+ >+ Can't use $0, $1 etc when inspecting Google Docs pages because the content uses these for function names >+ https://bugs.webkit.org/show_bug.cgi?id=195834 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Allow the user to set the saved result prefix (e.g. "$") from within Web Inspector. When >+ changing the prefix, all existing saved results will update to use the new prefix. >+ >+ * inspector/protocol/Runtime.json: >+ Add `setSavedResultPrefix` command. >+ >+ * inspector/agents/InspectorRuntimeAgent.h: >+ * inspector/agents/InspectorRuntimeAgent.cpp: >+ (Inspector::InspectorRuntimeAgent::setSavedResultPrefix): Added. >+ >+ * inspector/InjectedScriptHost.h: >+ (Inspector::InjectedScriptHost::setSavedResultPrefix): Added. >+ (Inspector::InjectedScriptHost::savedResultPrefix const): Added. >+ * inspector/JSInjectedScriptHost.h: >+ * inspector/JSInjectedScriptHost.cpp: >+ (Inspector::JSInjectedScriptHost::savedResultPrefix const): Added. >+ * inspector/JSInjectedScriptHostPrototype.cpp: >+ (Inspector::JSInjectedScriptHostPrototype::finishCreation): >+ (Inspector::jsInjectedScriptHostPrototypeAttributeSavedResultPrefix): Added. >+ Store the saved result prefix on the `InjectedScriptHost` since it is a shared object among >+ all `InjectedScript`. >+ >+ * inspector/InjectedScriptSource.js: >+ (BasicCommandLineAPI): >+ (BasicCommandLineAPI.prefix): Added. >+ > 2019-04-26 Keith Rollin <krollin@apple.com> > > Enable new build rule for post-processing headers when using XCBuild >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c00feef584fd38fb3b09640e7cd0ca10e5fb935a..d07109f8f054a8c96d3109a671ba84dafedd9153 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-04-27 Devin Rousso <drousso@apple.com> >+ >+ Can't use $0, $1 etc when inspecting Google Docs pages because the content uses these for function names >+ https://bugs.webkit.org/show_bug.cgi?id=195834 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Allow the user to set the saved result prefix (e.g. "$") from within Web Inspector. When >+ changing the prefix, all existing saved results will update to use the new prefix. >+ >+ Test: inspector/runtime/setSavedResultPrefix.html >+ >+ * inspector/CommandLineAPIModuleSource.js: >+ (CommandLineAPI): >+ (CommandLineAPI.prefix): Added. >+ > 2019-04-27 Megan Gardner <megan_gardner@apple.com> > > Lookup only looking up the first word in selection >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index bc81271021b98c587296f27d7477a5519ec7dc0a..504419037d3ac183fbdd6247aa4dbf95a84ab08a 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,66 @@ >+2019-04-27 Devin Rousso <drousso@apple.com> >+ >+ Can't use $0, $1 etc when inspecting Google Docs pages because the content uses these for function names >+ https://bugs.webkit.org/show_bug.cgi?id=195834 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Allow the user to set the saved result prefix (e.g. "$") from within Web Inspector. When >+ changing the prefix, all existing saved results will update to use the new prefix. >+ >+ * UserInterface/Controllers/RuntimeManager.js: >+ (WI.RuntimeManager): >+ (WI.RuntimeManager.prototype.initializeTarget): >+ * UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js: >+ (WI.JavaScriptRuntimeCompletionProvider.completionControllerCompletionsNeeded.receivedPropertyNames): >+ (WI.JavaScriptRuntimeCompletionProvider.completionControllerCompletionsNeeded.receivedPropertyNames.prependSavedResultPrefix): Added. >+ >+ * UserInterface/Base/Main.js: >+ (WI.contentLoaded): >+ (WI.contentLoaded.updateConsoleSavedResultPrefixCSSVariable): Added. >+ * UserInterface/Views/ConsoleMessageView.js: >+ (WI.ConsoleMessageView.prototype.toClipboardString): >+ (WI.ConsoleMessageView.prototype._appendSavedResultIndex.updateSavedVariableText): Added. >+ (WI.ConsoleMessageView.prototype._appendSavedResultIndex): >+ (WI.ConsoleMessageView.prototype._rootPropertyPathForObject.prefixSavedResultIndex): Added. >+ (WI.ConsoleMessageView.prototype._rootPropertyPathForObject): >+ * UserInterface/Views/DOMTreeOutline.css: >+ (.tree-outline.dom.show-last-selected li.last-selected > span::after): >+ * UserInterface/Views/QuickConsole.js: >+ (WI.QuickConsole): >+ (WI.QuickConsole.prototype.closed): >+ (WI.QuickConsole.prototype._updateAutomaticExecutionContextPathComponentTooltip): Added. >+ Listen for changes to the setting that holds the current saved result prefix and update any >+ related UI accordingly. >+ >+ * UserInterface/Views/SettingsTabContentView.js: >+ (WI.SettingsTabContentView.prototype._createGeneralSettingsView): >+ (WI.SettingsTabContentView.prototype._createGeneralSettingsView.updateConsoleSavedResultPrefixInput): Added. >+ * UserInterface/Views/SettingsTabContentView.css: >+ (.content-view.settings > .settings-view > .container > .editor-group > .editor input[type="text"]): Added. >+ * UserInterface/Views/SettingsGroup.js: >+ (WI.SettingsGroup.prototype.addCustomEditor): Added. >+ Add an input to the Settings tab that controls the saved result prefix value. Only allow >+ [a-zA-Z0-9_$] as values (but [0-9] cannot be used as the start). >+ >+ * UserInterface/Base/Utilities.js: >+ (HTMLInputElement.prototype.autosize): Added. >+ * UserInterface/Views/CanvasOverviewContentView.js: >+ (WI.CanvasOverviewContentView.prototype._updateRecordingAutoCaptureInputElementSize): >+ Pull logic for autosizing an `<input>` into a common function. >+ >+ * UserInterface/Base/Setting.js: >+ (WI.Setting.prototype.get defaultValue): Added. >+ * UserInterface/Models/PropertyPath.js: >+ (WI.PropertyPath.prototype.set pathComponent): Added. >+ Miscellaneous getters/setters. >+ >+ * Localizations/en.lproj/localizedStrings.js: >+ >+ * UserInterface/Test/TestHarness.js: >+ (TestHarness.prototype.newline): Added. >+ Convenience function for adding newlines to test results. >+ > 2019-04-26 Jessie Berlin <jberlin@webkit.org> > > Add new mac target numbers >diff --git a/Source/JavaScriptCore/inspector/InjectedScriptHost.h b/Source/JavaScriptCore/inspector/InjectedScriptHost.h >index 2784036ae5a0a6f8e028f55d0f828ecb4c4e24ff..fd58b709be69d6f79b17fb6a27d86c1a70093755 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScriptHost.h >+++ b/Source/JavaScriptCore/inspector/InjectedScriptHost.h >@@ -43,8 +43,12 @@ public: > JSC::JSValue wrapper(JSC::ExecState*, JSC::JSGlobalObject*); > void clearAllWrappers(); > >+ void setSavedResultPrefix(const String& prefix) { m_savedResultPrefix = prefix; } >+ const String& savedResultPrefix() const { return m_savedResultPrefix; } >+ > private: > PerGlobalObjectWrapperWorld m_wrappers; >+ String m_savedResultPrefix { "$" }; > }; > > } // namespace Inspector >diff --git a/Source/JavaScriptCore/inspector/InjectedScriptSource.js b/Source/JavaScriptCore/inspector/InjectedScriptSource.js >index 630e5dc014595975debc7614343b42b3f57395be..e6a80b76dad6783274fb34454aaf3ccac3e348bb 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScriptSource.js >+++ b/Source/JavaScriptCore/inspector/InjectedScriptSource.js >@@ -1453,17 +1453,21 @@ function bind(func, thisObject, ...outerArgs) > > function BasicCommandLineAPI(callFrame) > { >- this.$_ = injectedScript._lastResult; >- this.$exception = injectedScript._exceptionValue; >+ function prefix(string) { >+ return InjectedScriptHost.savedResultPrefix + string; >+ } >+ >+ this[prefix("_")] = injectedScript._lastResult; >+ this[prefix("exception")] = injectedScript._exceptionValue; > > if ("_eventValue" in injectedScript) >- this.$event = injectedScript._eventValue; >- else if ("$event" in this) >- delete this.$event; >+ this[prefix("event")] = injectedScript._eventValue; >+ else if (prefix("event") in this) >+ delete this[prefix("event")]; > > // $1-$99 > for (let i = 1; i <= injectedScript._savedResults.length; ++i) >- this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i)); >+ this.__defineGetter__(prefix(i), bind(injectedScript._savedResult, injectedScript, i)); > > // Command Line API methods. > for (let i = 0; i < BasicCommandLineAPI.methods.length; ++i) { >diff --git a/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp b/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp >index d9725c0d8f46e7744579551b4ff90ffa26db27e9..acaf05f74fc3d866bab9cfb779dff5cba001ea17 100644 >--- a/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp >+++ b/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp >@@ -102,6 +102,11 @@ JSValue JSInjectedScriptHost::evaluate(ExecState* exec) const > return globalObject->evalFunction(); > } > >+JSValue JSInjectedScriptHost::savedResultPrefix(ExecState* exec) const >+{ >+ return jsString(exec, impl().savedResultPrefix()); >+} >+ > JSValue JSInjectedScriptHost::evaluateWithScopeExtension(ExecState* exec) > { > VM& vm = exec->vm(); >diff --git a/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h b/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h >index 8d920f597fbe13610131d2e5c3d2d2b9ac3be31b..d5b17f358f3c92065c312857005ef8579cb10edd 100644 >--- a/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h >+++ b/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h >@@ -57,6 +57,7 @@ public: > > // Attributes. > JSC::JSValue evaluate(JSC::ExecState*) const; >+ JSC::JSValue savedResultPrefix(JSC::ExecState*) const; > > // Functions. > JSC::JSValue evaluateWithScopeExtension(JSC::ExecState*); >diff --git a/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp b/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp >index df00bfaadc11bde672ea132a1e55dca16cc7fc3c..be341f0d6c3553688173b1278da6afebd8fa5036 100644 >--- a/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp >+++ b/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp >@@ -54,6 +54,7 @@ static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionQueryOb > static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension(ExecState*); > > static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(ExecState*); >+static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeSavedResultPrefix(ExecState*); > > const ClassInfo JSInjectedScriptHostPrototype::s_info = { "InjectedScriptHost", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSInjectedScriptHostPrototype) }; > >@@ -79,6 +80,7 @@ void JSInjectedScriptHostPrototype::finishCreation(VM& vm, JSGlobalObject* globa > JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("evaluateWithScopeExtension", jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension, static_cast<unsigned>(PropertyAttribute::DontEnum), 1); > > JSC_NATIVE_GETTER_WITHOUT_TRANSITION("evaluate", jsInjectedScriptHostPrototypeAttributeEvaluate, PropertyAttribute::DontEnum | PropertyAttribute::Accessor); >+ JSC_NATIVE_GETTER_WITHOUT_TRANSITION("savedResultPrefix", jsInjectedScriptHostPrototypeAttributeSavedResultPrefix, PropertyAttribute::DontEnum | PropertyAttribute::Accessor); > } > > EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(ExecState* exec) >@@ -94,6 +96,19 @@ EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(Exec > return JSValue::encode(castedThis->evaluate(exec)); > } > >+EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeSavedResultPrefix(ExecState* exec) >+{ >+ VM& vm = exec->vm(); >+ auto scope = DECLARE_THROW_SCOPE(vm); >+ >+ JSValue thisValue = exec->thisValue(); >+ JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(vm, thisValue); >+ if (!castedThis) >+ return throwVMTypeError(exec, scope); >+ >+ return JSValue::encode(castedThis->savedResultPrefix(exec)); >+} >+ > EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionInternalConstructorName(ExecState* exec) > { > VM& vm = exec->vm(); >diff --git a/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp >index 1f01b101f6319f332acc17b54f0637cfdc9075f9..c6e5b971c4db7ff55bad8b5bb7cc24aecf0eb7d1 100644 >--- a/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp >+++ b/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp >@@ -260,6 +260,16 @@ void InspectorRuntimeAgent::saveResult(ErrorString& errorString, const JSON::Obj > injectedScript.saveResult(errorString, callArgument.toJSONString(), savedResultIndex); > } > >+void InspectorRuntimeAgent::setSavedResultPrefix(ErrorString& errorString, const String& prefix) >+{ >+ if (prefix.isEmpty()) { >+ errorString = "prefix must not be empty"_s; >+ return; >+ } >+ >+ m_injectedScriptManager.injectedScriptHost().setSavedResultPrefix(prefix); >+} >+ > void InspectorRuntimeAgent::releaseObject(ErrorString&, const String& objectId) > { > InjectedScript injectedScript = m_injectedScriptManager.injectedScriptForObjectId(objectId); >diff --git a/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h >index 038f6161f603d7fd1db77ce748129563c85a99e5..cfb2ba6b816038d858569afad467a7462915c4d2 100644 >--- a/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h >+++ b/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h >@@ -68,6 +68,7 @@ public: > void getDisplayableProperties(ErrorString&, const String& objectId, const bool* generatePreview, RefPtr<JSON::ArrayOf<Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<JSON::ArrayOf<Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties) final; > void getCollectionEntries(ErrorString&, const String& objectId, const String* objectGroup, const int* startIndex, const int* numberToFetch, RefPtr<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>& entries) final; > void saveResult(ErrorString&, const JSON::Object& callArgument, const int* executionContextId, Optional<int>& savedResultIndex) final; >+ void setSavedResultPrefix(ErrorString&, const String& prefix) final; > void releaseObjectGroup(ErrorString&, const String& objectGroup) final; > void getRuntimeTypesForVariablesAtOffsets(ErrorString&, const JSON::Array& locations, RefPtr<JSON::ArrayOf<Protocol::Runtime::TypeDescription>>&) override; > void enableTypeProfiler(ErrorString&) override; >diff --git a/Source/JavaScriptCore/inspector/protocol/Runtime.json b/Source/JavaScriptCore/inspector/protocol/Runtime.json >index 6902b5ebee39d8e02ef7bb29df4b67d8a7b460eb..dc4b1675d0f0356df7796e7071e4946e13b6d64e 100644 >--- a/Source/JavaScriptCore/inspector/protocol/Runtime.json >+++ b/Source/JavaScriptCore/inspector/protocol/Runtime.json >@@ -317,6 +317,13 @@ > { "name": "savedResultIndex", "type": "integer", "optional": true, "description": "If the value was saved, this is the $n index that can be used to access the value." } > ] > }, >+ { >+ "name": "setSavedResultPrefix", >+ "description": "Replaces the default $ prefix with the given string for all values saved by the console.", >+ "parameters": [ >+ { "name": "prefix", "type": "string" } >+ ] >+ }, > { > "name": "releaseObject", > "description": "Releases remote object with given id.", >diff --git a/Source/WebCore/inspector/CommandLineAPIModuleSource.js b/Source/WebCore/inspector/CommandLineAPIModuleSource.js >index a1f7d57a2c5fc9e43191da699dd877fd8e009d4e..a07f6e0a7e577701fa07c8b74d5b422b6506d4aa 100644 >--- a/Source/WebCore/inspector/CommandLineAPIModuleSource.js >+++ b/Source/WebCore/inspector/CommandLineAPIModuleSource.js >@@ -46,16 +46,20 @@ function bind(func, thisObject, ...outerArgs) > */ > function CommandLineAPI(commandLineAPIImpl, callFrame) > { >- this.$_ = injectedScript._lastResult; >- this.$event = injectedScript._eventValue; >- this.$exception = injectedScript._exceptionValue; >+ function prefix(string) { >+ return InjectedScriptHost.savedResultPrefix + string; >+ } >+ >+ this[prefix("_")] = injectedScript._lastResult; >+ this[prefix("event")] = injectedScript._eventValue; >+ this[prefix("exception")] = injectedScript._exceptionValue; > > // $0 >- this.__defineGetter__("$0", bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl)); >+ this.__defineGetter__(prefix("0"), bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl)); > > // $1-$99 > for (let i = 1; i <= injectedScript._savedResults.length; ++i) >- this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i)); >+ this.__defineGetter__(prefix(i), bind(injectedScript._savedResult, injectedScript, i)); > > // Command Line API methods. > for (let i = 0; i < CommandLineAPI.methods.length; ++i) { >diff --git a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >index 51a6e858f70ee4b91270c9129cd8c7f1a34c815a..baa111ee1f86bf9140054858fa4526006793c943 100644 >--- a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >+++ b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >@@ -440,7 +440,7 @@ localizedStrings["Events"] = "Events"; > localizedStrings["Events:"] = "Events:"; > localizedStrings["Example: \u201C%s\u201D"] = "Example: \u201C%s\u201D"; > localizedStrings["Exception with thrown value: %s"] = "Exception with thrown value: %s"; >-localizedStrings["Execution context for $0"] = "Execution context for $0"; >+localizedStrings["Execution context for %s"] = "Execution context for %s"; > localizedStrings["Exited Full-Screen Mode"] = "Exited Full-Screen Mode"; > localizedStrings["Exited Low-Power Mode"] = "Exited Low-Power Mode"; > localizedStrings["Expand All"] = "Expand All"; >@@ -1113,6 +1113,7 @@ localizedStrings["Unsupported property name"] = "Unsupported property name"; > localizedStrings["Unsupported property value"] = "Unsupported property value"; > localizedStrings["Untitled"] = "Untitled"; > localizedStrings["Usage: %s"] = "Usage: %s"; >+localizedStrings["Use %s as the saved result prefix"] = "Use %s as the saved result prefix"; > localizedStrings["Use Default Appearance"] = "Use Default Appearance"; > localizedStrings["Use Default Media Styles"] = "Use Default Media Styles"; > localizedStrings["Use Mock Capture Devices"] = "Use Mock Capture Devices"; >diff --git a/Source/WebInspectorUI/UserInterface/Base/Main.js b/Source/WebInspectorUI/UserInterface/Base/Main.js >index 0875955f1f4db37a2e2332b8f50f17cbf5c09ecc..633f5ebc0d5032ed7e03e39305acf4b8a7d24550 100644 >--- a/Source/WebInspectorUI/UserInterface/Base/Main.js >+++ b/Source/WebInspectorUI/UserInterface/Base/Main.js >@@ -578,6 +578,12 @@ WI.contentLoaded = function() > WI.tabBar.addEventListener(WI.TabBar.Event.TabBarItemRemoved, WI._rememberOpenTabs); > WI.tabBar.addEventListener(WI.TabBar.Event.TabBarItemsReordered, WI._rememberOpenTabs); > >+ function updateConsoleSavedResultPrefixCSSVariable() { >+ document.body.style.setProperty("--console-saved-result-prefix", "\"" + WI.settings.consoleSavedResultPrefix.value + "\""); >+ } >+ WI.settings.consoleSavedResultPrefix.addEventListener(WI.Setting.Event.Changed, updateConsoleSavedResultPrefixCSSVariable); >+ updateConsoleSavedResultPrefixCSSVariable(); >+ > // Signal that the frontend is now ready to receive messages. > WI.whenTargetsAvailable().then(() => { > InspectorFrontendAPI.loadCompleted(); >diff --git a/Source/WebInspectorUI/UserInterface/Base/Setting.js b/Source/WebInspectorUI/UserInterface/Base/Setting.js >index b3c6e575e440e5b475e68534ca045a352ef25794..12cec971991aad84a4f7d1eec1893da6b0b37011 100644 >--- a/Source/WebInspectorUI/UserInterface/Base/Setting.js >+++ b/Source/WebInspectorUI/UserInterface/Base/Setting.js >@@ -67,10 +67,8 @@ WI.Setting = class Setting extends WI.Object > > // Public > >- get name() >- { >- return this._name; >- } >+ get name() { return this._name; } >+ get defaultValue() { return this._defaultValue; } > > get value() > { >@@ -128,6 +126,7 @@ WI.settings = { > canvasRecordingAutoCaptureEnabled: new WI.Setting("canvas-recording-auto-capture-enabled", false), > canvasRecordingAutoCaptureFrameCount: new WI.Setting("canvas-recording-auto-capture-frame-count", 1), > consoleAutoExpandTrace: new WI.Setting("console-auto-expand-trace", true), >+ consoleSavedResultPrefix: new WI.Setting("console-saved-result-prefix", "$"), > cssChangesPerNode: new WI.Setting("css-changes-per-node", false), > clearLogOnNavigate: new WI.Setting("clear-log-on-navigate", true), > clearNetworkOnNavigate: new WI.Setting("clear-network-on-navigate", true), >diff --git a/Source/WebInspectorUI/UserInterface/Base/Utilities.js b/Source/WebInspectorUI/UserInterface/Base/Utilities.js >index 2bd4fad60cf21647580b7cf079edd53ac36a6e21..c772773f92e3ab766e6a5c0ae3aec45aeb650fff 100644 >--- a/Source/WebInspectorUI/UserInterface/Base/Utilities.js >+++ b/Source/WebInspectorUI/UserInterface/Base/Utilities.js >@@ -426,6 +426,23 @@ Object.defineProperty(Element.prototype, "recalculateStyles", > } > }); > >+Object.defineProperty(HTMLInputElement.prototype, "autosize", >+{ >+ value(extra = 0) >+ { >+ if (!this.__cachedFont) { >+ let computedStyle = window.getComputedStyle(this); >+ this.__cachedFont = computedStyle.font; >+ } >+ >+ WI.ImageUtilities.scratchCanvasContext2D((context) => { >+ context.font = this.__cachedFont; >+ let textMetrics = context.measureText(this.value || this.placeholder); >+ this.style.setProperty("width", (textMetrics.width + extra) + "px"); >+ }); >+ } >+}); >+ > Object.defineProperty(DocumentFragment.prototype, "createChild", > { > value: Element.prototype.createChild >diff --git a/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js b/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js >index 9f21a88e657562eba4c3c17b85c7ecd2c245d959..54286b4f807046b8a587fce193045bb98775e74a 100644 >--- a/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js >+++ b/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js >@@ -229,9 +229,16 @@ WI.JavaScriptRuntimeCompletionProvider = class JavaScriptRuntimeCompletionProvid > for (let name of commandLineAPI) > propertyNames[name] = true; > >+ function prependSavedResultPrefix(string) { >+ return WI.settings.consoleSavedResultPrefix.value + string; >+ } >+ >+ propertyNames[prependSavedResultPrefix("0")] = true; >+ propertyNames[prependSavedResultPrefix("_")] = true; >+ > // FIXME: Due to caching, sometimes old $n values show up as completion results even though they are not available. We should clear that proactively. > for (var i = 1; i <= WI.ConsoleCommandResultMessage.maximumSavedResultIndex; ++i) >- propertyNames["$" + i] = true; >+ propertyNames[prependSavedResultPrefix(i)] = true; > } > > propertyNames = Object.keys(propertyNames); >@@ -307,8 +314,6 @@ WI.JavaScriptRuntimeCompletionProvider = class JavaScriptRuntimeCompletionProvid > WI.JavaScriptRuntimeCompletionProvider._commandLineAPI = [ > "$", > "$$", >- "$0", >- "$_", > "$x", > "clear", > "copy", >diff --git a/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js b/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js >index be5f3dec41b958c7c903f18c806911fbfd078352..5dd8e819911c1f9bac282cc630d53d6957763c65 100644 >--- a/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js >+++ b/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js >@@ -31,6 +31,19 @@ WI.RuntimeManager = class RuntimeManager extends WI.Object > > this._activeExecutionContext = null; > >+ WI.settings.consoleSavedResultPrefix.addEventListener(WI.Setting.Event.Changed, (event) => { >+ if (!WI.settings.consoleSavedResultPrefix.value) { >+ WI.settings.consoleSavedResultPrefix.reset(); >+ return; >+ } >+ >+ for (let target of WI.targets) { >+ // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultPrefix did not exist. >+ if (target.RuntimeAgent.setSavedResultPrefix) >+ target.RuntimeAgent.setSavedResultPrefix(WI.settings.consoleSavedResultPrefix.value); >+ } >+ }); >+ > WI.Frame.addEventListener(WI.Frame.Event.ExecutionContextsCleared, this._frameExecutionContextsCleared, this); > } > >@@ -52,9 +65,13 @@ WI.RuntimeManager = class RuntimeManager extends WI.Object > if (target.RuntimeAgent.enableTypeProfiler && WI.settings.showJavaScriptTypeInformation.value) > target.RuntimeAgent.enableTypeProfiler(); > >- // COMPATIBILITY (iOS 10): Runtime.enableControlFlowProfiler did not exist >+ // COMPATIBILITY (iOS 10): Runtime.enableControlFlowProfiler did not exist. > if (target.RuntimeAgent.enableControlFlowProfiler && WI.settings.enableControlFlowProfiler.value) > target.RuntimeAgent.enableControlFlowProfiler(); >+ >+ // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultPrefix did not exist. >+ if (target.RuntimeAgent.setSavedResultPrefix) >+ target.RuntimeAgent.setSavedResultPrefix(WI.settings.consoleSavedResultPrefix.value); > } > > // Public >diff --git a/Source/WebInspectorUI/UserInterface/Models/PropertyPath.js b/Source/WebInspectorUI/UserInterface/Models/PropertyPath.js >index 05bb03453ea59a6f73ea98d0a6c0075855eaea9b..ab43f539c63e2f43f6c3f77d30ec72ad2505b439 100644 >--- a/Source/WebInspectorUI/UserInterface/Models/PropertyPath.js >+++ b/Source/WebInspectorUI/UserInterface/Models/PropertyPath.js >@@ -55,7 +55,9 @@ WI.PropertyPath = class PropertyPath > get object() { return this._object; } > get parent() { return this._parent; } > get isPrototype() { return this._isPrototype; } >+ > get pathComponent() { return this._pathComponent; } >+ set pathComponent(pathComponent) { this._pathComponent = pathComponent; } > > get rootObject() > { >diff --git a/Source/WebInspectorUI/UserInterface/Test/TestHarness.js b/Source/WebInspectorUI/UserInterface/Test/TestHarness.js >index 64534d621bb3f3a0f6c04c43a3afbf25008043fe..0a7b7a9dc52792651292dc6a3fb0e673258d7447 100644 >--- a/Source/WebInspectorUI/UserInterface/Test/TestHarness.js >+++ b/Source/WebInspectorUI/UserInterface/Test/TestHarness.js >@@ -97,6 +97,11 @@ TestHarness = class TestHarness extends WI.Object > this.addResult(message); > } > >+ newline() >+ { >+ this.log(""); >+ } >+ > json(object, filter) > { > this.log(JSON.stringify(object, filter || null, 2)); >diff --git a/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js b/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js >index ded3cb8c1be00dbc5e3e5be83d6a0de1ce5f0fdb..6f7aa7acc8448c6781e975bb6a29e03e4cb0c9fb 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/CanvasOverviewContentView.js >@@ -265,16 +265,8 @@ WI.CanvasOverviewContentView = class CanvasOverviewContentView extends WI.Collec > this._recordingAutoCaptureFrameCountInputElementValue = frameCount; > } > >- WI.ImageUtilities.scratchCanvasContext2D((context) => { >- if (!this._recordingAutoCaptureFrameCountInputElement.__cachedFont) { >- let computedStyle = window.getComputedStyle(this._recordingAutoCaptureFrameCountInputElement); >- this._recordingAutoCaptureFrameCountInputElement.__cachedFont = computedStyle.font; >- } >- >- context.font = this._recordingAutoCaptureFrameCountInputElement.__cachedFont; >- let textMetrics = context.measureText(this._recordingAutoCaptureFrameCountInputElement.value || this._recordingAutoCaptureFrameCountInputElement.placeholder); >- this._recordingAutoCaptureFrameCountInputElement.style.setProperty("width", (textMetrics.width + (2 * CanvasOverviewContentView.recordingAutoCaptureInputMargin)) + "px"); >- }); >+ const extra = CanvasOverviewContentView.recordingAutoCaptureInputMargin * 2; >+ this._recordingAutoCaptureFrameCountInputElement.autosize(extra); > > return frameCount; > } >diff --git a/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js b/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js >index 23ac06cf9a8971530e86de37cdd18e9151f8523c..92ad5fa2c4cf72ec79d01399afe71cfdf52a86a9 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js >@@ -203,7 +203,7 @@ WI.ConsoleMessageView = class ConsoleMessageView extends WI.Object > { > let clipboardString = this._messageBodyElement.innerText.removeWordBreakCharacters(); > if (this._message.savedResultIndex) >- clipboardString = clipboardString.replace(/\s*=\s*(\$\d+)$/, ""); >+ clipboardString = clipboardString.replace(new RegExp(`\\s*=\\s*(${WI.settings.consoleSavedResultPrefix.value}\\d+)$`), ""); > > let hasStackTrace = this._shouldShowStackTrace(); > if (!hasStackTrace) { >@@ -318,7 +318,8 @@ WI.ConsoleMessageView = class ConsoleMessageView extends WI.Object > > _appendSavedResultIndex(element) > { >- if (!this._message.savedResultIndex) >+ let savedResultIndex = this._message.savedResultIndex; >+ if (!savedResultIndex) > return; > > console.assert(this._message instanceof WI.ConsoleCommandResultMessage); >@@ -326,7 +327,12 @@ WI.ConsoleMessageView = class ConsoleMessageView extends WI.Object > > var savedVariableElement = document.createElement("span"); > savedVariableElement.classList.add("console-saved-variable"); >- savedVariableElement.textContent = " = $" + this._message.savedResultIndex; >+ >+ function updateSavedVariableText() { >+ savedVariableElement.textContent = " = " + WI.settings.consoleSavedResultPrefix.value + savedResultIndex; >+ } >+ WI.settings.consoleSavedResultPrefix.addEventListener(WI.Setting.Event.Changed, updateSavedVariableText); >+ updateSavedVariableText(); > > if (this._objectTree) > this._objectTree.appendTitleSuffix(savedVariableElement); >@@ -660,10 +666,21 @@ WI.ConsoleMessageView = class ConsoleMessageView extends WI.Object > > _rootPropertyPathForObject(object) > { >- if (!this._message.savedResultIndex) >+ let savedResultIndex = this._message.savedResultIndex; >+ if (!savedResultIndex) > return null; > >- return new WI.PropertyPath(object, "$" + this._message.savedResultIndex); >+ function prefixSavedResultIndex() { >+ return WI.settings.consoleSavedResultPrefix.value + savedResultIndex; >+ } >+ >+ let propertyPath = new WI.PropertyPath(object, prefixSavedResultIndex()); >+ >+ WI.settings.consoleSavedResultPrefix.addEventListener(WI.Setting.Event.Changed, (event) => { >+ propertyPath.pathComponent = prefixSavedResultIndex(); >+ }); >+ >+ return propertyPath; > } > > _formatWithSubstitutionString(parameters, formattedResult) >diff --git a/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.css b/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.css >index f96b187f0bf49071c411c650a4dc2df5a5d3e2ea..24b5ed691cd5dc567191c086e8a9b9fe40fcb21e 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.css >+++ b/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.css >@@ -71,7 +71,7 @@ > } > > .tree-outline.dom.show-last-selected li.last-selected > span::after { >- content: " = $0"; >+ content: " = " var(--console-saved-result-prefix) "0"; > color: var(--console-secondary-text-color); > position: absolute; > white-space: pre; >diff --git a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js b/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js >index 5187b3074c16223c904891c69350f6568cb34568..0637ffd13d91992f696ae729eeadad1c1d124dff 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js >+++ b/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js >@@ -33,7 +33,7 @@ WI.QuickConsole = class QuickConsole extends WI.View > this._toggleOrFocusKeyboardShortcut.implicitlyPreventsDefault = false; > > this._automaticExecutionContextPathComponent = this._createExecutionContextPathComponent(null, WI.UIString("Auto")); >- this._automaticExecutionContextPathComponent.tooltip = WI.UIString("Execution context for $0"); >+ this._updateAutomaticExecutionContextPathComponentTooltip(); > > this._mainExecutionContextPathComponent = null; > this._otherExecutionContextPathComponents = []; >@@ -69,6 +69,8 @@ WI.QuickConsole = class QuickConsole extends WI.View > > this.initializeMainExecutionContextPathComponent(); > >+ WI.settings.consoleSavedResultPrefix.addEventListener(WI.Setting.Event.Changed, this._updateAutomaticExecutionContextPathComponentTooltip, this); >+ > WI.consoleDrawer.toggleButtonShortcutTooltip(this._toggleOrFocusKeyboardShortcut); > WI.consoleDrawer.addEventListener(WI.ConsoleDrawer.Event.CollapsedStateChanged, this._updateStyles, this); > >@@ -96,6 +98,7 @@ WI.QuickConsole = class QuickConsole extends WI.View > > closed() > { >+ WI.settings.consoleSavedResultPrefix.removeEventListener(null, null, this); > WI.Frame.removeEventListener(null, null, this); > WI.debuggerManager.removeEventListener(null, null, this); > WI.runtimeManager.removeEventListener(null, null, this); >@@ -162,6 +165,11 @@ WI.QuickConsole = class QuickConsole extends WI.View > this._automaticExecutionContextPathComponent.displayName = WI.UIString("Auto - %s").format(preferredName || executionContext.name); > } > >+ _updateAutomaticExecutionContextPathComponentTooltip() >+ { >+ this._automaticExecutionContextPathComponent.tooltip = WI.UIString("Execution context for %s").format(WI.settings.consoleSavedResultPrefix.value + "0"); >+ } >+ > _handleMouseDown(event) > { > if (event.target !== this.element) >diff --git a/Source/WebInspectorUI/UserInterface/Views/SettingsGroup.js b/Source/WebInspectorUI/UserInterface/Views/SettingsGroup.js >index e851dbbd4de2fd72da6bc9f533423ec4f2d8a423..f53b46c3e2f02c2b416c5a153753f6abc0a6cddc 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SettingsGroup.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SettingsGroup.js >@@ -64,4 +64,10 @@ WI.SettingsGroup = class SettingsGroup extends WI.Object > this._editorGroupElement.append(editor.element); > return editor; > } >+ >+ addCustomEditor(element) >+ { >+ this._editorGroupElement.append(element); >+ return element; >+ } > }; >diff --git a/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.css b/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.css >index c23f74e38fd7ae431bf4b8fa98db7ae9e42a27a9..1922e3b9ba25434391c0bb1d49c4fa4e2dfb0613 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.css >+++ b/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.css >@@ -130,6 +130,13 @@ > --settings-editor-child-margin-top: -2px; > } > >+.content-view.settings > .settings-view > .container > .editor-group > .editor input[type="text"] { >+ max-width: 48px; >+ padding-top: 0; >+ padding-bottom: 0; >+ text-align: center; >+} >+ > @media (prefers-color-scheme: dark) { > .content-view.settings .navigation-bar { > background-color: var(--background-color-content); >diff --git a/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js b/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js >index 08066cd476640c68cca97307a60f9ca3c14213d9..27b86173e38088be85104fd898e5b3d83a9f0ea8 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js >@@ -208,7 +208,43 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi > > generalSettingsView.addSetting(WI.UIString("Debugger:"), WI.settings.showScopeChainOnPause, WI.UIString("Show Scope Chain on pause")); > generalSettingsView.addSetting(WI.UIString("Source maps:"), WI.settings.sourceMapsEnabled, WI.UIString("Enable source maps")); >- generalSettingsView.addSetting(WI.UIString("Console:"), WI.settings.consoleAutoExpandTrace, WI.UIString("Auto-expand Traces")); >+ >+ let consoleGroup = generalSettingsView.addGroup(WI.UIString("Console:")); >+ consoleGroup.addSetting(WI.settings.consoleAutoExpandTrace, WI.UIString("Auto-expand Traces")); >+ >+ // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultPrefix did not exist. >+ if (InspectorBackend.domains.Runtime.setSavedResultPrefix) { >+ let consoleSavedResultPrefixEditor = consoleGroup.addCustomEditor(document.createElement("div")); >+ consoleSavedResultPrefixEditor.classList.add("editor"); >+ >+ let consoleSavedResultPrefixWrapper = consoleSavedResultPrefixEditor.appendChild(document.createElement("label")); >+ >+ const consoleSavedResultPrefixInputExtra = 8; >+ let consoleSavedResultPrefixInput = document.createElement("input"); >+ consoleSavedResultPrefixInput.type = "text"; >+ consoleSavedResultPrefixInput.placeholder = WI.settings.consoleSavedResultPrefix.defaultValue; >+ consoleSavedResultPrefixInput.addEventListener("keydown", (event) => { >+ if (!/[a-zA-Z0-9_$]/.test(event.key) || (consoleSavedResultPrefixInput.selectionStart === 0 && /[0-9]/.test(event.key))) { >+ event.preventDefault(); >+ InspectorFrontendHost.beep(); >+ } >+ }); >+ consoleSavedResultPrefixInput.addEventListener("input", (event) => { >+ WI.settings.consoleSavedResultPrefix.value = consoleSavedResultPrefixInput.value; >+ }); >+ >+ String.format(WI.UIString("Use %s as the saved result prefix"), [consoleSavedResultPrefixInput], String.standardFormatters, consoleSavedResultPrefixWrapper, (a, b) => { >+ a.append(b); >+ return a; >+ }); >+ >+ function updateConsoleSavedResultPrefixInput() { >+ consoleSavedResultPrefixInput.value = WI.settings.consoleSavedResultPrefix.value; >+ consoleSavedResultPrefixInput.autosize(consoleSavedResultPrefixInputExtra); >+ } >+ WI.settings.consoleSavedResultPrefix.addEventListener(WI.Setting.Event.Changed, updateConsoleSavedResultPrefixInput); >+ updateConsoleSavedResultPrefixInput(); >+ } > > generalSettingsView.addSeparator(); > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 52b7b788d46ddc52093166a779abaf47d92a7e4c..0c2817d4ebf51793d838d42a59b4b5676c166df8 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,18 @@ >+2019-04-27 Devin Rousso <drousso@apple.com> >+ >+ Can't use $0, $1 etc when inspecting Google Docs pages because the content uses these for function names >+ https://bugs.webkit.org/show_bug.cgi?id=195834 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Allow the user to set the saved result prefix (e.g. "$") from within Web Inspector. When >+ changing the prefix, all existing saved results will update to use the new prefix. >+ >+ * inspector/runtime/setSavedResultPrefix.html: Added. >+ * inspector/runtime/setSavedResultPrefix-expected.txt: Added. >+ * http/tests/inspector/dom/cross-domain-inspected-node-access.html: >+ * inspector/console/command-line-api.html: >+ > 2019-04-26 Youenn Fablet <youenn@apple.com> > > Use normal loading path for ping loads >diff --git a/LayoutTests/http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt b/LayoutTests/http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt >index 9f857e9cbb2774cf6fb56643ed7fedb6fb2bb831..4975a69e988521da7d4bfbba2fe546dd46d98fe5 100644 >--- a/LayoutTests/http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt >+++ b/LayoutTests/http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt >@@ -1,5 +1,5 @@ >-CONSOLE MESSAGE: line 44: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match. >-CONSOLE MESSAGE: line 44: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match. >+CONSOLE MESSAGE: line 45: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match. >+CONSOLE MESSAGE: line 45: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match. > Test that code evaluated in the main frame cannot access $0 that resolves to a node in a frame from a different domain. Bug 105423. > > >diff --git a/LayoutTests/inspector/console/command-line-api-expected.txt b/LayoutTests/inspector/console/command-line-api-expected.txt >index d3365b5efc02234038237f762f15f0c673518fb9..9775d136079d042c36529ea0c14e0c32d4532bd2 100644 >--- a/LayoutTests/inspector/console/command-line-api-expected.txt >+++ b/LayoutTests/inspector/console/command-line-api-expected.txt >@@ -1,4 +1,4 @@ >-CONSOLE MESSAGE: line 12: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s") >+CONSOLE MESSAGE: line 13: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s") > Tests that command line api works. > > >diff --git a/LayoutTests/inspector/runtime/setSavedResultPrefix-expected.txt b/LayoutTests/inspector/runtime/setSavedResultPrefix-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..f1aecfbbe1d9ec204dcbbd3c0531cb192b189595 >--- /dev/null >+++ b/LayoutTests/inspector/runtime/setSavedResultPrefix-expected.txt >@@ -0,0 +1,22 @@ >+Tests for the Runtime.setSavedResultPrefix command. >+ >+ >+== Running test suite: Runtime.setSavedResultPrefix >+-- Running test case: Runtime.setSavedResultPrefix >+Saving value... >+ >+Getting saved value at $1... >+PASS: Saved value should match $0. >+ >+Changing saved result prefix to "temp"... >+ >+Getting saved value at temp1... >+PASS: Saved value should now match $temp. >+ >+Changing saved result prefix to ""... >+PASS: Should produce an exception. >+Error: prefix must not be empty >+ >+Getting saved value at temp1... >+PASS: Saved value should still match $temp. >+ >diff --git a/LayoutTests/inspector/runtime/setSavedResultPrefix.html b/LayoutTests/inspector/runtime/setSavedResultPrefix.html >new file mode 100644 >index 0000000000000000000000000000000000000000..465adfce7bce5df06d536ae9448a92c66d0b4bc3 >--- /dev/null >+++ b/LayoutTests/inspector/runtime/setSavedResultPrefix.html >@@ -0,0 +1,71 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../http/tests/inspector/resources/inspector-test.js"></script> >+<script> >+function test() >+{ >+ function createCallArgumentWithValue(value) { >+ return {value}; >+ } >+ >+ async function getSavedResult(savedResultPrefix, savedResultIndex) { >+ InspectorTest.log(`Getting saved value at ${savedResultPrefix}${savedResultIndex}...`); >+ let {result, wasThrown} = await RuntimeAgent.evaluate.invoke({ >+ expression: savedResultPrefix + savedResultIndex, >+ objectGroup: "test", >+ includeCommandLineAPI: true, >+ returnByValue: true, >+ }); >+ InspectorTest.assert(!wasThrown); >+ return result.value; >+ } >+ >+ async function changeSavedResultPrefix(prefix) { >+ InspectorTest.log(`Changing saved result prefix to "${prefix}"...`); >+ await RuntimeAgent.setSavedResultPrefix(prefix); >+ } >+ >+ let suite = InspectorTest.createAsyncSuite("Runtime.setSavedResultPrefix"); >+ >+ suite.addTestCase({ >+ name: "Runtime.setSavedResultPrefix", >+ description: "Saving a new value should produce a new $n value.", >+ async test() { >+ const value = 123; >+ >+ InspectorTest.log("Saving value..."); >+ let {savedResultIndex} = await RuntimeAgent.saveResult(createCallArgumentWithValue(value)); >+ >+ InspectorTest.newline(); >+ >+ InspectorTest.expectEqual(value, await getSavedResult("$", savedResultIndex), "Saved value should match $0."); >+ >+ InspectorTest.newline(); >+ >+ await changeSavedResultPrefix("temp"); >+ >+ InspectorTest.newline(); >+ >+ InspectorTest.expectEqual(value, await getSavedResult("temp", savedResultIndex), "Saved value should now match $temp."); >+ >+ InspectorTest.newline(); >+ >+ await InspectorTest.expectException(async () => { >+ await changeSavedResultPrefix(""); >+ }); >+ >+ InspectorTest.newline(); >+ >+ InspectorTest.expectEqual(value, await getSavedResult("temp", savedResultIndex), "Saved value should still match $temp."); >+ }, >+ }); >+ >+ suite.runTestCasesAndFinish(); >+} >+</script> >+</head> >+<body onload="runTest()"> >+ <p>Tests for the Runtime.setSavedResultPrefix command.</p> >+</body> >+</html>
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 195834
:
368402
|
368403
|
368407
|
368409
|
368413
|
368415
|
372824
|
372827
|
372830
|
372832
|
372835
|
372839
|
375579
|
375582
|
375589
|
375594