0

i am developping an addon chrome and firefox.

My problem is only appearing on firefox but not on chrome.

I want to make an XMLHttpRequest with url domain1.com in a tab of domain2.com (not in the background script)

var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function(event) {
    if (this.readyState === XMLHttpRequest.DONE) {
        if (this.status === 200) {
            console.log("Answer: %s", this.responseText);
        } else {
            console.log("Answer status: %d (%s)", this.status, this.statusText);
        }
    }
};  
xmlHttp.open("GET", theUrl, true);
xmlHttp.send(null);

In chrome i get a 200

But Firefox doesn't do the request ( Answer status: 0 () )

if i replacing domain1.com by domain2.com it's working on firefox

In my content_scripts matches i've added both domain1.com and domain2.com

Thank you for helping!

brouille
  • 295
  • 4
  • 14

1 Answers1

0

The difference between chrome and firefox : In firefox we need to add

"permissions": [
"activeTab",
"storage",
"*://*.domain1.com/*"

In addition of matches in both chrome on firefox

  "content_scripts": [
{
  "matches": [
    "*://*.domain2.com/*",
    "*://*.domain1.com/*"
  ]
brouille
  • 295
  • 4
  • 14