Reference error for chrome object

RESOLVED INVALID

Status

WebExtensions
Untriaged
RESOLVED INVALID
2 years ago
a month ago

People

(Reporter: drhen123, Unassigned)

Tracking

49 Branch
x86_64
Windows 10

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

2 years ago
Created attachment 8753253 [details]
Untitled.png

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0
Build ID: 20160516030211

Steps to reproduce:

In a content script have a chrome object being called such as chrome.runtime.


Actual results:

When the code is then run an error is produced in the console. "ReferenceError: chrome is not defined"


Expected results:

The code should be executed.
(Reporter)

Updated

2 years ago
OS: Unspecified → Windows 10
Hardware: Unspecified → x86_64
Can you please attach the add-on that is triggering this?
(Reporter)

Comment 2

2 years ago
Created attachment 8753528 [details]
A addon that contains the error
(Reporter)

Comment 3

2 years ago
If you go to the website https://www.mousehuntgame.com/login.php with the plugin installed even without logging in you should see the error in console. 

What is weird though it runs once and works and the next time it runs comes up with the reference error.

Any questions just ask
The problem is that you're also loading the script into the page itself, where privileged extension APIs are not available.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → INVALID
(Reporter)

Comment 5

2 years ago
(In reply to Kris Maglione [:kmag] from comment #4)
> The problem is that you're also loading the script into the page itself,
> where privileged extension APIs are not available.

Ah I see.

Is there a way to get around this i am trying to port an extension as you can see?
You can't access extension APIs from a script that you inject into a page. I wouldn't expect this to work any better on Chrome.

What exactly are you trying to achieve by injecting that script into the content document?
(Reporter)

Comment 7

2 years ago
(In reply to Kris Maglione [:kmag] from comment #6)
> You can't access extension APIs from a script that you inject into a page. I
> wouldn't expect this to work any better on Chrome.
> 
> What exactly are you trying to achieve by injecting that script into the
> content document?

I was not the original writer of this code so i am not sure why it injects into the page. I will talk to the original developer about why this happens. 

When running the code in chrome it does not appear to give any errors with this code however.

Updated

a month ago
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.