샘플
playwright 1.63.0: devices
검증된 샘플 — npm playwright 1.63.0: devices. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: playwright.devices exports a non-empty registry of…
sha256:1469cf2d732ed4e422f221cd4f4d2367ff1dfa05da13d054413b514a97613333
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify playwright.devices in pkg:npm/playwright@1.63.0
- 심벌
-
- playwright.devices
- 생성일
- 2026-09-10T20:26:05Z
컨트랙트
- 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
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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.');
오리진 시더
익명