訂判斷及所需輸入
R1 必須可讀 E1。錯介面只在懸停顯示,焦點到紀錄仍藏。更正加 Show evidence,Enter 或觸控都開同一原文;字留在藏着的 DOM,未完成閱讀。
| 情況 | 輸入 JSON |
|---|---|
| 原例測試 | {"method":"keyboard"} |
跑所附比較
瀏覽器實際懸停、Enter 及觸控後核顯示狀態;顯示不會授予受限資料權限,也不標個案已完成。
| 路徑 | 輸出 JSON |
|---|---|
| 錯誤路徑 | {"visible":false,"text":"Evidence E1"} |
| 所需路徑 | {"visible":true,"text":"Evidence E1"} |
import assert from 'node:assert/strict';
import {createRequire} from 'node:module';
const htmlEscape=s=>String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
async function withPage(action,options={}){
const require=createRequire(import.meta.url);const {chromium}=require('playwright');
const browser=await chromium.launch({headless:true});
try{const context=await browser.newContext(options);const page=await context.newPage();
const requests=[];await page.route('**/*',route=>{requests.push(route.request().url());return route.abort();});
return await action(page,context,requests);
}finally{await browser.close();}
}
const run=async function run(i,corrected=true){
if(!['keyboard','touch','pointer'].includes(i.method))return {held:true};
return withPage(async page=>{await page.setContent('<style>#tip{display:none}.record:hover #tip{display:block}</style><div class="record" tabindex="0" id="record">Record R1'+(corrected?'<button id="show">Show evidence</button>':'')+'<span id="tip">Evidence E1</span></div>');
if(corrected)await page.evaluate(()=>document.querySelector('#show').addEventListener('click',()=>document.querySelector('#tip').style.display='block'));
if(i.method==='pointer')await page.hover('#record');else if(corrected&&i.method==='touch')await page.tap('#show');else if(corrected){await page.focus('#show');await page.press('#show','Enter');}else await page.focus('#record');
return page.evaluate(()=>({visible:getComputedStyle(document.querySelector('#tip')).display!=='none',text:document.querySelector('#tip').textContent}));
},{hasTouch:i.method==='touch'});
};
const cases=[{"input":{"method":"keyboard"},"corrected":false,"expected":{"visible":false,"text":"Evidence E1"}},{"input":{"method":"keyboard"},"corrected":true,"expected":{"visible":true,"text":"Evidence E1"}},{"input":{"method":"touch"},"corrected":true,"expected":{"visible":true,"text":"Evidence E1"}},{"input":{"method":"pointer"},"corrected":true,"expected":{"visible":true,"text":"Evidence E1"}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
按邊界依據作判斷
更正觸控及指標邊界都顯 E1,原文身分不改。
- 核必須可讀依據
- 各按所需方法開
- 核真正顯示狀態
權限規則與開啟機制分開核。
| 條件 | 輸入 JSON | 預期輸出 JSON |
|---|---|---|
| 觸控開啟依據 | {"method":"touch"} | {"visible":true,"text":"Evidence E1"} |
| 指標開啟依據 | {"method":"pointer"} | {"visible":true,"text":"Evidence E1"} |
原例鍵盤動作須開到甚麼?
查看參考答案
同一 E1,而且真正看得到,不是只有隱藏文字節點。