D21112: Support message response and reply callbacks

2019-07-21 Thread Kai Uwe Broulik
This revision was automatically updated to reflect the committed changes.
Closed by commit R856:59fa1853817b: Support message response and reply 
callbacks (authored by broulik).

REPOSITORY
  R856 Plasma Browser Integration

CHANGES SINCE LAST UPDATE
  https://phabricator.kde.org/D21112?vs=62129&id=62182

REVISION DETAIL
  https://phabricator.kde.org/D21112

AFFECTED FILES
  extension/content-script.js
  extension/content-utils.js
  extension/extension.js
  extension/manifest.json
  extension/options.html
  extension/options.js

To: broulik, #plasma, fvogt
Cc: plasma-devel, LeGast00n, jraleigh, fbampaloukas, GB_2, ragreen, Pitel, 
ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, 
apol, mart


D21112: Support message response and reply callbacks

2019-07-21 Thread Fabian Vogt
fvogt accepted this revision.
fvogt added a comment.
This revision is now accepted and ready to land.


  In D21112#498669 , @fvogt wrote:
  
  > Code looks good and seems to work fine in vivaldi, but I get an error in 
firefox:
  >
  >   Promise resolved after context unloaded
  >   extension.js:78
  >   sendSettings 
moz-extension://d1f34b4e-4e97-40a5-b4ac-03dc2fea30a9/extension.js:78
  >
  >
  > appears to be harmless though?
  
  
  Couldn't reproduce again, so likely fine.

REPOSITORY
  R856 Plasma Browser Integration

REVISION DETAIL
  https://phabricator.kde.org/D21112

To: broulik, #plasma, fvogt
Cc: plasma-devel, LeGast00n, jraleigh, fbampaloukas, GB_2, ragreen, Pitel, 
ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, 
apol, mart


D21112: Support message response and reply callbacks

2019-07-20 Thread Fabian Vogt
fvogt added a comment.


  Code looks good and seems to work fine in vivaldi, but I get an error in 
firefox:
  
Promise resolved after context unloaded
extension.js:78
sendSettings 
moz-extension://d1f34b4e-4e97-40a5-b4ac-03dc2fea30a9/extension.js:78
  
  appears to be harmless though?

REPOSITORY
  R856 Plasma Browser Integration

REVISION DETAIL
  https://phabricator.kde.org/D21112

To: broulik, #plasma, fvogt
Cc: plasma-devel, LeGast00n, jraleigh, fbampaloukas, GB_2, ragreen, Pitel, 
ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, 
apol, mart


D21112: Support message response and reply callbacks

2019-07-20 Thread Kai Uwe Broulik
broulik updated this revision to Diff 62129.
broulik added a comment.


  - Use promises

REPOSITORY
  R856 Plasma Browser Integration

CHANGES SINCE LAST UPDATE
  https://phabricator.kde.org/D21112?vs=57839&id=62129

REVISION DETAIL
  https://phabricator.kde.org/D21112

AFFECTED FILES
  extension/content-script.js
  extension/content-utils.js
  extension/extension.js
  extension/manifest.json
  extension/options.html
  extension/options.js

To: broulik, #plasma, fvogt
Cc: plasma-devel, LeGast00n, jraleigh, fbampaloukas, GB_2, ragreen, Pitel, 
ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, 
apol, mart


D21112: Support message response and reply callbacks

2019-06-13 Thread Kai Uwe Broulik
broulik planned changes to this revision.
broulik added a comment.


  Ok, I have an idea.
  `browser.runtime.sendMessage` (Firefox) returns a promise that is fulfilled 
when a reply is sent. Chrome instead uses a callback function in 
`chrome.runtime.sendMessage`
  I'm gonna rework the `sendMessage()` to always return a Promise (makes for 
nicer code) by either forwarding the promise from Firefox or creating one 
forwarding the callback in Chrome

REPOSITORY
  R856 Plasma Browser Integration

REVISION DETAIL
  https://phabricator.kde.org/D21112

To: broulik, #plasma, fvogt
Cc: plasma-devel, LeGast00n, ericadams, jraleigh, GB_2, ragreen, Pitel, 
ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, 
apol, mart


D21112: Support message response and reply callbacks

2019-06-11 Thread Kai Uwe Broulik
broulik added a comment.


  It works just fine in Firefox 67 here. Maybe the documentation is outdated?
  
browser.runtime.sendMessage({foo: "bar"}, callback)
  
  works just fine

REPOSITORY
  R856 Plasma Browser Integration

REVISION DETAIL
  https://phabricator.kde.org/D21112

To: broulik, #plasma, fvogt
Cc: plasma-devel, LeGast00n, ericadams, jraleigh, GB_2, ragreen, Pitel, 
ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, 
apol, mart


D21112: Support message response and reply callbacks

2019-05-27 Thread Fabian Vogt
fvogt requested changes to this revision.
fvogt added a comment.
This revision now requires changes to proceed.


  `browser.runtime.sendMessage` does not seem to have a callback parameter.
  
  See 
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage:
  
  > if two arguments are given:
  >  the arguments are interpreted as (message, options), and the message is 
sent internally, if the second argument is any of the following:
  >  a valid options object (meaning, it is an object which contains only the 
properties of options that the browser supports)
  > null
  > undefined
  >  otherwise, the arguments are interpreted as (extensionId, message). The 
message will be sent to the extension identified by extensionId.

REPOSITORY
  R856 Plasma Browser Integration

REVISION DETAIL
  https://phabricator.kde.org/D21112

To: broulik, #plasma, fvogt
Cc: plasma-devel, jraleigh, GB_2, ragreen, Pitel, ZrenBot, himcesjf, 
lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart


D21112: Support message response and reply callbacks

2019-05-10 Thread Kai Uwe Broulik
broulik created this revision.
broulik added reviewers: Plasma, fvogt.
Herald added a project: Plasma.
Herald added a subscriber: plasma-devel.
broulik requested review of this revision.

REVISION SUMMARY
  This allows to make use of the sendReply/sendResponse callbacks allowing for 
the callee to reply directly without having to manually track state and relate 
a message to a reply.
  Also add a bit of documentation on the required callback signature.

TEST PLAN
  Sent a message with a callback, replied, got reply in callback.
  Returned true from a callback and stored the callback in a variable, did some 
processing, replied successfully at a later point.

REPOSITORY
  R856 Plasma Browser Integration

REVISION DETAIL
  https://phabricator.kde.org/D21112

AFFECTED FILES
  extension/content-script.js
  extension/extension.js
  extension/options.js

To: broulik, #plasma, fvogt
Cc: plasma-devel, jraleigh, GB_2, ragreen, Pitel, ZrenBot, lesliezhai, 
ali-mohamed, jensreuterberg, abetts, sebas, apol, mart