aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-10-13 04:01:29 +0800
committerGitHub <noreply@github.com>2017-10-13 04:01:29 +0800
commit701887bb19171b1cef0f6d5f6359d8cf39d80a01 (patch)
tree36a051f22d6dc099fce6bdd9f22a24219769cadb
parent29ee33359e818525549b5241adb6f5903a054bba (diff)
parent53a360b65d6b97fa4551c2953072a21cbe9f708d (diff)
downloadtangerine-wallet-browser-701887bb19171b1cef0f6d5f6359d8cf39d80a01.tar.gz
tangerine-wallet-browser-701887bb19171b1cef0f6d5f6359d8cf39d80a01.tar.zst
tangerine-wallet-browser-701887bb19171b1cef0f6d5f6359d8cf39d80a01.zip
Merge pull request #2352 from MetaMask/i1340-SynchronousInjection
Fix slow web3 injection bug
-rw-r--r--CHANGELOG.md2
-rw-r--r--app/scripts/contentscript.js7
-rw-r--r--gulpfile.js9
3 files changed, 13 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ab5b3cb9f..65f75ee18 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## Current Master
+- Fix bug where web3 API was sometimes injected after the page loaded.
+
## 3.11.0 2017-10-11
- Add support for new eth_signTypedData method per EIP 712.
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index b4708189e..ffbbc73cc 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -7,7 +7,9 @@ const ObjectMultiplex = require('obj-multiplex')
const extension = require('extensionizer')
const PortStream = require('./lib/port-stream.js')
-const inpageText = fs.readFileSync(path.join(__dirname, 'inpage.js')).toString()
+const inpageContent = fs.readFileSync(path.join(__dirname, '..', '..', 'dist', 'chrome', 'scripts', 'inpage.js')).toString()
+const inpageSuffix = '//# sourceURL=' + extension.extension.getURL('scripts/inpage.js') + '\n'
+const inpageBundle = inpageContent + inpageSuffix
// Eventually this streaming injection could be replaced with:
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.exportFunction
@@ -25,8 +27,7 @@ function setupInjection () {
try {
// inject in-page script
var scriptTag = document.createElement('script')
- scriptTag.src = extension.extension.getURL('scripts/inpage.js')
- scriptTag.textContent = inpageText
+ scriptTag.textContent = inpageBundle
scriptTag.onload = function () { this.parentNode.removeChild(this) }
var container = document.head || document.documentElement
// append as first child
diff --git a/gulpfile.js b/gulpfile.js
index 557b58a68..9253949c7 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -186,8 +186,13 @@ jsFiles.forEach((jsFile) => {
gulp.task(`build:js:${jsFile}`, bundleTask({ watch: false, label: jsFile, filename: `${jsFile}.js` }))
})
-gulp.task('dev:js', gulp.parallel(...jsDevStrings))
-gulp.task('build:js', gulp.parallel(...jsBuildStrings))
+// inpage must be built before all other scripts:
+const firstDevString = jsDevStrings.shift()
+gulp.task('dev:js', gulp.series(firstDevString, gulp.parallel(...jsDevStrings)))
+
+// inpage must be built before all other scripts:
+const firstBuildString = jsBuildStrings.shift()
+gulp.task('build:js', gulp.series(firstBuildString, gulp.parallel(...jsBuildStrings)))
// disc bundle analyzer tasks