-
Notifications
You must be signed in to change notification settings - Fork 443
Fix #5292: Add "Force Paste" item in menu to bypass onpaste handlers #5293
Conversation
|
||
"use strict"; | ||
|
||
Object.defineProperty(window.__firefox__, "forcePaste", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to add this stuff to window? Seems like it would be better to just keep the script in a const somewhere and execute it directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we are doing this in other places, but it doesn't really seem ideal to me. What do you think about a follow up to call the JS directly for this kind of stuff? I'm not sure if ios has resource paks in chromium, but if it does we can still manage these as js files, but read the value as a string (sync read from memory, not disk). I don't think it's terrible though to just embed the JS in some consts somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was for namespacing and keeping everything under one variable since prior to iOS 14 content world sandboxes (and still for a bunch of these scripts) they are visible to the webpage. No resource pak's but the reason they're like this is because they're webpack'd and injected via the WebKit APIs
We can technically get rid of window.__firefox__
if we want but we possibly would want to namespace things for non-sandboxed scripts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I guess I'm wondering why they need to by part of window at all. Can we not just execute the JS directly instead of calling a method that we add to window?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know they don't need to be a a part of window at all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to do anything in this PR, but I do think we should a follow-up to change all of these. I assume this was following some pattern from FF and that's why it has __firefox__
which is also a bit weird to have in Brave. I mean we have window.chrome in Brave, but we have to for extensions to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually have this so we don't inject
JS over and over again. Inject once, and call anywhere, any amount of times. This JS is actually injected into a sandbox
called .defaultClient
, so pages won't be able to access it :)
I guess if we want it could technically be loaded from file into memory, and injected again, every time the user hits paste. Either way seems fine to me.
13055ab
to
ba14df2
Compare
Summary of Changes
This pull request fixes #5292
Submitter Checklist:
NSLocalizableString()
Test Plan
Screenshots:
Reviewer Checklist:
QA/(Yes|No)
bug
/enhancement