0
  getIFrameParentUrl() {
    return (window.location !== window.parent.location)
      ? document.referrer
      : document.location.href;
  };

The code above is run from an i-frame checks if an i-frame is embedded and gets the url of the site embedding the iframe. I have no idea where to even begin with this one. Is this function testable in Karma? If so, how? I need a pointer in the right direction, not necessarily the code.

Running in PhantomJs, if that's relevant.

Source of function if anyone wants more background: Access parent URL from iframe

Community
  • 1
  • 1
VSO
  • 11,546
  • 25
  • 99
  • 187
  • I am not familiar with Karma, but you can just write to window.parent. If it is possible to add some code just for tests consider using `window.postMessage()` and you will be able to listen for messages from parent window. – Yevhenii Ponomar Dec 15 '16 at 13:54
  • Unfortunately I do not always control the parent and cannot test as if I do. – VSO Dec 15 '16 at 13:55
  • 1
    PhantomJS can render just HTML you can embed your code in custom parent this way, can you do this with Karma? – Yevhenii Ponomar Dec 15 '16 at 13:57
  • Not sure, will look into it, thanks. – VSO Dec 15 '16 at 14:14

0 Answers0