Can't pass callback to experimental webextension from normal webextension

RESOLVED DUPLICATE of bug 1323845

Status

()

Toolkit
WebExtensions: Experiments
RESOLVED DUPLICATE of bug 1323845
6 months ago
6 months ago

People

(Reporter: bin li, Unassigned)

Tracking

56 Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 months ago
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.
(Reporter)

Comment 1

6 months ago
sorry to correct a typo:
Actual results:
the experimental webextension can't receive my callback. it's always null.

Updated

6 months ago
Component: Untriaged → WebExtensions: Experiments
Product: Firefox → Toolkit
Status: UNCONFIRMED → RESOLVED
Last Resolved: 6 months ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1323845
In general, you'd use event listeners rather than callbacks for this sort of thing.
(Reporter)

Comment 4

6 months ago
Actually I have got the solution from Firefox source code - that's use the event listener - just like you said.
Thank for your help☺
You need to log in before you can comment on or make changes to this bug.