Ejemplo n.º 1
0
      it('triggers an event if message is from trusted origin', function () {
        sinon.spy(channel, 'trigger');

        channel.receiveEvent({
          data: IFrameChannel.stringify('message_type', { key: 'value' }),
          origin: 'https://trusted-parent.org',
          type: 'message'
        });

        assert.isTrue(
          channel.trigger.calledWith('message_type', { key: 'value' }));
      });
Ejemplo n.º 2
0
      it('ignores and logs messages from untrusted origins', function () {
        var errorSpy = sinon.spy();
        channel.on('error', errorSpy);

        channel.receiveEvent({
          data: IFrameChannel.stringify('message_type', { key: 'value' }),
          origin: 'https://untrusted-parent.org',
          type: 'message'
        });

        var error = errorSpy.args[0][0];
        assert.isTrue(AuthErrors.is(error, 'UNEXPECTED_POSTMESSAGE_ORIGIN'));
        assert.equal(error.context, 'https://untrusted-parent.org');
      });
 OriginCheck.stringify = function (command) {
   return IFrameChannel.stringify(command);
 };