@ui5/webcomponents-base 2.10.0 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/cypress/specs/ConfigurationChange.cy.tsx +199 -0
- package/cypress/specs/ConfigurationScript.cy.tsx +395 -0
- package/cypress/specs/ConfigurationURL.cy.tsx +378 -56
- package/cypress/specs/ThemeRoot.cy.tsx +180 -0
- package/cypress/specs/ThemeRootAPI.cy.tsx +148 -0
- package/dist/.tsbuildinfobuild +1 -1
- package/dist/InitialConfiguration.js +1 -2
- package/dist/InitialConfiguration.js.map +1 -1
- package/dist/config/ThemeRoot.js +12 -7
- package/dist/config/ThemeRoot.js.map +1 -1
- package/dist/generated/VersionInfo.js +3 -3
- package/dist/generated/VersionInfo.js.map +1 -1
- package/dist/prod/InitialConfiguration.js +1 -1
- package/dist/prod/InitialConfiguration.js.map +3 -3
- package/dist/prod/config/ThemeRoot.js +1 -1
- package/dist/prod/config/ThemeRoot.js.map +3 -3
- package/dist/prod/generated/VersionInfo.js +1 -1
- package/dist/prod/generated/VersionInfo.js.map +1 -1
- package/dist/prod/validateThemeRoot.js +1 -1
- package/dist/prod/validateThemeRoot.js.map +3 -3
- package/dist/validateThemeRoot.js +24 -13
- package/dist/validateThemeRoot.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.10.1](https://github.com/UI5/webcomponents/compare/v2.10.0...v2.10.1) (2026-05-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **framework:** improve themeRoot validation ([#13354](https://github.com/UI5/webcomponents/issues/13354)) ([8735b72](https://github.com/UI5/webcomponents/commit/8735b72ffd1103fa02c26cbba55d28d7562747da))
|
|
12
|
+
* validate correctly protocol relative urls ([#13447](https://github.com/UI5/webcomponents/issues/13447)) ([2fc757f](https://github.com/UI5/webcomponents/commit/2fc757f2e37aede2974a9136de908ce3bd4fc37d))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
# [2.10.0](https://github.com/SAP/ui5-webcomponents/compare/v2.10.0-rc.3...v2.10.0) (2025-05-07)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @ui5/webcomponents-base
|
|
@@ -39,3 +39,202 @@ describe("Some configuration options can be changed at runtime", () => {
|
|
|
39
39
|
.should("deep.equal", newThemeRoot);
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
|
+
|
|
43
|
+
describe("ThemeRoot validation at runtime", () => {
|
|
44
|
+
describe("Valid themeRoot with allowed origin", () => {
|
|
45
|
+
before(() => {
|
|
46
|
+
cy.window()
|
|
47
|
+
.then($el => {
|
|
48
|
+
const metaTag = document.createElement("meta");
|
|
49
|
+
metaTag.name = "sap-allowed-theme-origins";
|
|
50
|
+
metaTag.content = "https://runtime-example.com";
|
|
51
|
+
$el.document.head.append(metaTag);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
after(() => {
|
|
56
|
+
cy.window()
|
|
57
|
+
.then($el => {
|
|
58
|
+
const metaTag = $el.document.head.querySelector("[name='sap-allowed-theme-origins']");
|
|
59
|
+
metaTag?.remove();
|
|
60
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
61
|
+
link?.remove();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should set raw themeRoot", () => {
|
|
66
|
+
cy.wrap({ setThemeRoot })
|
|
67
|
+
.invoke("setThemeRoot", "https://runtime-example.com/themes");
|
|
68
|
+
|
|
69
|
+
cy.wrap({ getThemeRoot })
|
|
70
|
+
.invoke("getThemeRoot")
|
|
71
|
+
.should("equal", "https://runtime-example.com/themes");
|
|
72
|
+
|
|
73
|
+
// Verify link is created in DOM
|
|
74
|
+
cy.wrap({ getTheme })
|
|
75
|
+
.invoke("getTheme")
|
|
76
|
+
.then(theme => {
|
|
77
|
+
cy.get(`link[sap-ui-webcomponents-theme="${theme}"]`)
|
|
78
|
+
.should("exist")
|
|
79
|
+
.and("have.attr", "href")
|
|
80
|
+
.then(href => {
|
|
81
|
+
return href.includes("https://runtime-example.com/themes/UI5/Base/baseLib/");
|
|
82
|
+
})
|
|
83
|
+
.should("be.true");
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe("Invalid themeRoot without meta tag", () => {
|
|
89
|
+
after(() => {
|
|
90
|
+
cy.window()
|
|
91
|
+
.then($el => {
|
|
92
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
93
|
+
link?.remove();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("should set themeRoot but log warning", () => {
|
|
98
|
+
const consoleWarnStub = cy.stub().as("consoleWarn");
|
|
99
|
+
|
|
100
|
+
cy.window().then(win => {
|
|
101
|
+
cy.stub(win.console, "warn").callsFake(consoleWarnStub);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
cy.wrap({ setThemeRoot })
|
|
105
|
+
.invoke("setThemeRoot", "https://unauthorized-runtime.com/themes");
|
|
106
|
+
|
|
107
|
+
// The themeRoot should be set in the internal state
|
|
108
|
+
cy.wrap({ getThemeRoot })
|
|
109
|
+
.invoke("getThemeRoot")
|
|
110
|
+
.should("equal", "https://unauthorized-runtime.com/themes");
|
|
111
|
+
|
|
112
|
+
// But validation should fail and log a warning
|
|
113
|
+
cy.get("@consoleWarn").should("have.been.called");
|
|
114
|
+
|
|
115
|
+
// Verify link is NOT created in DOM
|
|
116
|
+
cy.get("link[sap-ui-webcomponents-theme]")
|
|
117
|
+
.should("not.exist");
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe("Relative themeRoot at runtime", () => {
|
|
122
|
+
before(() => {
|
|
123
|
+
cy.window()
|
|
124
|
+
.then($el => {
|
|
125
|
+
const metaTag = document.createElement("meta");
|
|
126
|
+
metaTag.name = "sap-allowed-theme-origins";
|
|
127
|
+
metaTag.content = "*";
|
|
128
|
+
$el.document.head.append(metaTag);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
after(() => {
|
|
133
|
+
cy.window()
|
|
134
|
+
.then($el => {
|
|
135
|
+
const metaTag = $el.document.head.querySelector("[name='sap-allowed-theme-origins']");
|
|
136
|
+
metaTag?.remove();
|
|
137
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
138
|
+
link?.remove();
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("should set raw relative path", () => {
|
|
143
|
+
cy.wrap({ setThemeRoot })
|
|
144
|
+
.invoke("setThemeRoot", "./custom-themes");
|
|
145
|
+
|
|
146
|
+
cy.wrap({ getThemeRoot })
|
|
147
|
+
.invoke("getThemeRoot")
|
|
148
|
+
.should("equal", "./custom-themes");
|
|
149
|
+
|
|
150
|
+
// Verify link is created with resolved URL
|
|
151
|
+
cy.wrap({ getTheme })
|
|
152
|
+
.invoke("getTheme")
|
|
153
|
+
.then(theme => {
|
|
154
|
+
cy.get(`link[sap-ui-webcomponents-theme="${theme}"]`)
|
|
155
|
+
.should("exist")
|
|
156
|
+
.and("have.attr", "href")
|
|
157
|
+
.then(href => {
|
|
158
|
+
return href.includes("/custom-themes/UI5/Base/baseLib/");
|
|
159
|
+
})
|
|
160
|
+
.should("be.true");
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
describe("Same themeRoot not re-applied", () => {
|
|
166
|
+
before(() => {
|
|
167
|
+
cy.window()
|
|
168
|
+
.then($el => {
|
|
169
|
+
const metaTag = document.createElement("meta");
|
|
170
|
+
metaTag.name = "sap-allowed-theme-origins";
|
|
171
|
+
metaTag.content = "https://same-root.com";
|
|
172
|
+
$el.document.head.append(metaTag);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
after(() => {
|
|
177
|
+
cy.window()
|
|
178
|
+
.then($el => {
|
|
179
|
+
const metaTag = $el.document.head.querySelector("[name='sap-allowed-theme-origins']");
|
|
180
|
+
metaTag?.remove();
|
|
181
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
182
|
+
link?.remove();
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("should not reprocess when setting the same themeRoot", () => {
|
|
187
|
+
const themeRoot = "https://same-root.com/themes";
|
|
188
|
+
|
|
189
|
+
cy.wrap({ setThemeRoot })
|
|
190
|
+
.invoke("setThemeRoot", themeRoot)
|
|
191
|
+
.should("not.equal", undefined);
|
|
192
|
+
|
|
193
|
+
// Setting again should return undefined (no-op)
|
|
194
|
+
cy.wrap({ setThemeRoot })
|
|
195
|
+
.invoke("setThemeRoot", themeRoot)
|
|
196
|
+
.should("equal", undefined);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe("ThemeRoot with wildcard origin", () => {
|
|
201
|
+
before(() => {
|
|
202
|
+
cy.window()
|
|
203
|
+
.then($el => {
|
|
204
|
+
const metaTag = document.createElement("meta");
|
|
205
|
+
metaTag.name = "sap-allowed-theme-origins";
|
|
206
|
+
metaTag.content = "*";
|
|
207
|
+
$el.document.head.append(metaTag);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
after(() => {
|
|
212
|
+
cy.window()
|
|
213
|
+
.then($el => {
|
|
214
|
+
const metaTag = $el.document.head.querySelector("[name='sap-allowed-theme-origins']");
|
|
215
|
+
metaTag?.remove();
|
|
216
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
217
|
+
link?.remove();
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it("should allow any origin with wildcard", () => {
|
|
222
|
+
cy.wrap({ setThemeRoot })
|
|
223
|
+
.invoke("setThemeRoot", "https://any-wildcard-domain.com/themes");
|
|
224
|
+
|
|
225
|
+
cy.wrap({ getThemeRoot })
|
|
226
|
+
.invoke("getThemeRoot")
|
|
227
|
+
.should("equal", "https://any-wildcard-domain.com/themes");
|
|
228
|
+
|
|
229
|
+
// Verify link is created with wildcard-allowed origin
|
|
230
|
+
cy.wrap({ getTheme })
|
|
231
|
+
.invoke("getTheme")
|
|
232
|
+
.then(theme => {
|
|
233
|
+
cy.get(`link[sap-ui-webcomponents-theme="${theme}"]`)
|
|
234
|
+
.should("exist")
|
|
235
|
+
.and("have.attr", "href")
|
|
236
|
+
.and("include", "https://any-wildcard-domain.com/themes/UI5/Base/baseLib/");
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
});
|
|
@@ -6,8 +6,10 @@ import { getFirstDayOfWeek, getLegacyDateCalendarCustomizing } from "../../src/c
|
|
|
6
6
|
import { getLanguage } from "../../src/config/Language.js";
|
|
7
7
|
import { getNoConflict } from "../../src/config/NoConflict.js";
|
|
8
8
|
import { getTheme } from "../../src/config/Theme.js";
|
|
9
|
+
import { getThemeRoot } from "../../src/config/ThemeRoot.js";
|
|
9
10
|
import { getEnableDefaultTooltips } from "../../src/config/Tooltips.js";
|
|
10
11
|
import { resetConfiguration } from "../../src/InitialConfiguration.js";
|
|
12
|
+
import applyTheme from "../../src/theming/applyTheme.js";
|
|
11
13
|
|
|
12
14
|
describe("Configuration script", () => {
|
|
13
15
|
const configurationObject = {
|
|
@@ -131,3 +133,396 @@ describe("Configuration script", () => {
|
|
|
131
133
|
.should("equal", false);
|
|
132
134
|
});
|
|
133
135
|
});
|
|
136
|
+
|
|
137
|
+
describe("Configuration script with themeRoot", () => {
|
|
138
|
+
describe("Valid absolute themeRoot with allowed origin", () => {
|
|
139
|
+
before(() => {
|
|
140
|
+
// Add meta tag to allow the origin
|
|
141
|
+
cy.window()
|
|
142
|
+
.then($el => {
|
|
143
|
+
const metaTag = document.createElement("meta");
|
|
144
|
+
metaTag.name = "sap-allowed-theme-origins";
|
|
145
|
+
metaTag.content = "https://example.com";
|
|
146
|
+
$el.document.head.append(metaTag);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
cy.window()
|
|
150
|
+
.then($el => {
|
|
151
|
+
const scriptElement = document.createElement("script");
|
|
152
|
+
scriptElement.type = "application/json";
|
|
153
|
+
scriptElement.setAttribute("data-ui5-config", "true");
|
|
154
|
+
scriptElement.innerHTML = JSON.stringify({
|
|
155
|
+
theme: "custom_theme",
|
|
156
|
+
themeRoot: "https://example.com/themes",
|
|
157
|
+
});
|
|
158
|
+
return $el.document.head.append(scriptElement);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
cy.wrap({ resetConfiguration })
|
|
162
|
+
.invoke("resetConfiguration", true);
|
|
163
|
+
|
|
164
|
+
cy.mount(<TestGeneric />);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
afterEach(() => {
|
|
168
|
+
cy.window()
|
|
169
|
+
.then($el => {
|
|
170
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
171
|
+
link?.remove();
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
after(() => {
|
|
176
|
+
cy.window()
|
|
177
|
+
.then($el => {
|
|
178
|
+
const scriptElement = $el.document.head.querySelector("script[data-ui5-config]");
|
|
179
|
+
scriptElement?.remove();
|
|
180
|
+
const metaTag = $el.document.head.querySelector("[name='sap-allowed-theme-origins']");
|
|
181
|
+
metaTag?.remove();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it("should return raw themeRoot from configuration", () => {
|
|
186
|
+
cy.wrap({ getThemeRoot })
|
|
187
|
+
.invoke("getThemeRoot")
|
|
188
|
+
.should("equal", "https://example.com/themes");
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("should create link in DOM with validated URL", () => {
|
|
192
|
+
// Apply theme to trigger link creation
|
|
193
|
+
cy.wrap({ applyTheme, getTheme })
|
|
194
|
+
.invoke("getTheme")
|
|
195
|
+
.then(theme => {
|
|
196
|
+
return cy.wrap({ applyTheme }).invoke("applyTheme", theme);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
cy.get("link[sap-ui-webcomponents-theme='custom_theme']")
|
|
200
|
+
.should("exist")
|
|
201
|
+
.and("have.attr", "href")
|
|
202
|
+
.and("equal", "https://example.com/themes/UI5/Base/baseLib/custom_theme/css_variables.css");
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe("Invalid absolute themeRoot without allowed origin", () => {
|
|
207
|
+
before(() => {
|
|
208
|
+
cy.window()
|
|
209
|
+
.then($el => {
|
|
210
|
+
const scriptElement = document.createElement("script");
|
|
211
|
+
scriptElement.type = "application/json";
|
|
212
|
+
scriptElement.setAttribute("data-ui5-config", "true");
|
|
213
|
+
scriptElement.innerHTML = JSON.stringify({
|
|
214
|
+
theme: "custom_theme",
|
|
215
|
+
themeRoot: "https://unauthorized.com/themes",
|
|
216
|
+
});
|
|
217
|
+
return $el.document.head.append(scriptElement);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
cy.wrap({ resetConfiguration })
|
|
221
|
+
.invoke("resetConfiguration", true);
|
|
222
|
+
|
|
223
|
+
cy.mount(<TestGeneric />);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
afterEach(() => {
|
|
227
|
+
cy.window()
|
|
228
|
+
.then($el => {
|
|
229
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
230
|
+
link?.remove();
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
after(() => {
|
|
235
|
+
cy.window()
|
|
236
|
+
.then($el => {
|
|
237
|
+
const scriptElement = $el.document.head.querySelector("script[data-ui5-config]");
|
|
238
|
+
scriptElement?.remove();
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it("should return raw themeRoot from configuration", () => {
|
|
243
|
+
cy.wrap({ getThemeRoot })
|
|
244
|
+
.invoke("getThemeRoot")
|
|
245
|
+
.should("equal", "https://unauthorized.com/themes");
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("should not create link in DOM due to validation failure", () => {
|
|
249
|
+
cy.get("link[sap-ui-webcomponents-theme='custom_theme']")
|
|
250
|
+
.should("not.exist");
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
describe("Relative themeRoot with meta tag", () => {
|
|
255
|
+
before(() => {
|
|
256
|
+
// Relative URLs require meta tag to be present
|
|
257
|
+
cy.window()
|
|
258
|
+
.then($el => {
|
|
259
|
+
const metaTag = document.createElement("meta");
|
|
260
|
+
metaTag.name = "sap-allowed-theme-origins";
|
|
261
|
+
metaTag.content = "*";
|
|
262
|
+
$el.document.head.append(metaTag);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
cy.window()
|
|
266
|
+
.then($el => {
|
|
267
|
+
const scriptElement = document.createElement("script");
|
|
268
|
+
scriptElement.type = "application/json";
|
|
269
|
+
scriptElement.setAttribute("data-ui5-config", "true");
|
|
270
|
+
scriptElement.innerHTML = JSON.stringify({
|
|
271
|
+
theme: "custom_theme",
|
|
272
|
+
themeRoot: "./themes",
|
|
273
|
+
});
|
|
274
|
+
return $el.document.head.append(scriptElement);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
cy.wrap({ resetConfiguration })
|
|
278
|
+
.invoke("resetConfiguration", true);
|
|
279
|
+
|
|
280
|
+
cy.mount(<TestGeneric />);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
afterEach(() => {
|
|
284
|
+
cy.window()
|
|
285
|
+
.then($el => {
|
|
286
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
287
|
+
link?.remove();
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
after(() => {
|
|
292
|
+
cy.window()
|
|
293
|
+
.then($el => {
|
|
294
|
+
const scriptElement = $el.document.head.querySelector("script[data-ui5-config]");
|
|
295
|
+
scriptElement?.remove();
|
|
296
|
+
const metaTag = $el.document.head.querySelector("[name='sap-allowed-theme-origins']");
|
|
297
|
+
metaTag?.remove();
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it("should return raw relative themeRoot", () => {
|
|
302
|
+
cy.wrap({ getThemeRoot })
|
|
303
|
+
.invoke("getThemeRoot")
|
|
304
|
+
.should("equal", "./themes");
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it("should create link with resolved URL", () => {
|
|
308
|
+
// Apply theme to trigger link creation
|
|
309
|
+
cy.wrap({ applyTheme, getTheme })
|
|
310
|
+
.invoke("getTheme")
|
|
311
|
+
.then(theme => {
|
|
312
|
+
return cy.wrap({ applyTheme }).invoke("applyTheme", theme);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
cy.get("link[sap-ui-webcomponents-theme='custom_theme']")
|
|
316
|
+
.should("exist")
|
|
317
|
+
.and("have.attr", "href")
|
|
318
|
+
.then(href => {
|
|
319
|
+
return href.includes("/themes/UI5/Base/baseLib/custom_theme/css_variables.css");
|
|
320
|
+
})
|
|
321
|
+
.should("be.true");
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
describe("Wildcard allowed origins", () => {
|
|
326
|
+
before(() => {
|
|
327
|
+
cy.window()
|
|
328
|
+
.then($el => {
|
|
329
|
+
const metaTag = document.createElement("meta");
|
|
330
|
+
metaTag.name = "sap-allowed-theme-origins";
|
|
331
|
+
metaTag.content = "*";
|
|
332
|
+
$el.document.head.append(metaTag);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
cy.window()
|
|
336
|
+
.then($el => {
|
|
337
|
+
const scriptElement = document.createElement("script");
|
|
338
|
+
scriptElement.type = "application/json";
|
|
339
|
+
scriptElement.setAttribute("data-ui5-config", "true");
|
|
340
|
+
scriptElement.innerHTML = JSON.stringify({
|
|
341
|
+
theme: "custom_theme",
|
|
342
|
+
themeRoot: "https://any-domain.com/themes",
|
|
343
|
+
});
|
|
344
|
+
return $el.document.head.append(scriptElement);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
cy.wrap({ resetConfiguration })
|
|
348
|
+
.invoke("resetConfiguration", true);
|
|
349
|
+
|
|
350
|
+
cy.mount(<TestGeneric />);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
afterEach(() => {
|
|
354
|
+
cy.window()
|
|
355
|
+
.then($el => {
|
|
356
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
357
|
+
link?.remove();
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
after(() => {
|
|
362
|
+
cy.window()
|
|
363
|
+
.then($el => {
|
|
364
|
+
const scriptElement = $el.document.head.querySelector("script[data-ui5-config]");
|
|
365
|
+
scriptElement?.remove();
|
|
366
|
+
const metaTag = $el.document.head.querySelector("[name='sap-allowed-theme-origins']");
|
|
367
|
+
metaTag?.remove();
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it("should return raw themeRoot", () => {
|
|
372
|
+
cy.wrap({ getThemeRoot })
|
|
373
|
+
.invoke("getThemeRoot")
|
|
374
|
+
.should("equal", "https://any-domain.com/themes");
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
it("should create link with wildcard-allowed origin", () => {
|
|
378
|
+
// Apply theme to trigger link creation
|
|
379
|
+
cy.wrap({ applyTheme, getTheme })
|
|
380
|
+
.invoke("getTheme")
|
|
381
|
+
.then(theme => {
|
|
382
|
+
return cy.wrap({ applyTheme }).invoke("applyTheme", theme);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
cy.get("link[sap-ui-webcomponents-theme='custom_theme']")
|
|
386
|
+
.should("exist")
|
|
387
|
+
.and("have.attr", "href")
|
|
388
|
+
.and("equal", "https://any-domain.com/themes/UI5/Base/baseLib/custom_theme/css_variables.css");
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
describe("Multiple allowed origins", () => {
|
|
393
|
+
before(() => {
|
|
394
|
+
cy.window()
|
|
395
|
+
.then($el => {
|
|
396
|
+
const metaTag = document.createElement("meta");
|
|
397
|
+
metaTag.name = "sap-allowed-theme-origins";
|
|
398
|
+
metaTag.content = "https://example.com, https://cdn.example.net, https://themes.example.org";
|
|
399
|
+
$el.document.head.append(metaTag);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
cy.window()
|
|
403
|
+
.then($el => {
|
|
404
|
+
const scriptElement = document.createElement("script");
|
|
405
|
+
scriptElement.type = "application/json";
|
|
406
|
+
scriptElement.setAttribute("data-ui5-config", "true");
|
|
407
|
+
scriptElement.innerHTML = JSON.stringify({
|
|
408
|
+
theme: "custom_theme",
|
|
409
|
+
themeRoot: "https://cdn.example.net/ui5-themes",
|
|
410
|
+
});
|
|
411
|
+
return $el.document.head.append(scriptElement);
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
cy.wrap({ resetConfiguration })
|
|
415
|
+
.invoke("resetConfiguration", true);
|
|
416
|
+
|
|
417
|
+
cy.mount(<TestGeneric />);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
afterEach(() => {
|
|
421
|
+
cy.window()
|
|
422
|
+
.then($el => {
|
|
423
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
424
|
+
link?.remove();
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
after(() => {
|
|
429
|
+
cy.window()
|
|
430
|
+
.then($el => {
|
|
431
|
+
const scriptElement = $el.document.head.querySelector("script[data-ui5-config]");
|
|
432
|
+
scriptElement?.remove();
|
|
433
|
+
const metaTag = $el.document.head.querySelector("[name='sap-allowed-theme-origins']");
|
|
434
|
+
metaTag?.remove();
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it("should return raw themeRoot", () => {
|
|
439
|
+
cy.wrap({ getThemeRoot })
|
|
440
|
+
.invoke("getThemeRoot")
|
|
441
|
+
.should("equal", "https://cdn.example.net/ui5-themes");
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
it("should create link matching one of multiple origins", () => {
|
|
445
|
+
// Apply theme to trigger link creation
|
|
446
|
+
cy.wrap({ applyTheme, getTheme })
|
|
447
|
+
.invoke("getTheme")
|
|
448
|
+
.then(theme => {
|
|
449
|
+
return cy.wrap({ applyTheme }).invoke("applyTheme", theme);
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
cy.get("link[sap-ui-webcomponents-theme='custom_theme']")
|
|
453
|
+
.should("exist")
|
|
454
|
+
.and("have.attr", "href")
|
|
455
|
+
.and("equal", "https://cdn.example.net/ui5-themes/UI5/Base/baseLib/custom_theme/css_variables.css");
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
describe("Same-origin absolute URL", () => {
|
|
460
|
+
before(() => {
|
|
461
|
+
cy.window()
|
|
462
|
+
.then($el => {
|
|
463
|
+
const metaTag = document.createElement("meta");
|
|
464
|
+
metaTag.name = "sap-allowed-theme-origins";
|
|
465
|
+
metaTag.content = "https://example.com";
|
|
466
|
+
$el.document.head.append(metaTag);
|
|
467
|
+
|
|
468
|
+
const currentOrigin = window.location.origin;
|
|
469
|
+
const scriptElement = document.createElement("script");
|
|
470
|
+
scriptElement.type = "application/json";
|
|
471
|
+
scriptElement.setAttribute("data-ui5-config", "true");
|
|
472
|
+
scriptElement.innerHTML = JSON.stringify({
|
|
473
|
+
theme: "custom_theme",
|
|
474
|
+
themeRoot: `${currentOrigin}/themes`,
|
|
475
|
+
});
|
|
476
|
+
return $el.document.head.append(scriptElement);
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
cy.wrap({ resetConfiguration })
|
|
480
|
+
.invoke("resetConfiguration", true);
|
|
481
|
+
|
|
482
|
+
cy.mount(<TestGeneric />);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
afterEach(() => {
|
|
486
|
+
cy.window()
|
|
487
|
+
.then($el => {
|
|
488
|
+
const link = $el.document.head.querySelector("link[sap-ui-webcomponents-theme]");
|
|
489
|
+
link?.remove();
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
after(() => {
|
|
494
|
+
cy.window()
|
|
495
|
+
.then($el => {
|
|
496
|
+
const scriptElement = $el.document.head.querySelector("script[data-ui5-config]");
|
|
497
|
+
scriptElement?.remove();
|
|
498
|
+
const metaTag = $el.document.head.querySelector("[name='sap-allowed-theme-origins']");
|
|
499
|
+
metaTag?.remove();
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
it("should return raw same-origin themeRoot", () => {
|
|
504
|
+
cy.window().then(win => {
|
|
505
|
+
cy.wrap({ getThemeRoot })
|
|
506
|
+
.invoke("getThemeRoot")
|
|
507
|
+
.should("equal", `${win.location.origin}/themes`);
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it("should create link for same-origin URL", () => {
|
|
512
|
+
// Apply theme to trigger link creation
|
|
513
|
+
cy.wrap({ applyTheme, getTheme })
|
|
514
|
+
.invoke("getTheme")
|
|
515
|
+
.then(theme => {
|
|
516
|
+
return cy.wrap({ applyTheme }).invoke("applyTheme", theme);
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
cy.get("link[sap-ui-webcomponents-theme='custom_theme']")
|
|
520
|
+
.should("exist")
|
|
521
|
+
.and("have.attr", "href")
|
|
522
|
+
.then(href => {
|
|
523
|
+
return href.endsWith("/themes/UI5/Base/baseLib/custom_theme/css_variables.css");
|
|
524
|
+
})
|
|
525
|
+
.should("be.true");
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
});
|