main.js 912 B

12345678910111213141516171819202122
  1. // Load in our dependencies
  2. var ContextKarma = require('./karma')
  3. // Resolve our parent window
  4. var parentWindow = window.opener || window.parent
  5. // Define a remote call method for Karma
  6. var callParentKarmaMethod = ContextKarma.getDirectCallParentKarmaMethod(parentWindow)
  7. // If we don't have access to the window, then use `postMessage`
  8. // DEV: In Electron, we don't have access to the parent window due to it being in a separate process
  9. // DEV: We avoid using this in Internet Explorer as they only support strings
  10. // http://caniuse.com/#search=postmessage
  11. var haveParentAccess = false
  12. try { haveParentAccess = !!parentWindow.window } catch (err) { /* Ignore errors (likely permisison errors) */ }
  13. if (!haveParentAccess) {
  14. callParentKarmaMethod = ContextKarma.getPostMessageCallParentKarmaMethod(parentWindow)
  15. }
  16. // Define a window-scoped Karma
  17. window.__karma__ = new ContextKarma(callParentKarmaMethod)