@@ -7,13 +7,113 @@ import type {Schema} from './models/models.js';
7
7
8
8
describe ( 'Injected' , ( ) => {
9
9
let iframe : HTMLIFrameElement | undefined ;
10
+ // TODO: use smaller test pages per test.
11
+ const testPage = `<!DOCTYPE html>
12
+ <html>
13
+ <head>
14
+ <meta charset="UTF-8" />
15
+ <meta name="viewport" content="width=device-width" />
16
+ <title>Recording Client example</title>
17
+ <style>
18
+ html, body, * {
19
+ margin: 0;
20
+ padding: 0;
21
+ }
22
+ button {
23
+ width: 100px;
24
+ height: 20px;
25
+ }
26
+ </style>
27
+ </head>
28
+ <body>
29
+
30
+ <button aria-role="button" aria-name="testButton" id="button"></button>
31
+ <button id="buttonNoARIA"></button>
32
+ <button id="buttonWithLength11">length a 11</button>
33
+ <button id="buttonWithLength12">length aa 12</button>
34
+ <button id="buttonWithLength32">length aaaaaaaaa aaaaaaaaa aa 32</button>
35
+ <button id="buttonWithLength33">length aaaaaaaaa aaaaaaaaa aaa 33</button>
36
+ <button id="buttonWithLength64">length aaaaaaaaa aaaaaaaaa aaaaaaaaa aaaaaaaaa aaaaaaaaa aaaa 64</button>
37
+ <button id="buttonWithLength65">length aaaaaaaaa aaaaaaaaa aaaaaaaaa aaaaaaaaa aaaaaaaaa aaaaa 65</button>
38
+ <button id="buttonWithNewLines">
39
+ with newlines
40
+ </button>
41
+ <input id="input"></input>
42
+
43
+ <script>
44
+ class ShadowCSSSelectorElement extends HTMLElement {
45
+ constructor() {
46
+ super();
47
+ const shadow = this.attachShadow({mode: 'open'});
48
+ shadow.innerHTML = \`
49
+ <p>sss</p>
50
+ <button id="insideShadowRoot">Login</button>
51
+ \`;
52
+ }
53
+ }
54
+ customElements.define('shadow-css-selector-element', ShadowCSSSelectorElement);
55
+
56
+ class ShadowARIASelectorElement extends HTMLElement {
57
+ constructor() {
58
+ super();
59
+ const shadow = this.attachShadow({mode: 'open'});
60
+ shadow.innerHTML = \`
61
+ <p>sss</p>
62
+ <button aria-role="button" aria-name="login">Login</button>
63
+ \`;
64
+ }
65
+ }
66
+ customElements.define('shadow-aria-selector-element', ShadowARIASelectorElement);
67
+ </script>
68
+ <header>
69
+ <shadow-css-selector-element></shadow-css-selector-element>
70
+ </header>
71
+ <main>
72
+ <shadow-css-selector-element></shadow-css-selector-element>
73
+ </main>
74
+
75
+ <div aria-role="header">
76
+ <shadow-aria-selector-element></shadow-aria-selector-element>
77
+ </div>
78
+ <div aria-role="main">
79
+ <shadow-aria-selector-element></shadow-aria-selector-element>
80
+ </div>
81
+
82
+ <div aria-name="parent-name">
83
+ <div id="no-aria-name-or-role" aria-name="" aria-role="">
84
+ </div>
85
+
86
+ <host-element id="slotted-host-element">
87
+ <template shadowrootmode="open">
88
+ <slot></slot>
89
+ </template>
90
+ text in slot
91
+ </host-element>
92
+
93
+ <button class="custom-selector-attribute" data-testid="unique">Custom selector</button>
94
+ <button class="custom-selector-attribute" data-testid="123456789">Custom selector (invalid CSS id)</button>
95
+
96
+ <host-element id="shadow-root-with-custom-selectors" data-qa="custom-id">
97
+ <template shadowrootmode="open">
98
+ <button data-testid="shadow button">Shadow button with testid</button>>
99
+ </template>
100
+ </host-element>
101
+
102
+ <div id="notunique"></div>
103
+ <div id="notunique"></div>
104
+ </body>
105
+ </html>` ;
10
106
107
+ /**
108
+ * Loads scripts injected by Recorder into a new iframe to make sure
109
+ * they run in dedicated environment.
110
+ */
11
111
async function createSandbox ( ) : Promise < Window > {
12
112
const url = new URL ( './injected/injected.generated.js' , import . meta. url ) ;
13
113
14
114
iframe = document . createElement ( 'iframe' ) ;
15
115
const { promise, resolve} = Promise . withResolvers ( ) ;
16
- iframe . src = new URL ( '../../ui/components/docs/recorder_injected/basic.html' , import . meta . url ) . toString ( ) ;
116
+ iframe . srcdoc = testPage ;
17
117
iframe . onload = resolve ;
18
118
document . body . append ( iframe ) ;
19
119
await promise ;
0 commit comments