Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
913 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | // Load in our dependencies
|
---|
| 2 | var ContextKarma = require('./karma')
|
---|
| 3 |
|
---|
| 4 | // Resolve our parent window
|
---|
| 5 | var parentWindow = window.opener || window.parent
|
---|
| 6 |
|
---|
| 7 | // Define a remote call method for Karma
|
---|
| 8 | var callParentKarmaMethod = ContextKarma.getDirectCallParentKarmaMethod(parentWindow)
|
---|
| 9 |
|
---|
| 10 | // If we don't have access to the window, then use `postMessage`
|
---|
| 11 | // DEV: In Electron, we don't have access to the parent window due to it being in a separate process
|
---|
| 12 | // DEV: We avoid using this in Internet Explorer as they only support strings
|
---|
| 13 | // https://caniuse.com/?search=postmessage
|
---|
| 14 | var haveParentAccess = false
|
---|
| 15 | try { haveParentAccess = !!parentWindow.window } catch (err) { /* Ignore errors (likely permisison errors) */ }
|
---|
| 16 | if (!haveParentAccess) {
|
---|
| 17 | callParentKarmaMethod = ContextKarma.getPostMessageCallParentKarmaMethod(parentWindow)
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | // Define a window-scoped Karma
|
---|
| 21 | window.__karma__ = new ContextKarma(callParentKarmaMethod)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.