GearyWebExtension: Add support for sending messages from JS to client
Define a vala-backed JS class in the extension and make that available to pages when they are registered. Add some helper JS to PageState for defining message sending functions. Listen for these in Components.WebView and dispatch to the registered callback for it.
This commit is contained in:
parent
db69807836
commit
6162785d99
3 changed files with 127 additions and 0 deletions
|
|
@ -200,3 +200,12 @@ PageState.prototype = {
|
|||
throw this.testResult;
|
||||
}
|
||||
};
|
||||
|
||||
let MessageSender = function(name) {
|
||||
return function() {
|
||||
// Since typeof(arguments) == 'object', convert to an array so
|
||||
// that Components.WebView.MessageCallback callbacks get
|
||||
// arrays or tuples rather than dicts as arguments
|
||||
_GearyWebExtension.send(name, Array.from(arguments));
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue