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

damienbod / angular-auth-oidc-client / 9308899843

30 May 2024 08:37PM CUT coverage: 92.928%. Remained the same
9308899843

Pull #1948

github

web-flow
Merge 9ccb2c964 into 33372edf1
Pull Request #1948: feat(core): adds angular 18 support

706 of 826 branches covered (85.47%)

Branch coverage included in aggregate %.

2566 of 2695 relevant lines covered (95.21%)

8.31 hits per line

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

85.29
/projects/angular-auth-oidc-client/src/lib/iframe/existing-iframe.service.ts
1
import { DOCUMENT } from '@angular/common';
2
import { Injectable, inject } from '@angular/core';
3
import { OpenIdConfiguration } from '../config/openid-configuration';
4
import { LoggerService } from '../logging/logger.service';
5

6
@Injectable({ providedIn: 'root' })
7
export class IFrameService {
1✔
8
  private readonly document = inject(DOCUMENT);
39✔
9

10
  private readonly loggerService = inject(LoggerService);
39✔
11

12
  getExistingIFrame(identifier: string): HTMLIFrameElement | null {
13
    const iFrameOnParent = this.getIFrameFromParentWindow(identifier);
4✔
14

15
    if (this.isIFrameElement(iFrameOnParent)) {
4!
16
      return iFrameOnParent;
×
17
    }
18

19
    const iFrameOnSelf = this.getIFrameFromWindow(identifier);
4✔
20

21
    if (this.isIFrameElement(iFrameOnSelf)) {
4✔
22
      return iFrameOnSelf;
1✔
23
    }
24

25
    return null;
3✔
26
  }
27

28
  addIFrameToWindowBody(
29
    identifier: string,
30
    config: OpenIdConfiguration
31
  ): HTMLIFrameElement {
32
    const sessionIframe = this.document.createElement('iframe');
4✔
33

34
    sessionIframe.id = identifier;
4✔
35
    sessionIframe.title = identifier;
4✔
36
    this.loggerService.logDebug(config, sessionIframe);
4✔
37
    sessionIframe.style.display = 'none';
4✔
38
    this.document.body.appendChild(sessionIframe);
4✔
39

40
    return sessionIframe;
4✔
41
  }
42

43
  private getIFrameFromParentWindow(
44
    identifier: string
45
  ): HTMLIFrameElement | null {
46
    try {
4✔
47
      const iFrameElement =
48
        this.document.defaultView?.parent.document.getElementById(identifier);
4✔
49

50
      if (this.isIFrameElement(iFrameElement)) {
4!
51
        return iFrameElement;
×
52
      }
53

54
      return null;
4✔
55
    } catch (e) {
56
      return null;
×
57
    }
58
  }
59

60
  private getIFrameFromWindow(identifier: string): HTMLIFrameElement | null {
61
    const iFrameElement = this.document.getElementById(identifier);
4✔
62

63
    if (this.isIFrameElement(iFrameElement)) {
4✔
64
      return iFrameElement;
1✔
65
    }
66

67
    return null;
3✔
68
  }
69

70
  private isIFrameElement(
71
    element: HTMLElement | null | undefined
72
  ): element is HTMLIFrameElement {
73
    return !!element && element instanceof HTMLIFrameElement;
16✔
74
  }
75
}
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

© 2025 Coveralls, Inc