mozilla / addon-wr

Looking Glass is a collaboration between Mozilla and the makers of Mr. Robot to provide a shared world experience.
https://support.mozilla.org/kb/lookingglass
51 stars 15 forks source link

Use ports to avoid race condition #18

Closed biancadanforth closed 6 years ago

biancadanforth commented 6 years ago

There was, with using normal browser.runtime.onMessage/sendMessage, a race condition where the content script would sometimes load before the background script on extension startup and try to send it a message before its message listener had been added.

Using a port between the content script and background script eliminates this problem, as the content script is notified when it is connected with the background script and can then send and receive messages.

I also looked at the tooltip on several popular websites and added some neutralizing styles (and cleaned up the CSS block in background.js). One known shortcoming is tootip visibility when the match word is on a window boundary; depending on location it can be completely or partially obscured.

gregglind commented 6 years ago

I accept those visibility limitiations. This Tooltip is "always on the right".

gregglind commented 6 years ago

OK with me! Merging.