Closed Bug 1434563 Opened 4 years ago Closed 3 years ago
keys and values jsterm helpers override global content functions
46 bytes, text/x-phabricator-request
|Details | Review|
Steps to reproduce: 1. Go to data:text/html,keys/values<script>values = () => "a";keys = () => 1;</script> 2. Open the console 3. Evaluate `keys()` 4. Evaluate `values()` Expected results: I see 2 lines, with "a" and `1` representing the result of the keys and values function call Actual results: I get 2 error messages: "TypeError: can't convert undefined to object" This is because the helpers override the global content functions. We already had the same issue with $/$$ helpers and fixed it: https://searchfox.org/mozilla-central/rev/c56f656febb1aa58c72b218699e24a76425bd284/devtools/server/actors/webconsole.js#1374-1397 We should make sure we do the same for all the helpers we provide in the jsterm.
Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Priority: P2 → P1
If the content page sets a global keys, values, , … function, calling them in the jsterm won't work because the helpers we provide will override them. This is very disturbing when debugging code, and this patch fixes this issue by looking at all the registered helpers and clearing helpers bindings if a function with the same name as an helper exists in the content page. This is not done for the print helper though, since the print function on window always exists. We also take this as an opportunity to only return unique item in the autocomplete server function so we don't show a function twice in the popup if it is defined in content and as an helper. The test that was asserting this behaviour for $ and $$ is renamed and modified to test all the helpers. MozReview-Commit-ID: 1bTliGUb39U
Comment on attachment 8992354 [details] Bug 1434563 - Do not execute helper if the function is defined in content; r=Honza. Manually setting reviewer here since Phabricator does not seem to do it automatically
Comment on attachment 8992354 [details] Bug 1434563 - Do not execute helper if the function is defined in content; r=Honza. Jan Honza Odvarko [:Honza] has approved the revision. https://phabricator.services.mozilla.com/D2156
Attachment #8992354 - Flags: review+
Pushed by firstname.lastname@example.org: https://hg.mozilla.org/integration/autoland/rev/9b6c65bb4719 Do not execute helper if the function is defined in content; r=Honza.
You need to log in before you can comment on or make changes to this bug.