26 lines
1002 B
JavaScript
26 lines
1002 B
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { mayReadClipboardAutomatically } from '../../web/src/clipboardAccess.js';
|
|
|
|
test('클립보드 자동 읽기는 모바일 확인과 지원하지 않는 권한 API를 우회하지 않는다', async () => {
|
|
assert.equal(await mayReadClipboardAutomatically({}, true), false);
|
|
const nav = (state) => ({ permissions: { query: async () => ({ state }) } });
|
|
assert.equal(await mayReadClipboardAutomatically(nav('granted'), true), true);
|
|
assert.equal(await mayReadClipboardAutomatically(nav('prompt'), true), false);
|
|
assert.equal(await mayReadClipboardAutomatically(nav('denied'), false), false);
|
|
assert.equal(await mayReadClipboardAutomatically(nav('prompt'), false), true);
|
|
assert.equal(
|
|
await mayReadClipboardAutomatically(
|
|
{
|
|
permissions: {
|
|
query: async () => {
|
|
throw new TypeError('unsupported');
|
|
},
|
|
},
|
|
},
|
|
false,
|
|
),
|
|
false,
|
|
);
|
|
});
|