Sha256: 650d5e1f569bb2bea51f3e611cbf4d5149b87ca75274b47b4d18353ac44c4305

Contents?: true

Size: 1.64 KB

Versions: 20

Compression:

Stored size: 1.64 KB

Contents

"use strict";
/* eslint-disable no-process-exit */
const util = require("util");
const { JSDOM } = require("../../../..");
const { READY_STATES } = require("./xhr-utils");
const idlUtils = require("../generated/utils");
const tough = require("tough-cookie");

const dom = new JSDOM();
const xhr = new dom.window.XMLHttpRequest();
const xhrImpl = idlUtils.implForWrapper(xhr);

const chunks = [];

process.stdin.on("data", chunk => {
  chunks.push(chunk);
});

process.stdin.on("end", () => {
  const buffer = Buffer.concat(chunks);

  const flag = JSON.parse(buffer.toString());
  if (flag.body && flag.body.type === "Buffer" && flag.body.data) {
    flag.body = Buffer.from(flag.body.data);
  }
  if (flag.cookieJar) {
    flag.cookieJar = tough.CookieJar.fromJSON(flag.cookieJar);
  }

  flag.synchronous = false;
  Object.assign(xhrImpl.flag, flag);
  const { properties } = xhrImpl;
  xhrImpl.readyState = READY_STATES.OPENED;
  try {
    xhr.addEventListener("loadend", () => {
      if (properties.error) {
        properties.error = properties.error.stack || util.inspect(properties.error);
      }
      process.stdout.write(JSON.stringify({
        responseURL: xhrImpl.responseURL,
        status: xhrImpl.status,
        statusText: xhrImpl.statusText,
        properties
      }), () => {
        process.exit(0);
      });
    }, false);
    xhr.send(flag.body);
  } catch (error) {
    properties.error += error.stack || util.inspect(error);
    process.stdout.write(JSON.stringify({
      responseURL: xhrImpl.responseURL,
      status: xhrImpl.status,
      statusText: xhrImpl.statusText,
      properties
    }), () => {
      process.exit(0);
    });
  }
});

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
appmap-0.72.2 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.72.1 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.72.0 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.71.0 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.70.2 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.70.1 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.70.0 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.69.0 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.68.2 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.68.1 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.68.0 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.67.1 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.67.0 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.66.2 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.66.1 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.66.0 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.65.1 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.65.0 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.64.0 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js
appmap-0.63.0 ./node_modules/jsdom/lib/jsdom/living/xhr/xhr-sync-worker.js