<commit_before>// In this file:
// * Chunking of steps for speed
// * Recording and playing, to make reduction possible
// * Things to aid automated reduction with Lithium (DD* markers, fuzzPriv.quitApplication)
// * Pausing (Esc pauses, Shift+Esc unpauses)

var fuzzIsStrictMode = (function() { return !this; })();

var dumpEachCommand = false; // Can be set to true by using the "Record as it goes" reduction strategy and setting it to record.  Also, some fuzzers always set this to true.
var dumpEachSeed = false; // Can be set to true if makeCommand has side effects, such as crashing, so you have to reduce "the hard way".
var pleaseSerializeDOMAsScript = false; // Can be set to true (and often is) ...
var gPageCompleted = false;
var reportAllErrors = false;
var fuzzExpectSanity = (location.href.indexOf("xslt") == -1 && location.href.indexOf("xml-stylesheet") == -1);

var fuzzCount;

var oPrefix  = "  /*FRCA1*/ "; // most recording output, including all random commands
var oPrefix2 = "  /*FRCA2*/ "; // dom reconstruction


function fuzzOnload(ev)
{
  // Work around bug 380537.
  if (Random.twister) {
    dumpln("fuzzOnload called twice!?");
    return;
  }

  if (window != top) {
    dumpln("I'm in some kind of frame!?");
    return;
  }

  if (window.opener) {
    dumpln("I have an opener!?");
    return;
  }

  if (history.length > 1 && "fuzzPriv" in window) {
    // This check is for some of the crazier stuff fuzzerDuringEvents does.
    // Unfortunately, it breaks the "&scan" tests that are nice for testing outside of the Firefox harness.
    // And it also breaks fuzzRetry.
    dumpln("I have history!?");
    fuzzPriv.quitApplicationSoon();
    return;
  }

  initFuzzerGeneral();

  // initFuzzerSpecific() is expected to call startFuzzing.  Most fuzzers call it immediately but some use a timeout or callback.

  if (rnd(2)) {
    // Go now! (On DOMContentLoaded)
    initFuzzerSpecific();
  } else {
    // Let the page do its onload things first.
    window.addEventListener("load", function() { setTimeout(initFuzzerSpecific, 50); }, false);
  }
}

function initFuzzerGeneral()
{
  // Prevent bad things from happening when svg:script nodes are cloned,
  // and keep some confusion out of addDOMNodes (perhaps)
  for (var i = 1; i <= 6; ++i) {
    try {
      rM(document.getElementById("fuzz" + i));
    } catch(e) {
      // dumpln("Nothing to remove?");
    }
  }

  obtainSettings();

  dumpln("FRCX Fuzzer: " + fuzzerName);
  dumpln("FRCX URL: " + location.href);
  dumpln("FRCX Content type: " + document.contentType);
  if (document.doctype)
    dumpln("FRCX Doctype: <!DOCTYPE " + document.doctype.name + (document.doctype.publicId ? " PUBLIC \"" + document.doctype.publicId + "\"" + (document.doctype.systemId ? " \"" + document.doctype.systemId + "\"" : "") : "") + ">");

  Random.init(fuzzSeed);
}


function startFuzzing(useSerializeDOMAsScript, storeThings)
{
  if (window.fuzzCommands) {
    // Already recorded, so we should play.
    fuzzCount = 0;
    playFunsChunk();
  }
  else {
    // Not already recorded
    if (recordStrategy == "Record as it goes") {
      dumpEachCommand = true;
    }

    if (recordMode) {
      recordSomehow();
    } else {
      dumpln(oPrefix + "var fuzzSettings = [" + fuzzSettings + "];");
      dumpln(oPrefix + "var fuzzCommands = [];");

      if (useSerializeDOMAsScript) {
        if (o.length > 10000) {
          dumpln("This document contains so many nodes that reduction would be painful and serializeDOMAsScript might hang!");
          fuzzPriv.quitApplication();
          return;
        }
        serializeDOMAsScript(); // includes its own DD + BEGIN
      } else {
        dumpln(oPrefix + "// DD" + "BEGIN");
      }

      if(storeThings)
        fuzzerSmartRandomJS.storeInitialThings();

      immedChunk(numImmediate || stepsPerInterval);
    }
  }
}

function recordSomehow()
{
  switch(recordStrategy) {
    case "Record without doing":
      if (maxSteps == Infinity)
        alert("You must specify maxSteps to record with this fuzzer.");
      else
        recordFuns();

      break;

    case "Record as it goes":
      // alert("This fuzzer records as it goes.  If you encounter a crash or other bug you want to reduce, grep console output for lines containing origCount and paste that in as a fuzzCommands array.");
      immedChunk(numImmediate || stepsPerInterval);
      break;

    default:
      alert("This fuzzer doesn't seem to support recording.");
  }
}


var immedCount = 0;

