about summary refs log tree commit diff stats
path: root/js/baba-yaga/debug-sandbox.js
blob: 96b66be0035b7d0f388402f2e91fd2c7a9bf4021 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// debug-sandbox.js - Debug the sandbox structure

import { createDefaultJSBridge } from './src/core/js-bridge.js';

const bridge = createDefaultJSBridge({
  allowedFunctions: new Set([
    'JSON.parse', 'JSON.stringify',
    'Math.abs', 'Math.floor', 'Math.ceil', 'Math.round',
    'Math.min', 'Math.max', 'Math.random',
    'console.log', 'console.warn', 'console.error',
    'Date.now', 'performance.now'
  ])
});

console.log('Sandbox keys:', Object.keys(bridge.config.sandbox));
console.log('Math object:', bridge.config.sandbox.Math);
console.log('Math.abs:', bridge.config.sandbox.Math.abs);
console.log('typeof Math.abs:', typeof bridge.config.sandbox.Math.abs);

// Test function resolution
const fn = bridge.resolveFunction('Math.abs');
console.log('Resolved function:', fn);
console.log('Function type:', typeof fn);

// Test function call
const result = bridge.callFunction('Math.abs', [-5]);
console.log('Call result:', result);