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

set getSelf to equal a function #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brianzhou13
Copy link

I was getting errors with getSelf when using this script.

@xpl
Copy link
Owner

xpl commented Jan 20, 2020

@brianzhou13 Thanks for the PR! However, I just checked with my Chrome (Version 79.0.3945.130 (Official Build) (64-bit)), and it behaves just fine with the previous getSelf usage.

It didn't load correctly using the code from your fix :(

We need to sort out why this is happening. The official documentation says clearly that getSelf is a function accepting a callback (and this is how I used it):

https://developer.chrome.com/extensions/management#method-getSelf

chrome.management.getSelf(function callback)

The only reason I can see this could happen is that you're trying to call getSelf from a wrong context. It can only be called from background context (and other internal contexts), but you might be trying to call it from webpage context, which does not provide Management API.

If you put hot-reload.js into background context, then getSelf should work just fine:

    "background": { "scripts": ["hot-reload.js"] }

See also this: Extensions Architecture for more info on script contexts.

@brianzhou13
Copy link
Author

mmm, interesting. I'll give it another shot!

I might've gotten bit by the issue you were talking about (calling getSelf from the context of a content-script rather than the background). I'll give this another try when I get back home later tonight.

Thanks for the quick and lengthy response!

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

Successfully merging this pull request may close these issues.

None yet

2 participants