function immedChunk(changes)
{<commit_msg>Remove leftover from smartrjs experiment<commit_after>// In this file:
// * Chunking of steps for speed
// * Recording and playing, to make reduction possible
// * Things to aid automated reduction with Lithium (DD* markers, fuzzPriv.quitApplication)
// * Pausing (Esc pauses, Shift+Esc unpauses)

var fuzzIsStrictMode = (function() { return !this; })();

var dumpEachCommand = false; // Can be set to true by using the "Record as it goes" reduction strategy and setting it to record.  Also, some fuzzers always set this to true.
var dumpEachSeed = false; // Can be set to true if makeCommand has side effects, such as crashing, so you have to reduce "the hard way".
var pleaseSerializeDOMAsScript = false; // Can be set to true (and often is) ...
var gPageCompleted = false;
var reportAllErrors = false;
var fuzzExpectSanity = (location.href.indexOf("xslt") == -1 && location.href.indexOf("xml-stylesheet") == -1);

var fuzzCount;

var oPrefix  = "  /*FRCA1*/ "; // most recording output, including all random commands
var oPrefix2 = "  /*FRCA2*/ "; // dom reconstruction


function fuzzOnload(ev)
{
  // Work around bug 380537.
  if (Random.twister) {
    dumpln("fuzzOnload called twice!?");
    return;
  }

  if (window != top) {
    dumpln("I'm in some kind of frame!?");
    return;
  }

  if (window.opener) {
    dumpln("I have an opener!?");
    return;
  }

  if (history.length > 1 && "fuzzPriv" in window) {
    // This check is for some of the crazier stuff fuzzerDuringEvents does.
    // Unfortunately, it breaks the "&scan" tests that are nice for testing outside of the Firefox harness.
    // And it also breaks fuzzRetry.
    dumpln("I have history!?");
    fuzzPriv.quitApplicationSoon();
    return;
  }

  initFuzzerGeneral();

  // initFuzzerSpecific() is expected to call startFuzzing.  Most fuzzers call it immediately but some use a timeout or callback.

  if (rnd(2)) {
    // Go now! (On DOMContentLoaded)
    initFuzzerSpecific();
  } else {
    // Let the page do its onload things first.
    window.addEventListener("load", function() { setTimeout(initFuzzerSpecific, 50); }, false);
  }
}

function initFuzzerGeneral()
{
  // Prevent bad things from happening when svg:script nodes are cloned,
  // and keep some confusion out of addDOMNodes (perhaps)
  for (var i = 1; i <= 6; ++i) {
    try {
      rM(document.getElementById("fuzz" + i));
    } catch(e) {
      // dumpln("Nothing to remove?");
    }
  }

  obtainSettings();

  dumpln("FRCX Fuzzer: " + fuzzerName);
  dumpln("FRCX URL: " + location.href);
  dumpln("FRCX Content type: " + document.contentType);
  if (document.doctype)
    dumpln("FRCX Doctype: <!DOCTYPE " + document.doctype.name + (document.doctype.publicId ? " PUBLIC \"" + document.doctype.publicId + "\"" + (document.doctype.systemId ? " \"" + document.doctype.systemId + "\"" : "") : "") + ">");

  Random.init(fuzzSeed);
}


function startFuzzing(useSerializeDOMAsScript)
{
  if (window.fuzzCommands) {
    // Already recorded, so we should play.
    fuzzCount = 0;
    playFunsChunk();
  }
  else {
    // Not already recorded
    if (recordStrategy == "Record as it goes") {
      dumpEachCommand = true;
    }

    if (recordMode) {
      recordSomehow();
    } else {
      dumpln(oPrefix + "var fuzzSettings = [" + fuzzSettings + "];");
      dumpln(oPrefix + "var fuzzCommands = [];");

      if (useSerializeDOMAsScript) {
        if (o.length > 10000) {
          dumpln("This document contains so many nodes that reduction would be painful and serializeDOMAsScript might hang!");
          fuzzPriv.quitApplication();
          return;
        }
        serializeDOMAsScript(); // includes its own DD + BEGIN
      } else {
        dumpln(oPrefix + "// DD" + "BEGIN");
      }

      immedChunk(numImmediate || stepsPerInterval);
    }
  }
}

function recordSomehow()
{
  switch(recordStrategy) {
    case "Record without doing":
      if (maxSteps == Infinity)
        alert("You must specify maxSteps to record with this fuzzer.");
      else
        recordFuns();

      break;

    case "Record as it goes":
      // alert("This fuzzer records as it goes.  If you encounter a crash or other bug you want to reduce, grep console output for lines containing origCount and paste that in as a fuzzCommands array.");
      immedChunk(numImmediate || stepsPerInterval);
      break;

    default:
      alert("This fuzzer doesn't seem to support recording.");
  }
}


var immedCount = 0;

function immedChunk(changes)
{
{'fraction_non_alphanumeric': 0.12210782685707959, 'fraction_numerical': 0.005313849219528396, 'mean_word_length': 3.0584007187780773, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '78685', 'n_tokens_mistral': 2959, 'n_tokens_neox': 2794, 'n_words': 897}