[webkit-reviews] review granted: [Bug 195834] Can't use $0, $1 etc when inspecting Google Docs pages because the content uses these for function names : [Attachment 372839] Patch

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Aug 5 13:11:27 PDT 2019


Joseph Pecoraro <joepeck at webkit.org> has granted Devin Rousso
<drousso at apple.com>'s request for review:
Bug 195834: 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

Attachment 372839: Patch

https://bugs.webkit.org/attachment.cgi?id=372839&action=review




--- Comment #25 from Joseph Pecoraro <joepeck at webkit.org> ---
Comment on attachment 372839
  --> https://bugs.webkit.org/attachment.cgi?id=372839
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=372839&action=review

r=me

> Source/JavaScriptCore/inspector/InjectedScriptSource.js:1459
> +	   this.$_ = injectedScript._lastResult;

I wonder if these should be `__defineGetter__` as well. It doesn't really
matter, because they get recreated every evaluation, but I suspect it would
throw errors when/if folks try to assign to them. That should have its own test
if we make such a change.

> Source/JavaScriptCore/inspector/protocol/Runtime.json:322
> +	       "description": "Creates an additional reference to all saved
values in the Console by replacing the default $ prefix with the given
string.",

This is not `replacing` but providing a parallel prefix. It seems more like a
`setSavedResultPrefixAlias` but I'm fine with the existing naming.

> Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js:334
> +	  
WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed,
updateSavedVariableText);

These event handlers need to get removed somewhere, or else they will exist
forever on the global Setting.

> Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js:683
> +	  
WI.settings.consoleSavedResultAlias.addEventListener(WI.Setting.Event.Changed,
(event) => {

These event handlers need to get removed somewhere, or else they will exist
forever on the global Setting.

> Source/WebInspectorUI/UserInterface/Views/SettingsTabContentView.js:275
> +	       consoleSavedResultAliasInput.addEventListener("keydown", (event)
=> {
> +		   if (!/[a-zA-Z0-9_$]/.test(event.key) ||
(consoleSavedResultAliasInput.selectionStart === 0 && /[0-9]/.test(event.key)))
{
> +		       event.preventDefault();
> +		       InspectorFrontendHost.beep();
> +		   }
> +	       });

I guess this validation doesn't need to happen on the backend because this is
actually becoming a property, not a variable name.

Maybe special case if the final value is "$" it could clear it.

> LayoutTests/inspector/runtime/setSavedResultAlias.html:46
> +	       InspectorTest.newline();

This would totally have made sense as 3 tests instead of just newlines.


More information about the webkit-reviews mailing list