Changeset 248287 in webkit
- Timestamp:
- Aug 5, 2019 8:37:44 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r248286 r248287 1 2019-08-05 Devin Rousso <drousso@apple.com> 2 3 Can't use $0, $1 etc when inspecting Google Docs pages because the content uses these for function names 4 https://bugs.webkit.org/show_bug.cgi?id=195834 5 6 Reviewed by Joseph Pecoraro. 7 8 Allow the user to alias saved results by providing a different prefix (e.g. "$") from within 9 Web Inspector. When changing the alias, all existing saved results will update to be 10 reference-able from the new alias. 11 12 * inspector/runtime/setSavedResultAlias.html: Added. 13 * inspector/runtime/setSavedResultAlias-expected.txt: Added. 14 * http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt: 15 * inspector/console/command-line-api-expected.txt: 16 * inspector/console/command-line-api-exception.html: 17 * inspector/console/command-line-api-exception-expected.txt: 18 * inspector/console/command-line-api-exception-nested-catch.html: 19 * inspector/console/command-line-api-exception-nested-catch-expected.txt: 20 1 21 2019-08-05 Devin Rousso <drousso@apple.com> 2 22 -
trunk/LayoutTests/http/tests/inspector/dom/cross-domain-inspected-node-access-expected.txt
r242992 r248287 1 CONSOLE MESSAGE: line 4 4: 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.2 CONSOLE MESSAGE: line 4 4: 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.1 CONSOLE MESSAGE: line 49: 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. 2 CONSOLE MESSAGE: line 49: 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. 3 3 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. 4 4 -
trunk/LayoutTests/inspector/console/command-line-api-expected.txt
r243953 r248287 1 CONSOLE MESSAGE: line 1 2: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s")1 CONSOLE MESSAGE: line 17: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $("#%s") 2 2 Tests that command line api works. 3 3 -
trunk/LayoutTests/inspector/debugger/command-line-api-exception-expected.txt
r219766 r248287 16 16 == Running test suite: CommandLineAPI.$exception 17 17 -- Running test case: BeforeExceptions 18 PASS: $exception should be undefined if there is no exception. 18 PASS: $exception should throw an error if there is no exception. 19 ReferenceError: Can't find variable: $exception 19 20 20 21 -- Running test case: UncaughtTypeException … … 70 71 71 72 -- Running test case: AfterExceptions 72 PASS: $exception should be undefined if there is no exception. 73 PASS: $exception should throw an error if there is no exception. 74 ReferenceError: Can't find variable: $exception 73 75 -
trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch-expected.txt
r202784 r248287 6 6 == Running test suite: CommandLineAPI.$exception 7 7 -- Running test case: EmptyBefore 8 PASS: $exception should be undefined if there is no exception. 8 PASS: $exception should throw an error if there is no exception. 9 ReferenceError: Can't find variable: $exception 9 10 10 11 -- Running test case: CheckExceptionInsideNestedCatchBlocks … … 17 18 18 19 -- Running test case: EmptyAfter 19 PASS: $exception should be undefined if there is no exception. 20 PASS: $exception should throw an error if there is no exception. 21 ReferenceError: Can't find variable: $exception 20 22 -
trunk/LayoutTests/inspector/debugger/command-line-api-exception-nested-catch.html
r220119 r248287 28 28 suite.addTestCase({ 29 29 name: "EmptyBefore", 30 description: "Without exceptions, $exception should be undefined",30 description: "Without exceptions, $exception should not be defined", 31 31 test(resolve, reject) { 32 32 WI.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => { 33 InspectorTest.expectThat(result.description === "undefined", "$exception should be undefined if there is no exception."); 33 InspectorTest.expectThat(wasThrown, "$exception should throw an error if there is no exception."); 34 InspectorTest.log(result.description); 34 35 resolve(); 35 36 }); … … 88 89 suite.addTestCase({ 89 90 name: "EmptyAfter", 90 description: "Without exceptions, $exception should be undefined",91 description: "Without exceptions, $exception should not be defined", 91 92 test(resolve, reject) { 92 93 WI.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => { 93 InspectorTest.expectThat(result.description === "undefined", "$exception should be undefined if there is no exception."); 94 InspectorTest.expectThat(wasThrown, "$exception should throw an error if there is no exception."); 95 InspectorTest.log(result.description); 94 96 resolve(); 95 97 }); -
trunk/LayoutTests/inspector/debugger/command-line-api-exception.html
r220119 r248287 19 19 test(resolve, reject) { 20 20 WI.runtimeManager.evaluateInInspectedWindow("$exception", {objectGroup: "test", includeCommandLineAPI: true, doNotPauseOnExceptionsAndMuteConsole: true}, (result, wasThrown) => { 21 InspectorTest.expectThat(result.description === "undefined", "$exception should be undefined if there is no exception."); 21 InspectorTest.expectThat(wasThrown, "$exception should throw an error if there is no exception."); 22 InspectorTest.log(result.description); 22 23 resolve(); 23 24 }); -
trunk/Source/JavaScriptCore/ChangeLog
r248286 r248287 1 2019-08-05 Devin Rousso <drousso@apple.com> 2 3 Can't use $0, $1 etc when inspecting Google Docs pages because the content uses these for function names 4 https://bugs.webkit.org/show_bug.cgi?id=195834 5 6 Reviewed by Joseph Pecoraro. 7 8 Allow the user to alias saved results by providing a different prefix (e.g. "$") from within 9 Web Inspector. When changing the alias, all existing saved results will update to be 10 reference-able from the new alias. 11 12 * inspector/protocol/Runtime.json: 13 Add `setSavedResultAlias` command. 14 15 * inspector/agents/InspectorRuntimeAgent.h: 16 * inspector/agents/InspectorRuntimeAgent.cpp: 17 (Inspector::InspectorRuntimeAgent::setSavedResultAlias): Added. 18 19 * inspector/InjectedScriptHost.h: 20 (Inspector::InjectedScriptHost::setSavedResultAlias): Added. 21 (Inspector::InjectedScriptHost::savedResultAlias const): Added. 22 * inspector/JSInjectedScriptHost.h: 23 * inspector/JSInjectedScriptHost.cpp: 24 (Inspector::JSInjectedScriptHost::savedResultAlias const): Added. 25 * inspector/JSInjectedScriptHostPrototype.cpp: 26 (Inspector::JSInjectedScriptHostPrototype::finishCreation): 27 (Inspector::jsInjectedScriptHostPrototypeAttributeSavedResultAlias): Added. 28 Store the saved result alias on the `InjectedScriptHost` since it is a shared object among 29 all `InjectedScript`. 30 31 * inspector/InjectedScriptSource.js: 32 (BasicCommandLineAPI): 33 1 34 2019-08-05 Devin Rousso <drousso@apple.com> 2 35 -
trunk/Source/JavaScriptCore/inspector/InjectedScriptHost.h
r228105 r248287 28 28 #include "JSCJSValueInlines.h" 29 29 #include "PerGlobalObjectWrapperWorld.h" 30 #include <wtf/Optional.h> 30 31 #include <wtf/RefCounted.h> 31 32 … … 44 45 void clearAllWrappers(); 45 46 47 void setSavedResultAlias(const Optional<String>& alias) { m_savedResultAlias = alias; } 48 const Optional<String>& savedResultAlias() const { return m_savedResultAlias; } 49 46 50 private: 47 51 PerGlobalObjectWrapperWorld m_wrappers; 52 Optional<String> m_savedResultAlias; 48 53 }; 49 54 -
trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js
r244312 r248287 1454 1454 function BasicCommandLineAPI(callFrame) 1455 1455 { 1456 this.$_ = injectedScript._lastResult; 1457 this.$exception = injectedScript._exceptionValue; 1456 let savedResultAlias = InjectedScriptHost.savedResultAlias; 1457 1458 let defineGetter = (key, value) => { 1459 if (typeof value !== "function") { 1460 let originalValue = value; 1461 value = function() { return originalValue; }; 1462 } 1463 1464 this.__defineGetter__("$" + key, value); 1465 if (savedResultAlias) 1466 this.__defineGetter__(savedResultAlias + key, value); 1467 }; 1468 1469 if ("_lastResult" in injectedScript) 1470 defineGetter("_", injectedScript._lastResult); 1471 1472 if ("_exceptionValue" in injectedScript) 1473 defineGetter("exception", injectedScript._exceptionValue); 1458 1474 1459 1475 if ("_eventValue" in injectedScript) 1460 this.$event = injectedScript._eventValue; 1461 else if ("$event" in this) 1462 delete this.$event; 1476 defineGetter("event", injectedScript._eventValue); 1463 1477 1464 1478 // $1-$99 1465 1479 for (let i = 1; i <= injectedScript._savedResults.length; ++i) 1466 this.__defineGetter__("$" +i, bind(injectedScript._savedResult, injectedScript, i));1480 defineGetter(i, bind(injectedScript._savedResult, injectedScript, i)); 1467 1481 1468 1482 // Command Line API methods. 1469 1483 for (let i = 0; i < BasicCommandLineAPI.methods.length; ++i) { 1470 1484 let method = BasicCommandLineAPI.methods[i]; 1471 this[method.name] = method; 1485 this[method] = bind(commandLineAPIImpl[method], commandLineAPIImpl); 1486 this[method].toString = function() { return "function " + method + "() { [Command Line API] }" }; 1472 1487 } 1473 1488 } -
trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp
r244312 r248287 103 103 } 104 104 105 JSValue JSInjectedScriptHost::savedResultAlias(ExecState* exec) const 106 { 107 auto savedResultAlias = impl().savedResultAlias(); 108 if (!savedResultAlias) 109 return jsUndefined(); 110 return jsString(exec, savedResultAlias.value()); 111 } 112 105 113 JSValue JSInjectedScriptHost::evaluateWithScopeExtension(ExecState* exec) 106 114 { -
trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h
r244312 r248287 58 58 // Attributes. 59 59 JSC::JSValue evaluate(JSC::ExecState*) const; 60 JSC::JSValue savedResultAlias(JSC::ExecState*) const; 60 61 61 62 // Functions. -
trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp
r246837 r248287 55 55 56 56 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(ExecState*); 57 static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeSavedResultAlias(ExecState*); 57 58 58 59 const ClassInfo JSInjectedScriptHostPrototype::s_info = { "InjectedScriptHost", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSInjectedScriptHostPrototype) }; … … 79 80 80 81 JSC_NATIVE_GETTER_WITHOUT_TRANSITION("evaluate", jsInjectedScriptHostPrototypeAttributeEvaluate, PropertyAttribute::DontEnum | PropertyAttribute::Accessor); 82 JSC_NATIVE_GETTER_WITHOUT_TRANSITION("savedResultAlias", jsInjectedScriptHostPrototypeAttributeSavedResultAlias, PropertyAttribute::DontEnum | PropertyAttribute::Accessor); 81 83 } 82 84 … … 94 96 } 95 97 98 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeSavedResultAlias(ExecState* exec) 99 { 100 VM& vm = exec->vm(); 101 auto scope = DECLARE_THROW_SCOPE(vm); 102 103 JSValue thisValue = exec->thisValue(); 104 JSInjectedScriptHost* castedThis = jsDynamicCast<JSInjectedScriptHost*>(vm, thisValue); 105 if (!castedThis) 106 return throwVMTypeError(exec, scope); 107 108 return JSValue::encode(castedThis->savedResultAlias(exec)); 109 } 110 96 111 EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionInternalConstructorName(ExecState* exec) 97 112 { -
trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp
r243243 r248287 261 261 } 262 262 263 void InspectorRuntimeAgent::setSavedResultAlias(ErrorString&, const String* alias) 264 { 265 Optional<String> savedResultAlias; 266 if (alias && !alias->isEmpty()) 267 savedResultAlias = *alias; 268 m_injectedScriptManager.injectedScriptHost().setSavedResultAlias(savedResultAlias); 269 } 270 263 271 void InspectorRuntimeAgent::releaseObject(ErrorString&, const String& objectId) 264 272 { -
trunk/Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h
r243243 r248287 69 69 void getCollectionEntries(ErrorString&, const String& objectId, const String* objectGroup, const int* startIndex, const int* numberToFetch, RefPtr<JSON::ArrayOf<Protocol::Runtime::CollectionEntry>>& entries) final; 70 70 void saveResult(ErrorString&, const JSON::Object& callArgument, const int* executionContextId, Optional<int>& savedResultIndex) final; 71 void setSavedResultAlias(ErrorString&, const String* alias) final; 71 72 void releaseObjectGroup(ErrorString&, const String& objectGroup) final; 72 73 void getRuntimeTypesForVariablesAtOffsets(ErrorString&, const JSON::Array& locations, RefPtr<JSON::ArrayOf<Protocol::Runtime::TypeDescription>>&) override; -
trunk/Source/JavaScriptCore/inspector/protocol/Runtime.json
r241633 r248287 319 319 }, 320 320 { 321 "name": "setSavedResultAlias", 322 "description": "Creates an additional reference to all saved values in the Console using the the given string as a prefix instead of $.", 323 "parameters": [ 324 { "name": "alias", "type": "string", "optional": true, "description": "Passing an empty/null string will clear the alias." } 325 ] 326 }, 327 { 321 328 "name": "releaseObject", 322 329 "description": "Releases remote object with given id.", -
trunk/Source/WebCore/ChangeLog
r248286 r248287 1 2019-08-05 Devin Rousso <drousso@apple.com> 2 3 Can't use $0, $1 etc when inspecting Google Docs pages because the content uses these for function names 4 https://bugs.webkit.org/show_bug.cgi?id=195834 5 6 Reviewed by Joseph Pecoraro. 7 8 Allow the user to alias saved results by providing a different prefix (e.g. "$") from within 9 Web Inspector. When changing the alias, all existing saved results will update to be 10 reference-able from the new alias. 11 12 Test: inspector/runtime/setSavedResultAlias.html 13 14 * inspector/CommandLineAPIModuleSource.js: 15 (CommandLineAPI): 16 1 17 2019-08-05 Devin Rousso <drousso@apple.com> 2 18 -
trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js
r243161 r248287 47 47 function CommandLineAPI(commandLineAPIImpl, callFrame) 48 48 { 49 this.$_ = injectedScript._lastResult; 50 this.$event = injectedScript._eventValue; 51 this.$exception = injectedScript._exceptionValue; 49 let savedResultAlias = InjectedScriptHost.savedResultAlias; 50 51 let defineGetter = (key, value) => { 52 if (typeof value !== "function") { 53 let originalValue = value; 54 value = function() { return originalValue; }; 55 } 56 57 this.__defineGetter__("$" + key, value); 58 if (savedResultAlias) 59 this.__defineGetter__(savedResultAlias + key, value); 60 }; 61 62 if ("_lastResult" in injectedScript) 63 defineGetter("_", injectedScript._lastResult); 64 65 if ("_exceptionValue" in injectedScript) 66 defineGetter("exception", injectedScript._exceptionValue); 67 68 if ("_eventValue" in injectedScript) 69 defineGetter("event", injectedScript._eventValue); 52 70 53 71 // $0 54 this.__defineGetter__("$0", bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl));72 defineGetter("0", bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl)); 55 73 56 74 // $1-$99 57 75 for (let i = 1; i <= injectedScript._savedResults.length; ++i) 58 this.__defineGetter__("$" +i, bind(injectedScript._savedResult, injectedScript, i));76 defineGetter(i, bind(injectedScript._savedResult, injectedScript, i)); 59 77 60 78 // Command Line API methods. -
trunk/Source/WebInspectorUI/ChangeLog
r248286 r248287 1 2019-08-05 Devin Rousso <drousso@apple.com> 2 3 Can't use $0, $1 etc when inspecting Google Docs pages because the content uses these for function names 4 https://bugs.webkit.org/show_bug.cgi?id=195834 5 6 Reviewed by Joseph Pecoraro. 7 8 Allow the user to alias saved results by providing a different prefix (e.g. "$") from within 9 Web Inspector. When changing the alias, all existing saved results will update to be 10 reference-able from the new alias. 11 12 * UserInterface/Controllers/RuntimeManager.js: 13 (WI.RuntimeManager): 14 (WI.RuntimeManager.preferredSavedResultPrefix): Added. 15 (WI.RuntimeManager.prototype.initializeTarget): 16 * UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js: 17 (WI.JavaScriptRuntimeCompletionProvider.completionControllerCompletionsNeeded.receivedPropertyNames): 18 19 * UserInterface/Base/Setting.js: 20 * UserInterface/Base/Main.js: 21 (WI.contentLoaded): 22 (WI.contentLoaded.updateConsoleSavedResultPrefixCSSVariable): Added. 23 * UserInterface/Views/ConsoleMessageView.js: 24 (WI.ConsoleMessageView.prototype.toClipboardString): 25 (WI.ConsoleMessageView.prototype.removeEventListeners): Added. 26 (WI.ConsoleMessageView.prototype._appendSavedResultIndex): 27 (WI.ConsoleMessageView.prototype._appendSavedResultIndex.updateSavedVariableText): Added. 28 (WI.ConsoleMessageView.prototype._rootPropertyPathForObject): 29 (WI.ConsoleMessageView.prototype._rootPropertyPathForObject.prefixSavedResultIndex): Added. 30 * UserInterface/Views/LogContentView.js: 31 (WI.LogContentView.prototype._sessionStarted): 32 (WI.LogContentView.prototype._logCleared): 33 * UserInterface/Views/DOMTreeOutline.css: 34 (.tree-outline.dom.show-last-selected li.last-selected > span::after): 35 * UserInterface/Views/QuickConsole.js: 36 (WI.QuickConsole): 37 (WI.QuickConsole.prototype.closed): 38 (WI.QuickConsole.prototype._updateAutomaticExecutionContextPathComponentTooltip): Added. 39 Listen for changes to the setting that holds the current saved result alias and update any 40 related UI accordingly. 41 42 * UserInterface/Views/SettingsTabContentView.js: 43 (WI.SettingsTabContentView.prototype._createConsoleSettingsView): 44 * UserInterface/Views/SettingsTabContentView.css: 45 (.content-view.settings > .settings-view > .container > .editor-group > .editor input[type="text"]): Added. 46 * UserInterface/Views/SettingsGroup.js: 47 (WI.SettingsGroup.prototype.addCustomEditor): Added. 48 Add an input to the Settings tab that controls the saved result prefix alias. Only allow 49 [a-zA-Z0-9_$] as values (but [0-9] cannot be used as the start). 50 51 * UserInterface/Models/PropertyPath.js: 52 (WI.PropertyPath.prototype.set pathComponent): Added. 53 Miscellaneous getters/setters. 54 55 * Localizations/en.lproj/localizedStrings.js: 56 57 * UserInterface/Test/TestHarness.js: 58 (TestHarness.prototype.newline): Added. 59 Convenience function for adding newlines to test results. 60 1 61 2019-08-05 Devin Rousso <drousso@apple.com> 2 62 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r248274 r248287 468 468 localizedStrings["Example: \u201C%s\u201D"] = "Example: \u201C%s\u201D"; 469 469 localizedStrings["Exception with thrown value: %s"] = "Exception with thrown value: %s"; 470 localizedStrings["Execution context for $0"] = "Execution context for $0";470 localizedStrings["Execution context for %s"] = "Execution context for %s"; 471 471 localizedStrings["Exited Full-Screen Mode"] = "Exited Full-Screen Mode"; 472 472 localizedStrings["Expand All"] = "Expand All"; … … 925 925 localizedStrings["Save configuration"] = "Save configuration"; 926 926 localizedStrings["Saved Recordings"] = "Saved Recordings"; 927 localizedStrings["Saved Result Alias:"] = "Saved Result Alias:"; 927 928 localizedStrings["Saved States"] = "Saved States"; 928 929 localizedStrings["Scheduling:"] = "Scheduling:"; -
trunk/Source/WebInspectorUI/UserInterface/Base/Main.js
r248198 r248287 574 574 WI.tabBar.addEventListener(WI.TabBar.Event.TabBarItemsReordered, WI._rememberOpenTabs); 575 575 576 function updateConsoleSavedResultPrefixCSSVariable() { 577 document.body.style.setProperty("--console-saved-result-prefix", "\"" + WI.RuntimeManager.preferredSavedResultPrefix() + "\""); 578 } 579 WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, updateConsoleSavedResultPrefixCSSVariable); 580 updateConsoleSavedResultPrefixCSSVariable(); 581 576 582 // Signal that the frontend is now ready to receive messages. 577 583 WI.whenTargetsAvailable().then(() => { -
trunk/Source/WebInspectorUI/UserInterface/Base/Setting.js
r248202 r248287 144 144 canvasRecordingAutoCaptureFrameCount: new WI.Setting("canvas-recording-auto-capture-frame-count", 1), 145 145 consoleAutoExpandTrace: new WI.Setting("console-auto-expand-trace", true), 146 consoleSavedResultAlias: new WI.Setting("console-saved-result-alias", ""), 146 147 cssChangesPerNode: new WI.Setting("css-changes-per-node", false), 147 148 clearLogOnNavigate: new WI.Setting("clear-log-on-navigate", true), -
trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js
r248201 r248287 230 230 propertyNames[name] = true; 231 231 232 let savedResultAlias = WI.settings.consoleSavedResultAlias.value; 233 if (savedResultAlias) { 234 propertyNames[savedResultAlias + "0"] = true; 235 propertyNames[savedResultAlias + "_"] = true; 236 } 237 232 238 // FIXME: Due to caching, sometimes old $n values show up as completion results even though they are not available. We should clear that proactively. 233 for (var i = 1; i <= WI.ConsoleCommandResultMessage.maximumSavedResultIndex; ++i) 239 for (var i = 1; i <= WI.ConsoleCommandResultMessage.maximumSavedResultIndex; ++i) { 234 240 propertyNames["$" + i] = true; 241 242 if (savedResultAlias) 243 propertyNames[savedResultAlias + i] = true; 244 } 235 245 } 236 246 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/RuntimeManager.js
r248097 r248287 32 32 this._activeExecutionContext = null; 33 33 34 WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, (event) => { 35 for (let target of WI.targets) { 36 // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultAlias did not exist. 37 if (target.RuntimeAgent.setSavedResultAlias) 38 target.RuntimeAgent.setSavedResultAlias(WI.settings.consoleSavedResultAlias.value); 39 } 40 }); 41 34 42 WI.Frame.addEventListener(WI.Frame.Event.ExecutionContextsCleared, this._frameExecutionContextsCleared, this); 35 43 } … … 41 49 // COMPATIBILITY (iOS 12): Runtime.awaitPromise did not exist 42 50 return !!InspectorBackend.domains.Runtime.awaitPromise; 51 } 52 53 static preferredSavedResultPrefix() 54 { 55 // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultAlias did not exist. 56 if (!InspectorBackend.domains.Runtime.setSavedResultAlias) 57 return "$"; 58 return WI.settings.consoleSavedResultAlias.value || "$"; 43 59 } 44 60 … … 53 69 target.RuntimeAgent.enableTypeProfiler(); 54 70 55 // COMPATIBILITY (iOS 10): Runtime.enableControlFlowProfiler did not exist 71 // COMPATIBILITY (iOS 10): Runtime.enableControlFlowProfiler did not exist. 56 72 if (target.RuntimeAgent.enableControlFlowProfiler && WI.settings.enableControlFlowProfiler.value) 57 73 target.RuntimeAgent.enableControlFlowProfiler(); 74 75 // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultAlias did not exist. 76 if (target.RuntimeAgent.setSavedResultAlias && WI.settings.consoleSavedResultAlias.value) 77 target.RuntimeAgent.setSavedResultAlias(WI.settings.consoleSavedResultAlias.value); 58 78 } 59 79 -
trunk/Source/WebInspectorUI/UserInterface/Models/PropertyPath.js
r220119 r248287 56 56 get parent() { return this._parent; } 57 57 get isPrototype() { return this._isPrototype; } 58 58 59 get pathComponent() { return this._pathComponent; } 60 set pathComponent(pathComponent) { this._pathComponent = pathComponent; } 59 61 60 62 get rootObject() -
trunk/Source/WebInspectorUI/UserInterface/Test/TestHarness.js
r239343 r248287 96 96 else 97 97 this.addResult(message); 98 } 99 100 newline() 101 { 102 this.log(""); 98 103 } 99 104 -
trunk/Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js
r247790 r248287 204 204 let clipboardString = this._messageBodyElement.innerText.removeWordBreakCharacters(); 205 205 if (this._message.savedResultIndex) 206 clipboardString = clipboardString.replace( /\s*=\s*(\$\d+)$/, "");206 clipboardString = clipboardString.replace(new RegExp(`\\s*=\\s*(${WI.RuntimeManager.preferredSavedResultPrefix()}\\d+)$`), ""); 207 207 208 208 let hasStackTrace = this._shouldShowStackTrace(); … … 239 239 return this._clipboardPrefixString() + clipboardString; 240 240 return clipboardString; 241 } 242 243 removeEventListeners() 244 { 245 // FIXME: <https://webkit.org/b/196956> Web Inspector: use weak collections for holding event listeners 246 WI.settings.consoleSavedResultAlias.removeEventListener(null, null, this); 241 247 } 242 248 … … 347 353 _appendSavedResultIndex(element) 348 354 { 349 if (!this._message.savedResultIndex) 355 let savedResultIndex = this._message.savedResultIndex; 356 if (!savedResultIndex) 350 357 return; 351 358 … … 355 362 var savedVariableElement = document.createElement("span"); 356 363 savedVariableElement.classList.add("console-saved-variable"); 357 savedVariableElement.textContent = " = $" + this._message.savedResultIndex; 364 365 // FIXME: <https://webkit.org/b/196956> Web Inspector: use weak collections for holding event listeners 366 function updateSavedVariableText() { 367 savedVariableElement.textContent = " = " + WI.RuntimeManager.preferredSavedResultPrefix() + savedResultIndex; 368 } 369 WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, updateSavedVariableText, this); 370 updateSavedVariableText(); 358 371 359 372 if (this._objectTree) … … 693 706 _rootPropertyPathForObject(object) 694 707 { 695 if (!this._message.savedResultIndex) 708 let savedResultIndex = this._message.savedResultIndex; 709 if (!savedResultIndex) 696 710 return null; 697 711 698 return new WI.PropertyPath(object, "$" + this._message.savedResultIndex); 712 function prefixSavedResultIndex() { 713 return WI.RuntimeManager.preferredSavedResultPrefix() + savedResultIndex; 714 } 715 716 let propertyPath = new WI.PropertyPath(object, prefixSavedResultIndex()); 717 718 // FIXME: <https://webkit.org/b/196956> Web Inspector: use weak collections for holding event listeners 719 WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, (event) => { 720 propertyPath.pathComponent = prefixSavedResultIndex(); 721 }, this); 722 723 return propertyPath; 699 724 } 700 725 -
trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.css
r246855 r248287 72 72 73 73 .tree-outline.dom.show-last-selected li.last-selected > span::after { 74 content: " = $0";74 content: " = " var(--console-saved-result-prefix) "0"; 75 75 color: var(--console-secondary-text-color); 76 76 position: absolute; -
trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js
r248180 r248287 395 395 } 396 396 397 for (let messageElement of this._allMessageElements()) { 398 if (messageElement.__messageView) 399 messageElement.__messageView.removeEventListeners(); 400 } 401 397 402 const isFirstSession = false; 398 403 const newSessionReason = event.data.wasReloaded ? WI.ConsoleSession.NewSessionReason.PageReloaded : WI.ConsoleSession.NewSessionReason.PageNavigated; … … 825 830 for (let item of this._scopeBar.items) 826 831 item.element.classList.remove("unread"); 832 833 for (let messageElement of this._allMessageElements()) { 834 if (messageElement.__messageView) 835 messageElement.__messageView.removeEventListeners(); 836 } 827 837 828 838 this._logViewController.clear(); -
trunk/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js
r248196 r248287 34 34 35 35 this._automaticExecutionContextPathComponent = this._createExecutionContextPathComponent(null, WI.UIString("Auto")); 36 this._ automaticExecutionContextPathComponent.tooltip = WI.UIString("Execution context for $0");36 this._updateAutomaticExecutionContextPathComponentTooltip(); 37 37 38 38 this._mainExecutionContextPathComponent = null; … … 72 72 this.initializeMainExecutionContextPathComponent(); 73 73 74 WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed, this._updateAutomaticExecutionContextPathComponentTooltip, this); 75 74 76 WI.consoleDrawer.toggleButtonShortcutTooltip(this._toggleOrFocusKeyboardShortcut); 75 77 WI.consoleDrawer.addEventListener(WI.ConsoleDrawer.Event.CollapsedStateChanged, this._updateStyles, this); … … 99 101 closed() 100 102 { 103 WI.settings.consoleSavedResultAlias.removeEventListener(null, null, this); 101 104 WI.Frame.removeEventListener(null, null, this); 102 105 WI.debuggerManager.removeEventListener(null, null, this); … … 166 169 WI.runtimeManager.activeExecutionContext = executionContext; 167 170 return changed; 171 } 172 173 _updateAutomaticExecutionContextPathComponentTooltip() 174 { 175 this._automaticExecutionContextPathComponent.tooltip = WI.UIString("Execution context for %s").format(WI.RuntimeManager.preferredSavedResultPrefix() + "0"); 168 176 } 169 177 -
trunk/Source/WebInspectorUI/UserInterface/Views/SettingsGroup.js
r220119 r248287 65 65 return editor; 66 66 } 67 68 addCustomEditor() 69 { 70 let element = this._editorGroupElement.appendChild(document.createElement("div")); 71 element.classList.add("editor"); 72 return element; 73 } 67 74 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.css
r246410 r248287 129 129 } 130 130 131 .content-view.settings > .settings-view > .container > .editor-group > .editor input[type="text"] { 132 padding-top: 0; 133 padding-bottom: 0; 134 vertical-align: 1px; 135 136 /* Vertically align <input> with the group title text. */ 137 --settings-editor-child-margin-top: -2px; 138 } 139 131 140 @media (prefers-color-scheme: dark) { 132 141 .content-view.settings .navigation-bar { -
trunk/Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js
r248202 r248287 261 261 let consoleSettingsView = new WI.SettingsView("console", WI.UIString("Console")); 262 262 263 // COMPATIBILITY (iOS 12.2): Runtime.setSavedResultAlias did not exist. 264 if (InspectorBackend.domains.Runtime.setSavedResultAlias) { 265 let consoleSavedResultAliasEditor = consoleSettingsView.addGroupWithCustomEditor(WI.UIString("Saved Result Alias:")); 266 267 let consoleSavedResultAliasInput = consoleSavedResultAliasEditor.appendChild(document.createElement("input")); 268 consoleSavedResultAliasInput.type = "text"; 269 consoleSavedResultAliasInput.value = WI.settings.consoleSavedResultAlias.value; 270 consoleSavedResultAliasInput.placeholder = WI.unlocalizedString("$"); 271 consoleSavedResultAliasInput.addEventListener("keydown", (event) => { 272 if (!/[a-zA-Z0-9_$]/.test(event.key) || (consoleSavedResultAliasInput.selectionStart === 0 && /[0-9]/.test(event.key))) { 273 event.preventDefault(); 274 InspectorFrontendHost.beep(); 275 } 276 }); 277 consoleSavedResultAliasInput.addEventListener("input", (event) => { 278 let savedResultAlias = consoleSavedResultAliasInput.value; 279 if (savedResultAlias === "$") 280 savedResultAlias = ""; 281 WI.settings.consoleSavedResultAlias.value = savedResultAlias; 282 }); 283 284 consoleSettingsView.addSeparator(); 285 } 286 263 287 consoleSettingsView.addSetting(WI.UIString("Traces:"), WI.settings.consoleAutoExpandTrace, WI.UIString("Auto-expand")); 264 288 -
trunk/Source/WebInspectorUI/UserInterface/Views/SettingsView.js
r220119 r248287 53 53 } 54 54 55 addGroupWithCustomEditor(title, element) 56 { 57 let settingsGroup = this.addGroup(title); 58 return settingsGroup.addCustomEditor(); 59 } 60 55 61 addGroup(title) 56 62 {
Note: See TracChangeset
for help on using the changeset viewer.