commit
9e506e99dc
@ -1,48 +1,44 @@ |
||||
const semver = require('semver') |
||||
const minixhr = require('minixhr') |
||||
/* global Worker */ |
||||
|
||||
export const baseUrl = 'https://solc-bin.ethereum.org/bin' |
||||
export const baseURLBin = 'https://solc-bin.ethereum.org/bin' |
||||
export const baseURLWasm = 'https://solc-bin.ethereum.org/wasm' |
||||
|
||||
export const pathToURL = {} |
||||
|
||||
/** |
||||
* Retrieves the URL of the given compiler version |
||||
* @param version is the version of compiler with or without 'soljson-v' prefix and .js postfix |
||||
*/ |
||||
export function urlFromVersion (version) { |
||||
return `${baseUrl}/soljson-v${version}.js` |
||||
if (!version.startsWith('soljson-v')) version = 'soljson-v' + version |
||||
if (!version.endsWith('.js')) version = version + '.js' |
||||
return `${pathToURL[version]}/${version}` |
||||
} |
||||
|
||||
/** |
||||
* Checks if the worker can be used to load a compiler. |
||||
* checks a compiler whitelist, browser support and OS. |
||||
*/ |
||||
export function canUseWorker (selectedVersion) { |
||||
// Following restrictions should be deleted when Solidity will release fixed versions of compilers.
|
||||
// See https://github.com/ethereum/remix-ide/issues/2461
|
||||
const isChrome = !!window.chrome |
||||
const os = retrieveOS() |
||||
// define a whitelist for Linux
|
||||
const linuxWL = ['0.4.26', '0.5.3', '0.5.4', '0.5.5'] |
||||
const version = semver.coerce(selectedVersion) |
||||
// defining whitelist for chrome
|
||||
let isFromWhiteList = false |
||||
switch (os) { |
||||
case 'Windows': |
||||
isFromWhiteList = semver.gt(version, '0.5.2') || version === '0.4.26' |
||||
break |
||||
case 'Linux': |
||||
isFromWhiteList = semver.gt(version, '0.5.13') || linuxWL.includes(version) |
||||
break |
||||
default : |
||||
isFromWhiteList = true |
||||
} |
||||
return browserSupportWorker() && (!isChrome || (isChrome && isFromWhiteList)) |
||||
const isNightly = selectedVersion.includes('nightly') |
||||
return browserSupportWorker() && ( |
||||
semver.gt(version, '0.6.3') || |
||||
semver.gt(version, '0.3.6') && !isNightly |
||||
) |
||||
} |
||||
|
||||
function browserSupportWorker () { |
||||
return document.location.protocol !== 'file:' && Worker !== undefined |
||||
} |
||||
|
||||
function retrieveOS () { |
||||
let osName = 'Unknown OS' |
||||
if (navigator.platform.indexOf('Win') !== -1) { |
||||
osName = 'Windows' |
||||
} else if (navigator.platform.indexOf('Linux') !== -1) { |
||||
osName = 'Linux' |
||||
} |
||||
return osName |
||||
// returns a promise for minixhr
|
||||
export function promisedMiniXhr (url) { |
||||
return new Promise((resolve, reject) => { |
||||
minixhr(url, (json, event) => { |
||||
resolve({ json, event }) |
||||
}) |
||||
}) |
||||
} |
||||
|
@ -0,0 +1,28 @@ |
||||
const EventEmitter = require('events') |
||||
|
||||
class NoWorkerErrorFor extends EventEmitter { |
||||
command (version) { |
||||
this.api.perform((done) => { |
||||
noWorkerErrorFor(this.api, version, () => { |
||||
done() |
||||
this.emit('complete') |
||||
}) |
||||
}) |
||||
return this |
||||
} |
||||
} |
||||
|
||||
function noWorkerErrorFor (browser, version, callback) { |
||||
browser |
||||
.setSolidityCompilerVersion(version) |
||||
.click('*[data-id="compilerContainerCompileBtn"]') |
||||
.waitForElementPresent('*[data-id="compilationFinishedWith_' + version + '"]', 10000) |
||||
.notContainsText('*[data-id="compiledErrors"]', 'worker error:undefined') |
||||
.notContainsText('*[data-id="compiledErrors"]', 'Uncaught RangeError: Maximum call stack size exceeded') |
||||
.notContainsText('*[data-id="compiledErrors"]', 'RangeError: Maximum call stack size exceeded') |
||||
.perform(() => { |
||||
callback() |
||||
}) |
||||
} |
||||
|
||||
module.exports = NoWorkerErrorFor |
@ -0,0 +1,37 @@ |
||||
'use strict' |
||||
var examples = require('../../src/app/editor/example-contracts') |
||||
var init = require('../helpers/init') |
||||
var sauce = require('./sauce') |
||||
|
||||
var sources = [ |
||||
{'browser/basic.sol': {content: examples.basic.content}} |
||||
] |
||||
|
||||
module.exports = { |
||||
before: function (browser, done) { |
||||
init(browser, done) |
||||
}, |
||||
'@sources': function () { |
||||
return sources |
||||
}, |
||||
'Using Web Worker': function (browser) { |
||||
browser |
||||
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000) |
||||
.clickLaunchIcon('fileExplorers') |
||||
.openFile('browser/basic.sol') |
||||
.clickLaunchIcon('solidity') |
||||
.execute(() => { |
||||
document.getElementById('nightlies').checked = true |
||||
}) |
||||
.noWorkerErrorFor('soljson-v0.3.4+commit.7dab890.js') |
||||
.noWorkerErrorFor('soljson-v0.6.5+commit.f956cc89.js') |
||||
.noWorkerErrorFor('soljson-v0.6.8-nightly.2020.5.14+commit.a6d0067b.js') |
||||
.noWorkerErrorFor('soljson-v0.6.0-nightly.2019.12.17+commit.d13438ee.js') |
||||
.noWorkerErrorFor('soljson-v0.4.26+commit.4563c3fc.js') |
||||
.execute(() => { |
||||
document.getElementById('nightlies').checked = false |
||||
}) |
||||
}, |
||||
|
||||
tearDown: sauce |
||||
} |
Loading…
Reference in new issue