1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-18 08:52:26 +02:00

add new advanced setting to disable use of WASM for dev purpose

This commit is contained in:
Raymond Hill 2018-11-16 10:19:06 -05:00
parent 7831c094fc
commit 2189f020df
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
4 changed files with 17 additions and 2 deletions

View File

@ -44,8 +44,9 @@ const µBlock = (function() { // jshint ignore:line
autoUpdatePeriod: 7,
benchmarkingPane: false,
cacheStorageCompression: true,
debugScriptlets: false,
cacheControlForFirefox1376932: 'no-cache, no-store, must-revalidate',
debugScriptlets: false,
disableWebAssembly: false,
ignoreRedirectFilters: false,
ignoreScriptInjectFilters: false,
manualUpdateAssetFetchPeriod: 500,

View File

@ -467,6 +467,15 @@ const hnTrieManager = {
return;
}
// Soft-dependency on µBlock's advanced settings so that the code here can
// be used outside of uBO (i.e. tests, benchmarks)
if (
typeof µBlock === 'object' &&
µBlock.hiddenSettings.disableWebAssembly === true
) {
return;
}
// The wasm module will work only if CPU is natively little-endian,
// as we use native uint32 array in our trie-creation js code.
const uint32s = new Uint32Array(1);

View File

@ -52,7 +52,11 @@ let init = function() {
return Promise.resolve(lz4CodecInstance);
}
if ( pendingInitialization === undefined ) {
pendingInitialization = lz4BlockCodec.createInstance()
let flavor;
if ( µBlock.hiddenSettings.disableWebAssembly === true ) {
flavor = 'js';
}
pendingInitialization = lz4BlockCodec.createInstance(flavor)
.then(instance => {
lz4CodecInstance = instance;
pendingInitialization = undefined;

View File

@ -186,6 +186,7 @@
vAPI.localStorage.setItem(
'immediateHiddenSettings',
JSON.stringify({
disableWebAssembly: this.hiddenSettings.disableWebAssembly,
suspendTabsUntilReady: this.hiddenSettings.suspendTabsUntilReady,
userResourcesLocation: this.hiddenSettings.userResourcesLocation
})