• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

excaliburjs / Excalibur / 29113721976

10 Jul 2026 06:12PM UTC coverage: 88.902% (-0.004%) from 88.906%
29113721976

Pull #3793

github

web-flow
Merge e34b9fb0f into 3ee8a530a
Pull Request #3793: chore: TS6 Upgrades + Typedoc update

6933 of 9094 branches covered (76.24%)

279 of 378 new or added lines in 58 files covered. (73.81%)

3 existing lines in 2 files now uncovered.

15517 of 17454 relevant lines covered (88.9%)

24916.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.75
/src/engine/util/iframe.ts
1
import { Logger } from './log';
2

3
/**
4
 * Checks if excalibur is in a x-origin iframe
5
 */
6
export function isCrossOriginIframe() {
7
  try {
2,263✔
8
    // Try and listen to events on top window frame if within an iframe.
9
    //
10
    // See https://github.com/excaliburjs/Excalibur/issues/1294
11
    //
12
    // Attempt to add an event listener, which triggers a DOMException on
13
    // cross-origin iframes
14
    const noop = () => {
2,263✔
15
      return;
×
16
    };
17
    window.top!.addEventListener('blur', noop);
2,263✔
18
    window.top!.removeEventListener('blur', noop);
2,263✔
19
  } catch {
20
    return true;
×
21
  }
22
  return false;
2,263✔
23
}
24

25
export function isIframe() {
26
  return window !== window.top;
2,263✔
27
}
28

29
/**
30
 * Grabs the default global object for Excalibur
31
 */
32
export function getDefaultGlobal(): GlobalEventHandlers {
33
  let global: GlobalEventHandlers;
34
  if (isCrossOriginIframe()) {
776!
35
    global = window;
×
36
    Logger.getInstance().warnOnce('Excalibur might be in a cross-origin iframe, in order to receive keyboard events it must be in focus');
×
37
  } else if (isIframe()) {
776!
38
    global = window;
776✔
39
    Logger.getInstance().warnOnce('Excalibur might be in a iframe, in order to receive keyboard events it must be in focus');
776✔
40
  } else {
NEW
41
    global = window.top!;
×
42
  }
43

44
  return global;
776✔
45
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc