Closed Bug 1393684 Opened 7 years ago Closed 7 years ago

Can't pass callback to experimental webextension from normal webextension

Categories

(WebExtensions :: Experiments, defect)

56 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1323845

People

(Reporter: bh7578, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36

Steps to reproduce:

I'm working on a WebExtension development, one feature is need to get the response for each request. I have went through the WebExtension API documents, and didn't found related API, so I want to use the WebExtension experiment technique to solve it.
Now I developed an experimental webextension to get the requests' response, and expose following interfaces for other webextension.
function startMonitor(callback){
        httpResponseObserver.callback = callback;
        Services.obs.addObserver(httpResponseObserver, 'http-on-examine-response', false);
}
the schema defination:
{
    "name": "startMonitor",
     "type": "function",
     "async": "callback",
     "description": "start monitor network",
     "parameters": [{
            "name": "callback",
            "type": "function",
            "description": "the callback to notify caller new response comes",
            "parameters": []
    }]
}
I called this function in my other normal webextension:
experimentalExt.startMonitor(function(response){
        console.log('new response comes: ', response);

});


Actual results:

the experimental webextension can't receive my call. it's always null.


Expected results:

the experimental should can receive my callback pass from webextension, then it can pass the response back to webextention caller.
sorry to correct a typo:
Actual results:
the experimental webextension can't receive my callback. it's always null.
Component: Untriaged → WebExtensions: Experiments
Product: Firefox → Toolkit
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
In general, you'd use event listeners rather than callbacks for this sort of thing.
Actually I have got the solution from Firefox source code - that's use the event listener - just like you said.
Thank for your help☺
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.