src/third_party/mozjs/extract/js/src/fuzz-tests/util/sanitize.js
// to libFuzzer targets is reduced to a minimum.
to libFuzzer targets is reduced to a minimum.
to libFuzzer targets is reduced to a minimum .
function sanitizeGlobal(g) {
  let lfFuncs = {
    backtrace: function() {},
    getBacktrace: function() {},
    help: function() {},
    print: function(s) { return s.toString(); },
    printErr: function(s) { return s.toString(); },
    putstr: function(s) { return s.toString(); },
    stackDump: function() {},
    dumpHeap: function() {},
    dumpScopeChain: function() {},
    dumpObjectWrappers: function() {},
    dumpGCArenaInfo: function() {},
    printProfilerEvents: function() {},
    getLcovInfo: function() {},
    readline: function() {},
    readlineBuf: function() {},
    timeout: function() {},
    quit: function() {},
    interruptIf: function() {},
    terminate: function() {},
    invokeInterruptCallback: function() {},
    setInterruptCallback: function() {},
    intern: function() {},
    evalInWorker: function() {},
    sleep: function() {},
    cacheEntry: function() {},
    streamCacheEntry: function() {},
    createMappedArrayBuffer: function() {},
    wasmCompileInSeparateProcess: function() {},
    gcparam: function() {},
    newGlobal: function() { return g; },
    assertEq: function(a,b) { return a.toString() == b.toString(); },
    throwError: function() {},
    reportOutOfMemory: function() {},
    throwOutOfMemory: function() {},
    reportLargeAllocationFailure: function() {},
    gczeal: function(m, f) { return gczeal(m, 100); },
    startgc: function(n, o) { startgc(n > 20 ? 20 : n, o); },
    gcslice: function(n) { gcslice(n > 20 ? 20 : n); },
    deterministicgc: function() {},
    fullcompartmentchecks: function() {},
    setIonCheckGraphCoherency: function() {},
    enableShellAllocationMetadataBuilder: function() {},
    setTimeResolution: function() {},
    options: function() { return "tracejit,methodjit,typeinfer"; },
    setJitCompilerOption: function() {},
    clearLastWarning: function() {},
    enableSingleStepProfiling: function() {},
    disableSingleStepProfiling: function() {},
    enableGeckoProfiling: function() {},
    enableGeckoProfilingWithSlowAssertions: function() {},
    disableGeckoProfiling: function() {},
    enqueueJob: function() {},
    globalOfFirstJobInQueue: function() {},
    drainJobQueue: function() {},
    setPromiseRejectionTrackerCallback: function() {},
    startTimingMutator: function() {},
    stopTimingMutator: function() {},
    setModuleLoadHook: function() {},
    setModuleMetadataHook: function() {},
    setModuleDynamicImportHook: function() {},
    finishDynamicModuleImport: function() {},
    abortDynamicModuleImport: function() {},
    offThreadCompileScript: function() {},
    runOffThreadScript: function() {},
    offThreadCompileModule: function() {},
    finishOffThreadModule: function() {},
    offThreadDecodeScript: function() {},
    runOffThreadDecodedScript: function() {},
    addPromiseReactions: function() {},
    ignoreUnhandledRejections: function() {},
    enableTrackAllocations: function() {},
    disableTrackAllocations: function() {},
    startTraceLogger: function() {},
    stopTraceLogger: function() {},
    setTestFilenameValidationCallback: function() {},
  };
  for (let lfFunc in lfFuncs) {
    g[lfFunc] = lfFuncs[lfFunc];
  }
  return g;
}
function sanitizeGlobal ( g ) { let lfFuncs = { backtrace : function ( ) { } , getBacktrace : function ( ) { } , help : function ( ) { } , print : function ( s ) { return s . toString ( ) ; } , printErr : function ( s ) { return s . toString ( ) ; } , putstr : function ( s ) { return s . toString ( ) ; } , stackDump : function ( ) { } , dumpHeap : function ( ) { } , dumpScopeChain : function ( ) { } , dumpObjectWrappers : function ( ) { } , dumpGCArenaInfo : function ( ) { } , printProfilerEvents : function ( ) { } , getLcovInfo : function ( ) { } , readline : function ( ) { } , readlineBuf : function ( ) { } , timeout : function ( ) { } , quit : function ( ) { } , interruptIf : function ( ) { } , terminate : function ( ) { } , invokeInterruptCallback : function ( ) { } , setInterruptCallback : function ( ) { } , intern : function ( ) { } , evalInWorker : function ( ) { } , sleep : function ( ) { } , cacheEntry : function ( ) { } , streamCacheEntry : function ( ) { } , createMappedArrayBuffer : function ( ) { } , wasmCompileInSeparateProcess : function ( ) { } , gcparam : function ( ) { } , newGlobal : function ( ) { return g ; } , assertEq : function ( a , b ) { return a . toString ( ) == b . toString ( ) ; } , throwError : function ( ) { } , reportOutOfMemory : function ( ) { } , throwOutOfMemory : function ( ) { } , reportLargeAllocationFailure : function ( ) { } , gczeal : function ( m , f ) { return gczeal ( m , 100 ) ; } , startgc : function ( n , o ) { startgc ( n > 20 ? 20 : n , o ) ; } , gcslice : function ( n ) { gcslice ( n > 20 ? 20 : n ) ; } , deterministicgc : function ( ) { } , fullcompartmentchecks : function ( ) { } , setIonCheckGraphCoherency : function ( ) { } , enableShellAllocationMetadataBuilder : function ( ) { } , setTimeResolution : function ( ) { } , options : function ( ) { return "tracejit,methodjit,typeinfer" ; } , setJitCompilerOption : function ( ) { } , clearLastWarning : function ( ) { } , enableSingleStepProfiling : function ( ) { } , disableSingleStepProfiling : function ( ) { } , enableGeckoProfiling : function ( ) { } , enableGeckoProfilingWithSlowAssertions : function ( ) { } , disableGeckoProfiling : function ( ) { } , enqueueJob : function ( ) { } , globalOfFirstJobInQueue : function ( ) { } , drainJobQueue : function ( ) { } , setPromiseRejectionTrackerCallback : function ( ) { } , startTimingMutator : function ( ) { } , stopTimingMutator : function ( ) { } , setModuleLoadHook : function ( ) { } , setModuleMetadataHook : function ( ) { } , setModuleDynamicImportHook : function ( ) { } , finishDynamicModuleImport : function ( ) { } , abortDynamicModuleImport : function ( ) { } , offThreadCompileScript : function ( ) { } , runOffThreadScript : function ( ) { } , offThreadCompileModule : function ( ) { } , finishOffThreadModule : function ( ) { } , offThreadDecodeScript : function ( ) { } , runOffThreadDecodedScript : function ( ) { } , addPromiseReactions : function ( ) { } , ignoreUnhandledRejections : function ( ) { } , enableTrackAllocations : function ( ) { } , disableTrackAllocations : function ( ) { } , startTraceLogger : function ( ) { } , stopTraceLogger : function ( ) { } , setTestFilenameValidationCallback : function ( ) { } , } ; for ( let lfFunc in lfFuncs ) { g [ lfFunc ] = lfFuncs [ lfFunc ] ; } return g ; }
to libFuzzer targets is reduced to a minimum.
to libFuzzer targets is reduced to a minimum .
// Noisy functions (output) // Harmful functions (hangs, timeouts, leaks) // Harmful functions (throw) // Functions that need limiting // Global side-effects // Left enabled, as it is required for now to avoid leaks //setModuleResolveHook: function() {},