Beispiel
playwright 1.63.0: devices
Verifiziertes Beispiel für npm playwright 1.63.0: devices. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.
sha256:1469cf2d732ed4e422f221cd4f4d2367ff1dfa05da13d054413b514a97613333
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 npm
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify playwright.devices in pkg:npm/playwright@1.63.0
- Pakete
- Symbole
-
- playwright.devices
- Erstellt
- 2026-09-10T20:26:05Z
Contract
- playwright.devices exports a non-empty registry of device emulation descriptors
- playwright.devices contains standard Desktop Chrome descriptor configured for non-mobile chromium
- playwright.devices contains standard iPhone 13 descriptor configured for mobile webkit with touch
- playwright.devices contains standard Pixel 5 descriptor configured for mobile chromium with touch
- all device descriptors in playwright.devices conform to standard descriptor schema
- getDevicesByBrowser filters device descriptors by matching defaultBrowserType
- getDevicesByMobile separates mobile device profiles from desktop profiles
- getDevice returns undefined when requested device name does not exist
Dateien
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Quelltext
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 playwright.devices in pkg:npm/playwright@1.63.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/playwright@1.63.0
Demonstrate these symbols/APIs:
- playwright.devices
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.
{"case":{"caseId":"case:sha256:4b269e863b296eaa2f7f8540e7064908f86a209297c1eaa17c65ea8ae31536f7","contract":["playwright.devices exports a non-empty registry of device emulation descriptors","playwright.devices contains standard Desktop Chrome descriptor configured for non-mobile chromium","playwright.devices contains standard iPhone 13 descriptor configured for mobile webkit with touch","playwright.devices contains standard Pixel 5 descriptor configured for mobile chromium with touch","all device descriptors in playwright.devices conform to standard descriptor schema","getDevicesByBrowser filters device descriptors by matching defaultBrowserType","getDevicesByMobile separates mobile device profiles from desktop profiles","getDevice returns undefined when requested device name does not exist"],"goal":"verify playwright.devices in pkg:npm/playwright@1.63.0","kind":"HOW","packages":["pkg:npm/playwright@1.63.0"],"schemaVersion":1,"symbols":["playwright.devices"]},"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","symbols":["playwright.devices"],"verifierAdapter":"node-typescript@1"}
import { devices } from 'playwright';
/**
* Returns the full dictionary of device descriptors.
* @returns {Record<string, object>}
*/
export function getAllDevices() {
return devices;
}
/**
* Retrieves a device descriptor by name.
* @param {string} deviceName
* @returns {object | undefined}
*/
export function getDevice(deviceName) {
return devices[deviceName];
}
/**
* Filters device descriptors by defaultBrowserType ('chromium' | 'firefox' | 'webkit').
* @param {string} browserType
* @returns {Record<string, object>}
*/
export function getDevicesByBrowser(browserType) {
const result = {};
for (const [name, descriptor] of Object.entries(devices)) {
if (descriptor.defaultBrowserType === browserType) {
result[name] = descriptor;
}
}
return result;
}
/**
* Filters device descriptors by mobile capability.
* @param {boolean} isMobile
* @returns {Record<string, object>}
*/
export function getDevicesByMobile(isMobile) {
const result = {};
for (const [name, descriptor] of Object.entries(devices)) {
if (descriptor.isMobile === isMobile) {
result[name] = descriptor;
}
}
return result;
}
/**
* Validates the schema of a device descriptor.
* @param {object} descriptor
* @returns {boolean}
*/
export function isValidDeviceDescriptor(descriptor) {
if (!descriptor || typeof descriptor !== 'object') {
return false;
}
return (
typeof descriptor.userAgent === 'string' &&
typeof descriptor.viewport === 'object' &&
descriptor.viewport !== null &&
typeof descriptor.viewport.width === 'number' &&
typeof descriptor.viewport.height === 'number' &&
typeof descriptor.deviceScaleFactor === 'number' &&
typeof descriptor.isMobile === 'boolean' &&
typeof descriptor.hasTouch === 'boolean' &&
typeof descriptor.defaultBrowserType === 'string'
);
}
export default devices;
{
"name": "sample-playwright-devices",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-playwright-devices",
"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"
}
}
}
}
{
"name": "sample-playwright-devices",
"version": "1.0.0",
"description": "verify playwright.devices in pkg:npm/playwright@1.63.0",
"main": "index.js",
"type": "module",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"playwright": "1.63.0"
}
}
{
"schemaVersion": 1,
"goal": "verify playwright.devices in pkg:npm/playwright@1.63.0",
"kind": "HOW",
"packages": [
"pkg:npm/playwright@1.63.0"
],
"symbols": [
"playwright.devices"
]
}
import assert from 'node:assert/strict';
import devices, {
getAllDevices,
getDevice,
getDevicesByBrowser,
getDevicesByMobile,
isValidDeviceDescriptor
} from '../index.js';
// 1. playwright.devices exports a non-empty registry of device emulation descriptors
{
assert(devices && typeof devices === 'object', 'devices must be an object');
const all = getAllDevices();
const keys = Object.keys(all);
assert(keys.length > 50, `expected at least 50 device descriptors, found ${keys.length}`);
}
// 2. playwright.devices contains standard Desktop Chrome descriptor configured for non-mobile chromium
{
const desktopChrome = getDevice('Desktop Chrome');
assert(desktopChrome, 'Desktop Chrome device descriptor must exist');
assert.strictEqual(desktopChrome.defaultBrowserType, 'chromium');
assert.strictEqual(desktopChrome.isMobile, false);
assert.strictEqual(desktopChrome.hasTouch, false);
assert(desktopChrome.viewport.width > 0 && desktopChrome.viewport.height > 0);
assert(typeof desktopChrome.userAgent === 'string' && desktopChrome.userAgent.length > 0);
}
// 3. playwright.devices contains standard iPhone 13 descriptor configured for mobile webkit with touch
{
const iphone = getDevice('iPhone 13');
assert(iphone, 'iPhone 13 device descriptor must exist');
assert.strictEqual(iphone.defaultBrowserType, 'webkit');
assert.strictEqual(iphone.isMobile, true);
assert.strictEqual(iphone.hasTouch, true);
assert.strictEqual(iphone.deviceScaleFactor, 3);
assert.strictEqual(iphone.viewport.width, 390);
assert.strictEqual(iphone.viewport.height, 664);
assert(iphone.userAgent.includes('iPhone'));
}
// 4. playwright.devices contains standard Pixel 5 descriptor configured for mobile chromium with touch
{
const pixel = getDevice('Pixel 5');
assert(pixel, 'Pixel 5 device descriptor must exist');
assert.strictEqual(pixel.defaultBrowserType, 'chromium');
assert.strictEqual(pixel.isMobile, true);
assert.strictEqual(pixel.hasTouch, true);
assert.strictEqual(pixel.deviceScaleFactor, 2.75);
assert.strictEqual(pixel.viewport.width, 393);
assert.strictEqual(pixel.viewport.height, 727);
assert(pixel.userAgent.includes('Pixel 5'));
}
// 5. all device descriptors in playwright.devices conform to standard descriptor schema
{
for (const [name, descriptor] of Object.entries(devices)) {
assert(isValidDeviceDescriptor(descriptor), `Device descriptor for "${name}" does not match schema`);
}
}
// 6. getDevicesByBrowser filters device descriptors by matching defaultBrowserType
{
const chromiumDevices = getDevicesByBrowser('chromium');
const webkitDevices = getDevicesByBrowser('webkit');
const firefoxDevices = getDevicesByBrowser('firefox');
assert(Object.keys(chromiumDevices).length > 0, 'Must have chromium devices');
assert(Object.keys(webkitDevices).length > 0, 'Must have webkit devices');
for (const desc of Object.values(chromiumDevices)) {
assert.strictEqual(desc.defaultBrowserType, 'chromium');
}
for (const desc of Object.values(webkitDevices)) {
assert.strictEqual(desc.defaultBrowserType, 'webkit');
}
for (const desc of Object.values(firefoxDevices)) {
assert.strictEqual(desc.defaultBrowserType, 'firefox');
}
}
// 7. getDevicesByMobile separates mobile device profiles from desktop profiles
{
const mobileDevices = getDevicesByMobile(true);
const desktopDevices = getDevicesByMobile(false);
assert(Object.keys(mobileDevices).length > 0, 'Must have mobile devices');
assert(Object.keys(desktopDevices).length > 0, 'Must have desktop devices');
for (const desc of Object.values(mobileDevices)) {
assert.strictEqual(desc.isMobile, true);
}
for (const desc of Object.values(desktopDevices)) {
assert.strictEqual(desc.isMobile, false);
}
}
// 8. getDevice returns undefined when requested device name does not exist
{
const nonexistent = getDevice('__nonexistent_device_model_12345__');
assert.strictEqual(nonexistent, undefined);
}
console.log('Contract tests passed successfully.');
Ursprungs-Seeder
anonym