|
1 | 1 | import { createHead } from '@unhead/vue/client'
|
| 2 | +import { renderSSRHead } from '@unhead/vue/server' |
| 3 | + |
2 | 4 | import { describe, it } from 'vitest'
|
3 | 5 | import { ref, watch } from 'vue'
|
4 | 6 | import { useDom } from '../../../unhead/test/util'
|
5 | 7 | import { useScript } from '../../src/scripts/useScript'
|
| 8 | +import { createHeadCore } from '../../src' |
6 | 9 |
|
7 | 10 | describe('vue e2e scripts', () => {
|
8 | 11 | it('multiple active promise handles', async () => {
|
@@ -113,4 +116,50 @@ describe('vue e2e scripts', () => {
|
113 | 116 | expect(status.value).toEqual('loading')
|
114 | 117 | expect(status2.value).toEqual('loading')
|
115 | 118 | })
|
| 119 | + |
| 120 | + it('respects useScript privacy controls - #293', async () => { |
| 121 | + const head = createHeadCore() |
| 122 | + const script = useScript({ |
| 123 | + src: 'https://s.kk-resources.com/leadtag.js', |
| 124 | + async: true, |
| 125 | + crossorigin: false, |
| 126 | + }, { |
| 127 | + head, |
| 128 | + }) |
| 129 | + const ssr = await renderSSRHead(head) |
| 130 | + expect(ssr.headTags.replace('>', '').split(' ').sort()).toMatchInlineSnapshot(` |
| 131 | + [ |
| 132 | + "<link", |
| 133 | + "as="script"", |
| 134 | + "fetchpriority="low"", |
| 135 | + "href="https://s.kk-resources.com/leadtag.js"", |
| 136 | + "referrerpolicy="no-referrer"", |
| 137 | + "rel="preload"", |
| 138 | + ] |
| 139 | + `) |
| 140 | + script.remove() |
| 141 | + }) |
| 142 | + it('respects useScript privacy controls', async () => { |
| 143 | + const head = createHeadCore() |
| 144 | + const script = useScript({ |
| 145 | + src: 'https://s.kk-resources.com/leadtag.js', |
| 146 | + crossorigin: 'use-credentials', |
| 147 | + referrerpolicy: 'no-referrer-when-downgrade', |
| 148 | + }, { |
| 149 | + head, |
| 150 | + }) |
| 151 | + const ssr = await renderSSRHead(head) |
| 152 | + expect(ssr.headTags.replace('>', '').split(' ').sort()).toMatchInlineSnapshot(` |
| 153 | + [ |
| 154 | + "<link", |
| 155 | + "as="script"", |
| 156 | + "crossorigin="use-credentials"", |
| 157 | + "fetchpriority="low"", |
| 158 | + "href="https://s.kk-resources.com/leadtag.js"", |
| 159 | + "referrerpolicy="no-referrer-when-downgrade"", |
| 160 | + "rel="preload"", |
| 161 | + ] |
| 162 | + `) |
| 163 | + script.remove() |
| 164 | + }) |
116 | 165 | })
|
0 commit comments