1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 18:41:38 +01:00
metamask-extension/app/scripts
Dan Finlay 913a9e85bd Inject inpage script synchronously
Huge thanks to the Firefox team, for their help on the issue of our long-standing inpage script race condition.

http://stackoverflow.com/questions/38577656/how-can-i-make-a-firefox-add-on-contentscript-inject-and-run-a-script-before-oth

The problem is that we were injecting a `script` tag and assigning its `src` attribute, which triggers an asynchronous fetch request, and does not guarantee execution order! (That was news to me!)

Instead, I'm now assigning the `script` tag a `textContent` value of the script to inject, and it seems to fix the problem!

There is also a Firefox-only API that could solve this whole problem in an even more elegant way, so we might want to expose a code path for that solution later on:

https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.exportFunction

Allows you to expose an object from one scope to another. There was even talk of creating a polyfill for it that does virtually what we do, message passing between contexts.
2016-07-25 16:38:07 -07:00
..
lib Clean up extension polyfill abstraction 2016-07-25 13:46:33 -07:00
migrations Auto linted 2016-06-21 13:18:32 -07:00
background.js Implement some cross-browser practices (#473) 2016-07-21 10:45:32 -07:00
chromereload.js Implement some cross-browser practices (#473) 2016-07-21 10:45:32 -07:00
config.js sync rpc fix 2016-05-19 16:53:16 -07:00
contentscript.js Inject inpage script synchronously 2016-07-25 16:38:07 -07:00
inpage.js typo fix 2016-07-18 18:08:29 -07:00
metamask-controller.js Buy button (#474) 2016-07-21 13:41:10 -07:00
popup.js Implement some cross-browser practices (#473) 2016-07-21 10:45:32 -07:00