Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lodash error (firefox + greasemonkey) #759

Closed
pihentagy opened this issue Oct 29, 2014 · 16 comments
Closed

Lodash error (firefox + greasemonkey) #759

pihentagy opened this issue Oct 29, 2014 · 16 comments
Labels

Comments

@pihentagy
Copy link

Don't know where to report, but anyway, the problem is:

  • install greasemonkey on firefox
  • install this test script: https://greasyfork.org/en/scripts/5283-testing
  • load a greasyfork.org page
  • expected: you should see an alert
  • actual: nothing, but an error Permission denied to access property 'toString' lodash.min.js:30

note: script loads https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js

@jdalton
Copy link
Member

jdalton commented Oct 29, 2014

Hi @pihentagy! Try this path to lodash instead and report back.

@pihentagy
Copy link
Author

Same here:

16:36:58.348 Permission denied to access property 'toString' lodash.js:8278

Problematic line is:

string = string == null ? '' : String(string);

@jdalton
Copy link
Member

jdalton commented Oct 30, 2014

I've followed the steps provided but cannot get an error message displayed in the Firefox 32 web console or firebug.

@pihentagy
Copy link
Author

@jdalton Be aware, that there are 2 consoles. One of them is activated by Ctrl+Shift+K (Web console), that will not list any errors. But if you press Ctrl+Shift+J (Browser console)....

And, to be clear, did you see the alert box?

@jdalton
Copy link
Member

jdalton commented Oct 30, 2014

Ok, I've spotted the error in the browser console. It looks like a much deeper issue with permissions in greasemonkey than with Lo-Dash.

The specific issue is because greasemonkey doesn't like String(Object.prototype.toString) but is fine with Object.prototype.toString+''. So if I fix that then it complains that parseInt is undefined because even though it's supposed to be the window object it doesn't have parseInt. So if I fix that then it complains about native Object.keys use with something else.

@pihentagy
Copy link
Author

It's not clear for me, whether it is a greasemonkey or firefox issue. If the latter, I think lodash cannot afford to say it won't support firefox. I already mentioned the issue on a greasemonkey forum.

@jdalton
Copy link
Member

jdalton commented Oct 30, 2014

Lo-Dash is tested in Firefox on each commit. I know scripts in extensions like greasemonkey have restrictions those in pages don't but I'm not familiar with it enough nowadays to drill down to the root cause.

Try loading lodash without @require.

@pihentagy
Copy link
Author

Without @require how can I load lodash to a greasemonkey script?

@jdalton
Copy link
Member

jdalton commented Oct 30, 2014

Without @require how can I load lodash to a greasemonkey script?

Create script elements and inject them? Ask the greasemonkey forum for tips/suggestions.

@monk-time
Copy link

The test script works (shows an alert) if you remove all @grant directives in its header or change them to @grant none, forcing the script to run outside of the GM sandbox. Removing @require and putting lodash source directly inside the userscript doesn't change this behavior.

But for some reason greasemonkey doesn't protest if I just call alert(String(Object.prototype.toString)); in a script with no Lo-Dash, no matter what @grant mode I set.

@jdalton
Copy link
Member

jdalton commented Oct 30, 2014

But for some reason greasemonkey doesn't protest if I just call alert(String(Object.prototype.toString)); in a script with no Lo-Dash, no matter what @grant mode I set.

This is because Lo-Dash is using window and not this for window.String and window.Object which is restricted and different than this.String and this.Object. I can tweak the UMD to avoid this issue.

@pihentagy
Copy link
Author

Thanks for resolving.

I came across with lodash roadmap, but that's not clear, whether this fix will go to just 3.0, or there will be a 2.4.x build.

@jdalton
Copy link
Member

jdalton commented Oct 31, 2014

It will go to just 3.0.

@pihentagy
Copy link
Author

That being the case I'm interested when 3.0 will be available.

@jdalton
Copy link
Member

jdalton commented May 14, 2016

Hi @pihentagy!

I'm wanting to simplify the root definition. It looks like the guard for this is no longer needed as:

window === this.window // true

@lock
Copy link

lock bot commented Jan 18, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants