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

Url: github.com/...user.js - error in the Browser Console #1998

Closed
janekptacijarabaci opened this issue Aug 23, 2014 · 6 comments
Closed

Url: github.com/...user.js - error in the Browser Console #1998

janekptacijarabaci opened this issue Aug 23, 2014 · 6 comments
Milestone

Comments

@janekptacijarabaci
Copy link
Contributor

Example:
https://github.com/w35l3y/userscripts/blob/master/scripts/Neopets_Price_Checker/112692.user.js

Browser console:
#1875 (comment)
(line 278)

@Ventero
Copy link
Contributor

Ventero commented Sep 14, 2014

Some additional information so that I don't forget it:

RemoteScript#cleanup is called three times in cases like that. The three code paths are roughly the following:

  1. Once we detect the page is actually an HTML page, the DownloadListener's completion callback is called. This callback is RemoteScript#_downloadScriptCb, which calls RemoteScript#cleanup
  2. Inside cleanup, all download channels are cancelled, which leads to the download listener's onStopRequest being called with a status code indicating an error. Thus, it calls cleanup itself directly.
  3. Immediately afterwards, onStopRequest additionally calls the completion callback, which as I already mentioned goes through _downloadScriptCb and lands in cleanup.

I'd say number 1 and 2 are definitely unnecessary: Instead of calling the completion handler explicitly in onStartRequest we should just cancel the request and let onStopRequest handle the rest. Additionally, the download listener shouldn't really have to know if the script needs to be cleaned up and just let _downloadScriptCb decide.

Unless someone objects to this or has a better idea, I'll send a patch with these two changes.

PS: In my opinion, the whole script installation process might need some refactoring, as all these callbacks make the code very hard to follow. I understand that script installation is an inherently asynchronous process, but I think by dividing up the responsibilites a bit cleaner, the code can maybe be simplified a bit.

Ventero added a commit to Ventero/greasemonkey that referenced this issue Sep 16, 2014
@Ventero
Copy link
Contributor

Ventero commented Sep 16, 2014

Ventero@92cbf36 should fix this issue. I tested the following cases with this patch, which were all handled fine:

  • successful installation
  • script itself 404's
  • require/resource dependency 404's
  • icon 404's

Additionally, Ventero@b8a0936 fixes a small issue with an XPCOM status check.

@arantius arantius modified the milestones: 2.3, 2.4 Sep 16, 2014
@arantius arantius modified the milestones: 2.4, 2.5 Oct 29, 2014
@arantius
Copy link
Collaborator

This fix is now included in version 3.1beta1. Please browse to Greasemonkey's AMO page and open "Development Channel" near the bottom to install the beta version. Can you confirm the fix? Thank you.

@janekptacijarabaci
Copy link
Contributor Author

Unfortunately, there is still something wrong.

Example:
https://github.com/w35l3y/userscripts/blob/master/scripts/Neopets_Price_Checker/112692.user.js
(F5 page reload)

Browser console:
1
2

@arantius
Copy link
Collaborator

Moving to 3.2 to fix whatever bits remain.

@arantius
Copy link
Collaborator

Ah I totally missed one detail!

So https://developer.mozilla.org/en-US/Firefox/Multiprocess_Firefox/Frame_script_environment says " docShell The nsIDocShell associated with the browser". And https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIDocShell#loadURI says there's a loadURI() method which takes four arguments. But docShell also (??) is a nsIWebNavigation https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWebNavigation#loadURI%28%29 which has a loadURI() method which takes five arguments!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants