CodeSampleX

Ejemplo

playwright 1.63.0

Muestra verificada para npm playwright 1.63.0. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó: chromium, firefox, and webkit browser…

sha256:d5e9d11d35391f53bd06aa71c11eef57188f162b3d4547defb0ca3d142c212a5

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-10

Caso

HOW
Objetivo
verify pkg:npm/playwright@1.63.0
Paquetes
Creado
2026-09-10T17:27:14Z

Contrato

  1. chromium, firefox, and webkit browser types provide expected type names
  2. devices dictionary exposes mobile device emulation profiles
  3. errors namespace exports TimeoutError error class
  4. request APIRequestContext sends HTTP GET requests and parses JSON responses
  5. request APIRequestContext supports POST requests with JSON payload
  6. request APIRequestContext handles non-ok status codes and text responses

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Descargar el artefacto de código fuente (tar.gz)

Código fuente

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:npm/playwright@1.63.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/playwright@1.63.0

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:3942bed4780aa5fce744f527f2ccf432f45846b641749064350e55a87e22fbbb","contract":["chromium, firefox, and webkit browser types provide expected type names","devices dictionary exposes mobile device emulation profiles","errors namespace exports TimeoutError error class","request APIRequestContext sends HTTP GET requests and parses JSON responses","request APIRequestContext supports POST requests with JSON payload","request APIRequestContext handles non-ok status codes and text responses"],"goal":"verify pkg:npm/playwright@1.63.0","kind":"HOW","packages":["pkg:npm/playwright@1.63.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/playwright@1.63.0"],"schemaVersion":1,"subject":"pkg:npm/playwright@1.63.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "playwright-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "playwright-sample",
      "version": "1.0.0",
      "dependencies": {
        "playwright": "1.63.0"
      }
    },
    "node_modules/playwright": {
      "version": "1.63.0",
      "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.63.0.tgz",
      "integrity": "sha512-+7ziBLidS4NaNCdt57SUDT+wYmmd5fmiQejUic/kb+YsYSCPyOOE9sebzMjNmQrsnNpDJqd4WHvV/8lfKfUDUg==",
      "license": "Apache-2.0",
      "dependencies": {
        "playwright-core": "1.63.0"
      },
      "bin": {
        "playwright": "cli.js"
      },
      "engines": {
        "node": ">=20"
      }
    },
    "node_modules/playwright-core": {
      "version": "1.63.0",
      "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.63.0.tgz",
      "integrity": "sha512-rYCsBF/M5HjUch52bbtVONEFjv6Xu8sm8h72dNlR5bzIE1fvC/bxgspzkjSfU+MweEMmPM8KJebG6nnyxo5mCg==",
      "license": "Apache-2.0",
      "bin": {
        "playwright-core": "cli.js"
      },
      "engines": {
        "node": ">=20"
      }
    }
  }
}
package.json
{
  "name": "playwright-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for playwright",
  "dependencies": {
    "playwright": "1.63.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/playwright@1.63.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/playwright@1.63.0"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import http from 'node:http';
import { chromium, firefox, webkit, devices, errors, request } from 'playwright';

// 1. chromium, firefox, and webkit browser types provide expected type names
assert.strictEqual(chromium.name(), 'chromium');
assert.strictEqual(firefox.name(), 'firefox');
assert.strictEqual(webkit.name(), 'webkit');

// 2. devices dictionary exposes mobile device emulation profiles
assert.ok('iPhone 12' in devices);
const iphone = devices['iPhone 12'];
assert.ok(iphone.userAgent.includes('iPhone'));
assert.strictEqual(typeof iphone.viewport.width, 'number');
assert.strictEqual(typeof iphone.viewport.height, 'number');
assert.strictEqual(iphone.isMobile, true);
assert.strictEqual(iphone.hasTouch, true);

// 3. errors namespace exports TimeoutError error class
assert.ok(errors.TimeoutError);
const timeoutErr = new errors.TimeoutError('operation timed out');
assert.ok(timeoutErr instanceof Error);
assert.strictEqual(timeoutErr.name, 'TimeoutError');

// 4. request APIRequestContext sends HTTP GET requests and parses JSON responses
{
  const server = http.createServer((req, res) => {
    if (req.url === '/api/status') {
      res.writeHead(200, { 'Content-Type': 'application/json' });
      res.end(JSON.stringify({ status: 'ok', version: '1.63.0' }));
      return;
    }
    res.writeHead(404);
    res.end();
  });
  await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
  const port = server.address().port;

  try {
    const context = await request.newContext({ baseURL: `http://127.0.0.1:${port}` });
    const res = await context.get('/api/status');
    assert.strictEqual(res.status(), 200);
    assert.strictEqual(res.ok(), true);
    const data = await res.json();
    assert.strictEqual(data.status, 'ok');
    assert.strictEqual(data.version, '1.63.0');
    await context.dispose();
  } finally {
    await new Promise((resolve) => server.close(resolve));
  }
}

// 5. request APIRequestContext supports POST requests with JSON payload
{
  let receivedBody = null;
  const server = http.createServer((req, res) => {
    let body = '';
    req.on('data', (chunk) => {
      body += chunk;
    });
    req.on('end', () => {
      receivedBody = JSON.parse(body);
      res.writeHead(201, { 'Content-Type': 'application/json' });
      res.end(JSON.stringify({ received: true, echo: receivedBody }));
    });
  });
  await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
  const port = server.address().port;

  try {
    const context = await request.newContext({ baseURL: `http://127.0.0.1:${port}` });
    const res = await context.post('/api/echo', {
      data: { test: 'playwright-contract' },
    });
    assert.strictEqual(res.status(), 201);
    const data = await res.json();
    assert.strictEqual(data.received, true);
    assert.deepStrictEqual(data.echo, { test: 'playwright-contract' });
    await context.dispose();
  } finally {
    await new Promise((resolve) => server.close(resolve));
  }
}

// 6. request APIRequestContext handles non-ok status codes and text responses
{
  const server = http.createServer((req, res) => {
    res.writeHead(404, { 'Content-Type': 'text/plain' });
    res.end('Not Found Here');
  });
  await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
  const port = server.address().port;

  try {
    const context = await request.newContext({ baseURL: `http://127.0.0.1:${port}` });
    const res = await context.get('/missing');
    assert.strictEqual(res.status(), 404);
    assert.strictEqual(res.ok(), false);
    const text = await res.text();
    assert.strictEqual(text, 'Not Found Here');
    await context.dispose();
  } finally {
    await new Promise((resolve) => server.close(resolve));
  }
}

console.log('Contract passed');

Seeder de origen

anónimo