WebKit Bugzilla
Attachment 372839 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-20190625095351.patch (text/plain), 50.12 KB, created by
Devin Rousso
on 2019-06-25 09:53:52 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2019-06-25 09:53:52 PDT
Size:
50.12 KB
patch
obsolete
>diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 74bd2ffacdff0ece41da48959c8ba6cefd837c24..09e9474af8a6907c3e0e4562899eeb624a0204c9 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,36 @@ >+2019-06-25 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 alias saved results by providing a different prefix (e.g. "$") from within >+ Web Inspector. When changing the alias, all existing saved results will update to be >+ reference-able from the new alias. >+ >+ * inspector/protocol/Runtime.json: >+ Add `setSavedResultAlias` command. >+ >+ * inspector/agents/InspectorRuntimeAgent.h: >+ * inspector/agents/InspectorRuntimeAgent.cpp: >+ (Inspector::InspectorRuntimeAgent::setSavedResultAlias): Added. >+ >+ * inspector/InjectedScriptHost.h: >+ (Inspector::InjectedScriptHost::setSavedResultAlias): Added. >+ (Inspector::InjectedScriptHost::savedResultAlias const): Added. >+ * inspector/JSInjectedScriptHost.h: >+ * inspector/JSInjectedScriptHost.cpp: >+ (Inspector::JSInjectedScriptHost::savedResultAlias const): Added. >+ * inspector/JSInjectedScriptHostPrototype.cpp: >+ (Inspector::JSInjectedScriptHostPrototype::finishCreation): >+ (Inspector::jsInjectedScriptHostPrototypeAttributeSavedResultAlias): Added. >+ Store the saved result alias on the `InjectedScriptHost` since it is a shared object among >+ all `InjectedScript`. >+ >+ * inspector/InjectedScriptSource.js: >+ (BasicCommandLineAPI): >+ > 2019-06-24 Mark Lam <mark.lam@apple.com> > > ArraySlice needs to keep the source array alive. >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 30dd32961a7695dbe07b8cdbc6bd1217557a576c..db56968e9230c77e97ac2e90cc7a6640df7dbd65 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-06-25 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 alias saved results by providing a different prefix (e.g. "$") from within >+ Web Inspector. When changing the alias, all existing saved results will update to be >+ reference-able from the new alias. >+ >+ Test: inspector/runtime/setSavedResultAlias.html >+ >+ * inspector/CommandLineAPIModuleSource.js: >+ (CommandLineAPI): >+ > 2019-06-24 John Wilander <wilander@apple.com> > > Remove IsITPFirstPartyWebsiteDataRemovalEnabled as runtime check >diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index dd4d4a9c0d1f95af57215302a5ec04390c5ed460..6f6dad4b62e5e59cdc4acf0f30d990195c8fcc63 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,59 @@ >+2019-06-25 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 alias saved results by providing a different prefix (e.g. "$") from within >+ Web Inspector. When changing the alias, all existing saved results will update to be >+ reference-able from the new alias. >+ >+ * UserInterface/Controllers/RuntimeManager.js: >+ (WI.RuntimeManager): >+ (WI.RuntimeManager.preferredSavedResultPrefix): Added. >+ (WI.RuntimeManager.prototype.initializeTarget): >+ * UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js: >+ (WI.JavaScriptRuntimeCompletionProvider.completionControllerCompletionsNeeded.receivedPropertyNames): >+ >+ * UserInterface/Base/Setting.js: >+ * UserInterface/Base/Main.js: >+ (WI.contentLoaded): >+ (WI.contentLoaded.updateConsoleSavedResultPrefixCSSVariable): Added. >+ * UserInterface/Views/ConsoleMessageView.js: >+ (WI.ConsoleMessageView.prototype.toClipboardString): >+ (WI.ConsoleMessageView.prototype._appendSavedResultIndex): >+ (WI.ConsoleMessageView.prototype._appendSavedResultIndex.updateSavedVariableText): Added. >+ (WI.ConsoleMessageView.prototype._rootPropertyPathForObject): >+ (WI.ConsoleMessageView.prototype._rootPropertyPathForObject.prefixSavedResultIndex): Added. >+ * 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 alias and update any >+ related UI accordingly. >+ >+ * UserInterface/Views/SettingsTabContentView.js: >+ (WI.SettingsTabContentView.prototype._createConsoleSettingsView): >+ * 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 alias. Only allow >+ [a-zA-Z0-9_$] as values (but [0-9] cannot be used as the start). >+ >+ * 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-06-23 Matt Baker <mattbaker@apple.com> > > Web Inspector: REGRESSION (r246684): Dark Mode: dashboard buttons should have no background >diff --git a/Source/JavaScriptCore/inspector/InjectedScriptHost.h b/Source/JavaScriptCore/inspector/InjectedScriptHost.h >index 2784036ae5a0a6f8e028f55d0f828ecb4c4e24ff..8f7d374244a73ab180c9dcc2194a7e3606847402 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScriptHost.h >+++ b/Source/JavaScriptCore/inspector/InjectedScriptHost.h >@@ -27,6 +27,7 @@ > > #include "JSCJSValueInlines.h" > #include "PerGlobalObjectWrapperWorld.h" >+#include <wtf/Optional.h> > #include <wtf/RefCounted.h> > > namespace Inspector { >@@ -43,8 +44,12 @@ public: > JSC::JSValue wrapper(JSC::ExecState*, JSC::JSGlobalObject*); > void clearAllWrappers(); > >+ void setSavedResultAlias(const Optional<String>& alias) { m_savedResultAlias = alias; } >+ const Optional<String>& savedResultAlias() const { return m_savedResultAlias; } >+ > private: > PerGlobalObjectWrapperWorld m_wrappers; >+ Optional<String> m_savedResultAlias; > }; > > } // namespace Inspector >diff --git a/Source/JavaScriptCore/inspector/InjectedScriptSource.js b/Source/JavaScriptCore/inspector/InjectedScriptSource.js >index 630e5dc014595975debc7614343b42b3f57395be..561cab6d891eb02084a677c6bc43dcc089c62b7b 100644 >--- a/Source/JavaScriptCore/inspector/InjectedScriptSource.js >+++ b/Source/JavaScriptCore/inspector/InjectedScriptSource.js >@@ -1453,17 +1453,33 @@ function bind(func, thisObject, ...outerArgs) > > function BasicCommandLineAPI(callFrame) > { >- this.$_ = injectedScript._lastResult; >- this.$exception = injectedScript._exceptionValue; >+ let savedResultAlias = InjectedScriptHost.savedResultAlias; > >- if ("_eventValue" in injectedScript) >+ if ("_lastResult" in injectedScript) { >+ this.$_ = injectedScript._lastResult; >+ if (savedResultAlias) >+ this[savedResultAlias + "_"] = injectedScript._lastResult; >+ } >+ >+ if ("_exceptionValue" in injectedScript) { >+ this.$exception = injectedScript._exceptionValue; >+ if (savedResultAlias) >+ this[savedResultAlias + "exception"] = injectedScript._exceptionValue; >+ } >+ >+ if ("_eventValue" in injectedScript) { > this.$event = injectedScript._eventValue; >- else if ("$event" in this) >- delete this.$event; >+ if (savedResultAlias) >+ this[savedResultAlias + "event"] = injectedScript._eventValue; >+ } > > // $1-$99 >- for (let i = 1; i <= injectedScript._savedResults.length; ++i) >- this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i)); >+ for (let i = 1; i <= injectedScript._savedResults.length; ++i) { >+ let bound$i = bind(injectedScript._savedResult, injectedScript, i) >+ this.__defineGetter__("$" + i, bound$i); >+ if (savedResultAlias) >+ this.__defineGetter__(savedResultAlias + i, bound$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..9b7a22eeab1c71730e97d48df8be5d35f98642cb 100644 >--- a/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp >+++ b/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp >@@ -102,6 +102,14 @@ JSValue JSInjectedScriptHost::evaluate(ExecState* exec) const > return globalObject->evalFunction(); > } > >+JSValue JSInjectedScriptHost::savedResultAlias(ExecState* exec) const >+{ >+ auto savedResultAlias = impl().savedResultAlias(); >+ if (!savedResultAlias) >+ return jsUndefined(); >+ return jsString(exec, savedResultAlias.value()); >+} >+ > 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..d9978c7cd8cf077056d27d7213b9b164725ab46b 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 savedResultAlias(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..5ab1ba9d7c3e2db195b36af8dab1c0867bd62e7a 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 jsInjectedScriptHostPrototypeAttributeSavedResultAlias(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("savedResultAlias", jsInjectedScriptHostPrototypeAttributeSavedResultAlias, 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 jsInjectedScriptHostPrototypeAttributeSavedResultAlias(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->savedResultAlias(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..459d4a4e99b4a3245fc9048ad1be90ec4020d69f 100644 >--- a/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp >+++ b/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp >@@ -260,6 +260,14 @@ void InspectorRuntimeAgent::saveResult(ErrorString& errorString, const JSON::Obj > injectedScript.saveResult(errorString, callArgument.toJSONString(), savedResultIndex); > } > >+void InspectorRuntimeAgent::setSavedResultAlias(ErrorString&, const String* alias) >+{ >+ Optional<String> savedResultAlias; >+ if (alias && !alias->isEmpty()) >+ savedResultAlias = *alias; >+ m_injectedScriptManager.injectedScriptHost().setSavedResultAlias(savedResultAlias); >+} >+ > 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..16a7d9f4624a4273af612da2c5987c65a1fca24f 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 setSavedResultAlias(ErrorString&, const String* alias) 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..7eff672b4de66d9b4554bed79f1b236938578d86 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": "setSavedResultAlias", >+ "description": "Creates an additional reference to all saved values in the Console by replacing the default $ prefix with the given string.", >+ "parameters": [ >+ { "name": "alias", "type": "string", "optional": true, "description": "Passing an empty/null string will clear the alias." } >+ ] >+ }, > { > "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..dda0ba98accddeb4e107cc73f84b0f83c5919ca2 100644 >--- a/Source/WebCore/inspector/CommandLineAPIModuleSource.js >+++ b/Source/WebCore/inspector/CommandLineAPIModuleSource.js >@@ -46,16 +46,39 @@ function bind(func, thisObject, ...outerArgs) > */ > function CommandLineAPI(commandLineAPIImpl, callFrame) > { >- this.$_ = injectedScript._lastResult; >- this.$event = injectedScript._eventValue; >- this.$exception = injectedScript._exceptionValue; >+ let savedResultAlias = InjectedScriptHost.savedResultAlias; >+ >+ if ("_lastResult" in injectedScript) { >+ this.$_ = injectedScript._lastResult; >+ if (savedResultAlias) >+ this[savedResultAlias + "_"] = injectedScript._lastResult; >+ } >+ >+ if ("_exceptionValue" in injectedScript) { >+ this.$exception = injectedScript._exceptionValue; >+ if (savedResultAlias) >+ this[savedResultAlias + "exception"] = injectedScript._exceptionValue; >+ } >+ >+ if ("_eventValue" in injectedScript) { >+ this.$event = injectedScript._eventValue; >+ if (savedResultAlias) >+ this[savedResultAlias + "event"] = injectedScript._eventValue; >+ } > > // $0 >- this.__defineGetter__("$0", bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl)); >+ let bound$0 = bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl); >+ this.__defineGetter__("$0", bound$0); >+ if (savedResultAlias) >+ this.__defineGetter__(savedResultAlias + "0", bound$0); > > // $1-$99 >- for (let i = 1; i <= injectedScript._savedResults.length; ++i) >- this.__defineGetter__("$" + i, bind(injectedScript._savedResult, injectedScript, i)); >+ for (let i = 1; i <= injectedScript._savedResults.length; ++i) { >+ let bound$i = bind(injectedScript._savedResult, injectedScript, i) >+ this.__defineGetter__("$" + i, bound$i); >+ if (savedResultAlias) >+ this.__defineGetter__(savedResultAlias + i, bound$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 29c1ebdb9abe7509fb5346ca2040964d8c2fa589..2620662a206cf888df350fcae35348751131cc5f 100644 >--- a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >+++ b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >@@ -448,7 +448,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["Expand All"] = "Expand All"; > localizedStrings["Expand columns"] = "Expand columns"; >@@ -904,6 +904,7 @@ localizedStrings["Save Image"] = "Save Image"; > localizedStrings["Save Selected"] = "Save Selected"; > localizedStrings["Save configuration"] = "Save configuration"; > localizedStrings["Saved Recordings"] = "Saved Recordings"; >+localizedStrings["Saved Result Alias:"] = "Saved Result Alias:"; > localizedStrings["Saved States"] = "Saved States"; > localizedStrings["Scheduling:"] = "Scheduling:"; > localizedStrings["Scheme"] = "Scheme"; >diff --git a/Source/WebInspectorUI/UserInterface/Base/Main.js b/Source/WebInspectorUI/UserInterface/Base/Main.js >index 5bfde51548f7f26a7baed1b9a447e8d52cb6657c..14ae9f2e4938a25f21cda2bf3f5c4560ee5867f1 100644 >--- a/Source/WebInspectorUI/UserInterface/Base/Main.js >+++ b/Source/WebInspectorUI/UserInterface/Base/Main.js >@@ -572,6 +572,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.RuntimeManager.preferredSavedResultPrefix() + "\""); >+ } >+ WI.settings.consoleSavedResultAlias.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 bfa983806359e22083863b7fe6dc0e6fde2a50d3..41302dee00d8b8b45f6b9d6f891f840d08ee501d 100644 >--- a/Source/WebInspectorUI/UserInterface/Base/Setting.js >+++ b/Source/WebInspectorUI/UserInterface/Base/Setting.js >@@ -143,6 +143,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), >+ consoleSavedResultAlias: new WI.Setting("console-saved-result-alias", ""), > 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/Controllers/JavaScriptRuntimeCompletionProvider.js b/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js >index 9f21a88e657562eba4c3c17b85c7ecd2c245d959..beee9de40950b158fdcf3732895318cbea1685d9 100644 >--- a/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js >+++ b/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js >@@ -229,9 +229,19 @@ WI.JavaScriptRuntimeCompletionProvider = class JavaScriptRuntimeCompletionProvid > for (let name of commandLineAPI) > propertyNames[name] = true; > >+ let savedResultAlias = WI.settings.consoleSavedResultAlias.value; >+ if (savedResultAlias) { >+ propertyNames[savedResultAlias + "0"] = true; >+ propertyNames[savedResultAlias + "_"] = 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) >+ for (var i = 1; i <= WI.ConsoleCommandResultMessage.maximumSavedResultIndex; ++i) { > propertyNames["$" + i] = true; >+ >+ if (savedResultAlias) >+ propertyNames[savedResultAlias + i] = true; >+ } > } > > propertyNames = Object.keys(propertyNames); >diff --git a/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js b/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js >index be5f3dec41b958c7c903f18c806911fbfd078352..d214c8b20425e4a0c73db86051e83b6b9f4c2a40 100644 >--- a/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js >+++ b/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js >@@ -31,6 +31,14 @@ WI.RuntimeManager = class RuntimeManager extends WI.Object > > this._activeExecutionContext = null; > >+ WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, (event) => { >+ for (let target of WI.targets) { >+ // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultAlias did not exist. >+ if (target.RuntimeAgent.setSavedResultAlias) >+ target.RuntimeAgent.setSavedResultAlias(WI.settings.consoleSavedResultAlias.value); >+ } >+ }); >+ > WI.Frame.addEventListener(WI.Frame.Event.ExecutionContextsCleared, this._frameExecutionContextsCleared, this); > } > >@@ -42,6 +50,14 @@ WI.RuntimeManager = class RuntimeManager extends WI.Object > return !!InspectorBackend.domains.Runtime.awaitPromise; > } > >+ static preferredSavedResultPrefix() >+ { >+ // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultAlias did not exist. >+ if (!InspectorBackend.domains.Runtime.setSavedResultAlias) >+ return "$"; >+ return WI.settings.consoleSavedResultAlias.value || "$"; >+ } >+ > // Target > > initializeTarget(target) >@@ -52,9 +68,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.setSavedResultAlias did not exist. >+ if (target.RuntimeAgent.setSavedResultAlias && WI.settings.consoleSavedResultAlias.value) >+ target.RuntimeAgent.setSavedResultAlias(WI.settings.consoleSavedResultAlias.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/ConsoleMessageView.js b/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js >index 7f6f93bc0a6ae98a732a629d04f5cd8662021e3d..6551a39c898b7051ab8c0f686cf0d7fb48efc278 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.RuntimeManager.preferredSavedResultPrefix()}\\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.RuntimeManager.preferredSavedResultPrefix() + savedResultIndex; >+ } >+ WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, updateSavedVariableText); >+ updateSavedVariableText(); > > if (this._objectTree) > this._objectTree.appendTitleSuffix(savedVariableElement); >@@ -664,10 +670,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.RuntimeManager.preferredSavedResultPrefix() + savedResultIndex; >+ } >+ >+ let propertyPath = new WI.PropertyPath(object, prefixSavedResultIndex()); >+ >+ WI.settings.consoleSavedResultAlias.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 a340188c95e4b26f97b83e343ec5be94237fa6de..512d65b2c3ef97939757bef701c31ee065f52e22 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 01eea3d828b0a612408158826a4200b70e39e551..9b7414c96a7b170768d2acb30a09102eccb1dbca 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 = []; >@@ -71,6 +71,8 @@ WI.QuickConsole = class QuickConsole extends WI.View > > this.initializeMainExecutionContextPathComponent(); > >+ WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, this._updateAutomaticExecutionContextPathComponentTooltip, this); >+ > WI.consoleDrawer.toggleButtonShortcutTooltip(this._toggleOrFocusKeyboardShortcut); > WI.consoleDrawer.addEventListener(WI.ConsoleDrawer.Event.CollapsedStateChanged, this._updateStyles, this); > >@@ -98,6 +100,7 @@ WI.QuickConsole = class QuickConsole extends WI.View > > closed() > { >+ WI.settings.consoleSavedResultAlias.removeEventListener(null, null, this); > WI.Frame.removeEventListener(null, null, this); > WI.debuggerManager.removeEventListener(null, null, this); > WI.runtimeManager.removeEventListener(null, null, this); >@@ -164,6 +167,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.RuntimeManager.preferredSavedResultPrefix() + "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..43f00f8783e0d8f6f5c4a0aa5e6faf59843b83d3 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SettingsGroup.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SettingsGroup.js >@@ -64,4 +64,11 @@ WI.SettingsGroup = class SettingsGroup extends WI.Object > this._editorGroupElement.append(editor.element); > return editor; > } >+ >+ addCustomEditor() >+ { >+ let element = this._editorGroupElement.appendChild(document.createElement("div")); >+ element.classList.add("editor"); >+ return element; >+ } > }; >diff --git a/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.css b/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.css >index ebfab86f39c49b4a34935834951eb1b06eb8fe09..345d7b9b7f758f7f5728c02a2f291dd3f1995e73 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.css >+++ b/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.css >@@ -128,6 +128,15 @@ > --settings-editor-child-margin-top: -2px; > } > >+.content-view.settings > .settings-view > .container > .editor-group > .editor input[type="text"] { >+ padding-top: 0; >+ padding-bottom: 0; >+ vertical-align: 1px; >+ >+ /* Vertically align <input> with the group title text. */ >+ --settings-editor-child-margin-top: -2px; >+} >+ > @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 14aadeddc05d8b6d930e0adf5e205730161ffb90..7adca32fc4aa93d52051e305272b9f08b297773e 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js >@@ -260,6 +260,26 @@ WI.SettingsTabContentView = class SettingsTabContentView extends WI.TabContentVi > { > let consoleSettingsView = new WI.SettingsView("console", WI.UIString("Console")); > >+ // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultAlias did not exist. >+ if (InspectorBackend.domains.Runtime.setSavedResultAlias) { >+ let consoleSavedResultAliasEditor = consoleSettingsView.addGroupWithCustomEditor(WI.UIString("Saved Result Alias:")); >+ >+ let consoleSavedResultAliasInput = consoleSavedResultAliasEditor.appendChild(document.createElement("input")); >+ consoleSavedResultAliasInput.type = "text"; >+ consoleSavedResultAliasInput.placeholder = WI.unlocalizedString("temp"); >+ consoleSavedResultAliasInput.addEventListener("keydown", (event) => { >+ if (!/[a-zA-Z0-9_$]/.test(event.key) || (consoleSavedResultAliasInput.selectionStart === 0 && /[0-9]/.test(event.key))) { >+ event.preventDefault(); >+ InspectorFrontendHost.beep(); >+ } >+ }); >+ consoleSavedResultAliasInput.addEventListener("input", (event) => { >+ WI.settings.consoleSavedResultAlias.value = consoleSavedResultAliasInput.value; >+ }); >+ >+ consoleSettingsView.addSeparator(); >+ } >+ > consoleSettingsView.addSetting(WI.UIString("Traces:"), WI.settings.consoleAutoExpandTrace, WI.UIString("Auto-expand")); > > if (WI.ConsoleManager.supportsLogChannels()) { >diff --git a/Source/WebInspectorUI/UserInterface/Views/SettingsView.js b/Source/WebInspectorUI/UserInterface/Views/SettingsView.js >index 02e8859b5dc4d2a6aaef65e38700f0085b6f0fa1..d953ee3d02276632eef096e0d6030f8224de84ff 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/SettingsView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/SettingsView.js >@@ -52,6 +52,12 @@ WI.SettingsView = class SettingsView extends WI.View > return settingsGroup.addCustomSetting(editorType, options); > } > >+ addGroupWithCustomEditor(title, element) >+ { >+ let settingsGroup = this.addGroup(title); >+ return settingsGroup.addCustomEditor(); >+ } >+ > addGroup(title) > { > let settingsGroup = new WI.SettingsGroup(title); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 480a9e867b6f4e8563d25dd761d7da8c07d90e70..0382b3e45605b21bfbde097f38ae275af587487a 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,23 @@ >+2019-06-25 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 alias saved results by providing a different prefix (e.g. "$") from within >+ Web Inspector. When changing the alias, all existing saved results will update to be >+ reference-able from the new alias. >+ >+ * inspector/runtime/setSavedResultAlias.html: Added. >+ * inspector/runtime/setSavedResultAlias-expected.txt: Added. >+ * http/tests/inspector/dom/cross-domain-inspected-node-access.html: >+ * inspector/console/command-line-api.html: >+ * inspector/console/command-line-api-exception.html: >+ * inspector/console/command-line-api-exception-expected.txt: >+ * inspector/console/command-line-api-exception-nested-catch.html: >+ * inspector/console/command-line-api-exception-nested-catch-expected.txt: >+ > 2019-06-24 Jer Noble <jer.noble@apple.com> > > iOS 12.2 Drawing portrait video to canvas is sideways >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..3bd23af3c74355a7974da48e5e3570166694c8f5 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 53: 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 53: 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..f7994dab7dd5d0df7f765b3ca15f546dd487ddd4 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 21: 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/debugger/command-line-api-exception-expected.txt b/LayoutTests/inspector/debugger/command-line-api-exception-expected.txt >index 7075e973d7fbda2a1c16e765622a35adbfbdd56c..2b798e313e4b8a353904b19f337d58bdd886afc8 100644 >--- a/LayoutTests/inspector/debugger/command-line-api-exception-expected.txt >+++ b/LayoutTests/inspector/debugger/command-line-api-exception-expected.txt >@@ -15,7 +15,8 @@ Checks that $exception is available and accurate in evaluations when paused on a > > == Running test suite: CommandLineAPI.$exception > -- Running test case: BeforeExceptions >-PASS: $exception should be undefined if there is no exception. >+PASS: $exception should throw an error if there is no exception. >+ReferenceError: Can't find variable: $exception > > -- Running test case: UncaughtTypeException > $exception => TypeError: undefined is not an object (evaluating '[].x.x') >@@ -69,5 +70,6 @@ PASS: `$exception` should be equal to `e`. > $exception => Object > > -- Running test case: AfterExceptions >-PASS: $exception should be undefined if there is no exception. >+PASS: $exception should throw an error if there is no exception. >+ReferenceError: Can't find variable: $exception > >diff --git a/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch-expected.txt b/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch-expected.txt >index 0cb99ba399dc65c71639bb44f86662b381c32a94..7e317ac401c00bb7ef60c3bf41e9e24f3e9d281f 100644 >--- a/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch-expected.txt >+++ b/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch-expected.txt >@@ -5,7 +5,8 @@ Checks that $exception is the value of the current exception, even in nested cat > > == Running test suite: CommandLineAPI.$exception > -- Running test case: EmptyBefore >-PASS: $exception should be undefined if there is no exception. >+PASS: $exception should throw an error if there is no exception. >+ReferenceError: Can't find variable: $exception > > -- Running test case: CheckExceptionInsideNestedCatchBlocks > OUTER 1: $exception => outer exception >@@ -16,5 +17,6 @@ OUTER 2: $exception => outer exception > CATCH: $exception === e1 ? true > > -- Running test case: EmptyAfter >-PASS: $exception should be undefined if there is no exception. >+PASS: $exception should throw an error if there is no exception. >+ReferenceError: Can't find variable: $exception > >diff --git a/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html b/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html >index 53e6372a3cb04f5678452afe7c8cdd63f447fc74..7e9166dbdcdd9fc2c4b80f8e068b1c145749f2bf 100644 >--- a/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html >+++ b/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html >@@ -27,10 +27,11 @@ function test() > > suite.addTestCase({ > name: "EmptyBefore", >- description: "Without exceptions, $exception should be undefined", >+ description: "Without exceptions, $exception should not be defined", > test(resolve, reject) { > WI.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => { >- InspectorTest.expectThat(result.description === "undefined", "$exception should be undefined if there is no exception."); >+ InspectorTest.expectThat(wasThrown, "$exception should throw an error if there is no exception."); >+ InspectorTest.log(result.description); > resolve(); > }); > } >@@ -87,10 +88,11 @@ function test() > > suite.addTestCase({ > name: "EmptyAfter", >- description: "Without exceptions, $exception should be undefined", >+ description: "Without exceptions, $exception should not be defined", > test(resolve, reject) { > WI.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => { >- InspectorTest.expectThat(result.description === "undefined", "$exception should be undefined if there is no exception."); >+ InspectorTest.expectThat(wasThrown, "$exception should throw an error if there is no exception."); >+ InspectorTest.log(result.description); > resolve(); > }); > } >diff --git a/LayoutTests/inspector/debugger/command-line-api-exception.html b/LayoutTests/inspector/debugger/command-line-api-exception.html >index d982daa956074de3748cec72ce210d8d1a9a5e58..43ed6dbfc913679ccf511642acd2cf74c8a90c8b 100644 >--- a/LayoutTests/inspector/debugger/command-line-api-exception.html >+++ b/LayoutTests/inspector/debugger/command-line-api-exception.html >@@ -18,7 +18,8 @@ function test() > name, description: "Without exceptions, $exception should be undefined", > test(resolve, reject) { > WI.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => { >- InspectorTest.expectThat(result.description === "undefined", "$exception should be undefined if there is no exception."); >+ InspectorTest.expectThat(wasThrown, "$exception should throw an error if there is no exception."); >+ InspectorTest.log(result.description); > resolve(); > }); > } >diff --git a/LayoutTests/inspector/runtime/setSavedResultAlias-expected.txt b/LayoutTests/inspector/runtime/setSavedResultAlias-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..bca810f7bc773fd34aa8b86b5f0e4275ae7fc3f6 >--- /dev/null >+++ b/LayoutTests/inspector/runtime/setSavedResultAlias-expected.txt >@@ -0,0 +1,28 @@ >+Tests for the Runtime.setSavedResultAlias command. >+ >+ >+== Running test suite: Runtime.setSavedResultAlias >+-- Running test case: Runtime.setSavedResultAlias >+Saving value... >+ >+Getting saved value at '$1'... >+PASS: Saved value should match $1. >+Getting saved value at 'temp1'... >+PASS: Should produce an exception. >+Error: ReferenceError: Can't find variable: temp1 >+ >+Changing saved result alias to "temp"... >+ >+Getting saved value at '$1'... >+PASS: Saved value should still match $1. >+Getting saved value at 'temp1'... >+PASS: Saved value should now match temp1. >+ >+Changing saved result alias to ""... >+ >+Getting saved value at '$1'... >+PASS: Saved value should still match $1. >+Getting saved value at 'temp1'... >+PASS: Should produce an exception. >+Error: ReferenceError: Can't find variable: temp1 >+ >diff --git a/LayoutTests/inspector/runtime/setSavedResultAlias.html b/LayoutTests/inspector/runtime/setSavedResultAlias.html >new file mode 100644 >index 0000000000000000000000000000000000000000..6c960dc65fb2b241d0b30027d45286f40e4748e4 >--- /dev/null >+++ b/LayoutTests/inspector/runtime/setSavedResultAlias.html >@@ -0,0 +1,73 @@ >+<!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, >+ }); >+ if (wasThrown) >+ throw new Error(result.description); >+ return result.value; >+ } >+ >+ async function changeSavedResultAlias(alias) { >+ InspectorTest.log(`Changing saved result alias to "${alias}"...`); >+ await RuntimeAgent.setSavedResultAlias(alias); >+ } >+ >+ let suite = InspectorTest.createAsyncSuite("Runtime.setSavedResultAlias"); >+ >+ suite.addTestCase({ >+ name: "Runtime.setSavedResultAlias", >+ 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 $${savedResultIndex}.`); >+ await InspectorTest.expectException(() => getSavedResult("temp", savedResultIndex)); >+ >+ InspectorTest.newline(); >+ >+ await changeSavedResultAlias("temp"); >+ >+ InspectorTest.newline(); >+ >+ InspectorTest.expectEqual(value, await getSavedResult("$", savedResultIndex), `Saved value should still match $${savedResultIndex}.`); >+ InspectorTest.expectEqual(value, await getSavedResult("temp", savedResultIndex), `Saved value should now match temp${savedResultIndex}.`); >+ >+ InspectorTest.newline(); >+ >+ await changeSavedResultAlias(""); >+ >+ InspectorTest.newline(); >+ >+ InspectorTest.expectEqual(value, await getSavedResult("$", savedResultIndex), `Saved value should still match $${savedResultIndex}.`); >+ await InspectorTest.expectException(() => getSavedResult("temp", savedResultIndex)); >+ }, >+ }); >+ >+ suite.runTestCasesAndFinish(); >+} >+</script> >+</head> >+<body onload="runTest()"> >+ <p>Tests for the Runtime.setSavedResultAlias 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