|
41 | 41 | ];
|
42 | 42 | });
|
43 | 43 |
|
44 |
| - // eslint-disable-next-line no-undef |
45 | 44 | test('Script that should execute', async () => {
|
46 | 45 | window.scripty2Ran = false;
|
47 | 46 | const scriptElement = document.createElement('script');
|
|
66 | 65 | ];
|
67 | 66 | });
|
68 | 67 |
|
69 |
| - // eslint-disable-next-line no-undef |
| 68 | + test('Script array createElement that should execute', async () => { |
| 69 | + window.scripty2aRan = false; |
| 70 | + let scriptElementArray |
| 71 | + try { |
| 72 | + scriptElementArray = document.createElement(['script']); |
| 73 | + scriptElementArray.innerText = 'window.scripty2aRan = true'; |
| 74 | + scriptElementArray.id = 'scripty2a'; |
| 75 | + scriptElementArray.setAttribute('type', 'application/javascript'); |
| 76 | + document.body.appendChild(scriptElementArray); |
| 77 | + } catch { |
| 78 | + // We shouldn't ever get here unless the test is failing in which case the run check will fail. |
| 79 | + } |
| 80 | + const hadInspectorNode = scriptElementArray === document.querySelector('ddg-runtime-checks:last-of-type'); |
| 81 | + const instanceofResult = scriptElementArray instanceof HTMLScriptElement; |
| 82 | + const scriptyArray = document.querySelector('#scripty2a'); |
| 83 | + |
| 84 | + return [ |
| 85 | + { name: 'hadInspectorNode', result: hadInspectorNode, expected: true }, |
| 86 | + { name: 'expect script to match', result: scriptyArray, expected: scriptElementArray }, |
| 87 | + { name: 'instanceof matches HTMLScriptElement', result: instanceofResult, expected: true }, |
| 88 | + { name: 'scripty.type', result: scriptyArray?.type, expected: 'application/javascript' }, |
| 89 | + { name: 'scripty.id', result: scriptyArray?.id, expected: 'scripty2a' }, |
| 90 | + { name: 'script ran', result: window.scripty2aRan, expected: true } |
| 91 | + ]; |
| 92 | + }); |
| 93 | + |
70 | 94 | test('Invalid external script should trigger error listeners', async () => {
|
71 | 95 | const scriptElement = document.createElement('script');
|
72 | 96 | scriptElement.id = 'scripty3';
|
|
0 commit comments