1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-24 19:33:01 +01: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, autoUpdatePeriod: 7,
benchmarkingPane: false, benchmarkingPane: false,
cacheStorageCompression: true, cacheStorageCompression: true,
debugScriptlets: false,
cacheControlForFirefox1376932: 'no-cache, no-store, must-revalidate', cacheControlForFirefox1376932: 'no-cache, no-store, must-revalidate',
debugScriptlets: false,
disableWebAssembly: false,
ignoreRedirectFilters: false, ignoreRedirectFilters: false,
ignoreScriptInjectFilters: false, ignoreScriptInjectFilters: false,
manualUpdateAssetFetchPeriod: 500, manualUpdateAssetFetchPeriod: 500,

View File

@ -467,6 +467,15 @@ const hnTrieManager = {
return; 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, // The wasm module will work only if CPU is natively little-endian,
// as we use native uint32 array in our trie-creation js code. // as we use native uint32 array in our trie-creation js code.
const uint32s = new Uint32Array(1); const uint32s = new Uint32Array(1);

View File

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

View File

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