1 import { Logger } from './logs';
3 describe('Logger Iframe', () => {
7 Object.defineProperty(window, 'top', { value: {} });
8 logger = new Logger('test-logger-iframe');
9 console.error = jest.fn();
10 console.log = jest.fn();
17 test('should post message to parent frame on Ctrl+Shift+H in child frame', () => {
18 const spyPostMessage = jest.spyOn(window.parent, 'postMessage');
20 const event = new KeyboardEvent('keydown', {
25 window.dispatchEvent(event);
26 expect(window.self === window.top).toEqual(false);
27 expect(spyPostMessage).toHaveBeenCalledWith({ type: '@proton/utils/logs:downloadLogs' }, '*');
30 test('should post message to parent frame on .error() within child frame', () => {
31 const spyPostMessage = jest.spyOn(window.parent, 'postMessage');
32 const err = new Error('test');
34 expect(window.self === window.top).toEqual(false);
35 expect(spyPostMessage).toHaveBeenCalledWith(
36 { type: '@proton/utils/logs:report', tag: 'test-logger-iframe', args: [err] },