2

I have an AngularJS app that I wish to wrap into a Firefox extension. Using JPM I've been able to load the app in via the data folder. However, due to the permissions available to "page scripts" I'm not able to make any calls to the web services that I use for data.

I'm wondering if I was to minify the javascript aspects of the app into a single file and load it in as a "Content-Script" will I be able to make requests to my external web service?

If there's a better way in general to allow an extension to access external data please could you link me to an example?

Scott
  • 2,969
  • 8
  • 23
  • 23
  • Cool stuff! Ive been doing a lot of angular firefox addons as well. Angular is awesome man! Is your addon up on github? Can you share a link to it? – Noitidart Sep 13 '15 at 21:54
  • 1
    @Noitidart It's in a private repo currently but I'll open source it once I have the app working correctly. Can you tell me this, is it possible to debug a content script? It seems everytime I attach a breakpoint they get skipped over – Scott Sep 14 '15 at 09:19
  • Thanks I would love to see it as it will help me with my angular efforts :) I found that I have to use `angular('id of element here').getScope().$digest` or `.$apply` a lot. – Noitidart Sep 14 '15 at 09:49
  • 1
    @Noitidart Sure thing, I haven't need to manually call the digest cycle myself yet. My main issue currently is firefox not loading in some of my content scripts. Have you any knowledge in this area? – Scott Sep 17 '15 at 11:00
  • Yes a bit. The problem with that is angular doing weird sanitiatization which is poorly documented (reasons and how to). See how I got around it: https://github.com/Noitidart/MailtoWebmails/blob/0a5d2290f5f41b7e06266b91682737d5d3bbc82b/resources/scripts/app.js#L66-L68 this is `$sceDeleageProvider` fix to allow loading directives from `chrome://` paths. Then this is `$compileProvider` fix to allow loading `file://` images: https://github.com/Noitidart/Icon-Container-Generator/blob/master/resources/scripts/app.js#L125-L128 thanks to @nandu from here: http://stackoverflow.com/q/31859257/1828637 – Noitidart Sep 17 '15 at 11:57
  • Your situation might be different and I would love to help you fix it and learn the solution myself in case I run into it in the future. So if you can share the solution you come up with that would be awesome. If you can't figure it out jump onto Mozilla IRC channels `irc://moznet/jetpack` (or if you have no irc client heres a html5 client: https://client00.chat.mibbit.com/?url=irc%3A%2F%2Firc.mozilla.org%2F%23jetpack ) and I can help you out. – Noitidart Sep 17 '15 at 11:59
  • Have you got a few minutes to discuss on IRC now? – Scott Sep 17 '15 at 12:04

1 Answers1

2

You can make cross domain requests but you need to define specific settings in package.json, please see the docs:

https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/Cross_Domain_Content_Scripts

therealjeffg
  • 5,790
  • 1
  • 23
  • 24