Closed Bug 1445667 Opened 6 years ago Closed 6 years ago

Content Scripts have no access to Javascript APIs

Categories

(WebExtensions :: Untriaged, defect)

61 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: morton.jamesrichard, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Build ID: 20180314102135

Steps to reproduce:

Creating web app. Specified content scripts in manifest:

"content_scripts": [{
       "all_frames": true,
       "matches": ["*://127.0.0.1:3000/*"],
       "js": ["Javascript/jquery.min.js", "Javascript/dataGrab.js"]
}],

then within dataGrab.js:

window.onload = function () {	
	try{
		browser.runtime.sendMessage({greeting: "Hello"}, function(response){
                       console.log(response);
	 	});
	}
	catch(err){
		console.log(err);
	}	


Actual results:

ReferenceError
columnNumber: 3
fileName: "http://127.0.0.1:3000/JavaScript/dataGrab.js"
lineNumber: 6
message: "browser is not defined"
stack: "window.onload@http://127.0.0.1:3000/JavaScript/dataGrab.js:6:3\nEventHandlerNonNull*@http://127.0.0.1:3000/JavaScript/dataGrab.js:2:1\n"


Expected results:

dataGrab.js should gain access to javascript APIs and be able to use the runtime.sendMessage() function.
Component: DOM → WebExtensions: Untriaged
Product: Core → Toolkit
Scripts that are not part of the extension will never have access to extension APIs.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.