KangoExtensions / kango

Kango framework issue tracker
74 stars 7 forks source link

xhr send callback not firing on firefox #114

Closed ierror closed 9 years ago

ierror commented 9 years ago

Given this simple example, the callback function does not fire on the current Firefox 35.0.1 Firefox sends the data to the server, only the callback is not called...

The callback is fired in Chrome and Safari, any suggestions?

kango.xhr.send({
    url: config_data.server_url,
    method: 'POST',
    async: true,
    contentType: 'text',
    params: payload
}, function (data) {
    alert('Status: ' + data.status + ' Response: ' + data.response);
    if (config_data.debug_mode) {
        alert('Status: ' + data.status + ' Response: ' + data.response);
    }
});

Thank you

akrylysov commented 9 years ago

Please provide us full example with URL and payload.

hartleybrody commented 9 years ago

Can't upload the full code base cause it's not my code to share, but you can make a quick proof of concept in 3 minutes by creating a new kango extension (using latest 1.7.1 from website) and adding one content script with the following:

var request = {
    url: "https://www.google.com",
    method: "GET"
}

kango.xhr.send(request, function(response){
    console.log('got kango.xhr response')
})

You'll see the expected output in the page's console in Chrome 41 (latest). However, in Firefox 37 (latest), if you pull up the Browser Console, you'll see an error line coming from the content script:

Exposing privileged or cross-origin callable is prohibited

hartleybrody commented 9 years ago

Another thing that works fine on Chrome but throws the Exposing privileged or cross-origin callable is prohibited error on Firefox is using kango.invokeAsyncCallback. Like so:


// background.js
function echo(msg, callback){
    callback("background received: " + msg)
}

// content-script.js
kango.invokeAsyncCallback('echo', 'hello world', function(response){
    console.log('got response from background page')
    console.log(response)
})

On Chrome, we get the expected:

got response from background page
background received: hello world

but on Firefox, it's the Exposing privileged or cross-origin callable is prohibited error being thrown from the line where invokeAsyncCallback is called.

hartleybrody commented 9 years ago

Even the canonical example of communication between content scripts and background pages seems to be broken in Firefox:


// content-script.js
kango.invokeAsync('kango.storage.setItem', 'Foo', 'Bar');
kango.invokeAsync('kango.storage.getItem', 'Foo', function(data) {
    console.log('value of data in storage is: ' + data);
});

logs what you'd expect in Chrome but throws the same Exposing privileged or cross-origin callable is prohibited error in Firefox.

hartleybrody commented 9 years ago

Just uninstalled and reinstalled a fresh version of Firefox to confirm it wasn't an issue on my end.

Even this throws that error on Firefox (but works fine on Chrome):


// content-script.js
var browser = kango.browser.getName()
console.log(browser);
akrylysov commented 9 years ago

What is your Kango version?

hartleybrody commented 9 years ago

Ah, oops. I was on 1.3.1 :angel:

I had downloaded kango-framework-latest.zip from here but apparently I already had 1.3 in my downloads folder and then unzipped the wrong one.