Skip to content

Commit 4c48618

Browse files
committed
chore: add test pages
1 parent 76f5073 commit 4c48618

3 files changed

Lines changed: 168 additions & 0 deletions

File tree

packages/base/bundle.esm.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import applyDirection from "./dist/locale/applyDirection.js";
3131
import { getCurrentRuntimeIndex } from "./dist/Runtimes.js";
3232
import { startMultipleDrag } from "./dist/DragAndDrop.js";
3333
import LegacyDateFormats from "./dist/features/LegacyDateFormats.js";
34+
import { boot } from "./dist/Boot.js";
3435

3536
window["sap-ui-webcomponents-bundle"] = {
3637
configuration : {
@@ -54,6 +55,7 @@ window["sap-ui-webcomponents-bundle"] = {
5455
parseProperties,
5556
registerI18nLoader,
5657
getI18nBundle,
58+
boot,
5759
renderFinished,
5860
applyDirection,
5961
EventProvider,
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Base package default test page</title>
7+
8+
<script src="../../bundle.esm.js" type="module"></script>
9+
10+
</head>
11+
12+
<body>
13+
<h1>Without meta tag</h1>
14+
<ul>
15+
<li><a
16+
href="?sap-ui-theme=sap_horizon@http://example2.com/themes/">?sap-ui-theme=sap_horizon@http://example2.com/themes/</a>
17+
<br /> http://example2.com/ — no meta tag present, blocked
18+
</li>
19+
<li><a
20+
href="?sap-ui-theme=sap_horizon@https://example.com/themes/">?sap-ui-theme=sap_horizon@https://example.com/themes/</a>
21+
<br /> https://example.com/ — no meta tag present, blocked
22+
</li>
23+
<li><a
24+
href="?sap-ui-theme=sap_horizon@http://example:9090.com/themes/">?sap-ui-theme=sap_horizon@http://example:9090.com/themes/</a>
25+
<br /> http://example:9090.com/ — no meta tag present, blocked
26+
</li>
27+
<li><a
28+
href="?sap-ui-theme=sap_horizon@http://example.com/themes/">?sap-ui-theme=sap_horizon@http://example.com/themes/</a>
29+
<br /> http://example.com/ — no meta tag present, blocked
30+
</li>
31+
<li><a
32+
href="?sap-ui-theme=sap_horizon@//example2.com/themes/">?sap-ui-theme=sap_horizon@//example2.com/themes/</a>
33+
<br /> //example2.com/ — inherits current page protocol (e.g. http://example2.com/) — no meta tag present, blocked
34+
</li>
35+
<li><a
36+
href="?sap-ui-theme=sap_horizon@//example:9090.com/themes/">?sap-ui-theme=sap_horizon@//example:9090.com/themes/</a>
37+
<br /> //example:9090.com/ — inherits current page protocol (e.g. http://example:9090.com/) — no meta tag present, blocked
38+
</li>
39+
<li><a
40+
href="?sap-ui-theme=sap_horizon@//example.com/themes/">?sap-ui-theme=sap_horizon@//example.com/themes/</a>
41+
<br /> //example.com/ — inherits current page protocol (e.g. http://example.com/) — no meta tag present, blocked
42+
</li>
43+
<li><a href="?sap-ui-theme=sap_horizon@/themes/">?sap-ui-theme=sap_horizon@/themes/</a><br /> /themes/
44+
<br /> (resolves to the current page's origin, e.g. http://localhost:8080/themes/) <br /> Same-origin — expected link element
45+
</li>
46+
<li><a href="?sap-ui-theme=sap_horizon@./themes/">?sap-ui-theme=sap_horizon@./themes/</a><br /> ./themes/
47+
<br /> (resolves relative to the current page's URL, e.g. http://localhost:8080/test/pages/themes/) <br /> Same-origin — expected link element
48+
</li>
49+
<li><a href="?sap-ui-theme=sap_horizon@../themes/">?sap-ui-theme=sap_horizon@../themes/</a><br /> ../themes/
50+
<br /> (resolves relative to the current page's URL, e.g. http://localhost:8080/test/themes/) <br /> Same-origin — expected link element
51+
</li>
52+
</ul>
53+
<script>
54+
setTimeout(async () => {
55+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("http://example2.com/themes/") // ❌ no meta tag present, blocked
56+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("https://example.com/themes/") // ❌ no meta tag present, blocked
57+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("http://example:9090.com/themes/") // ❌ no meta tag present, blocked
58+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("http://example.com/themes/") // ❌ no meta tag present, blocked
59+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("//example2.com/themes/") // ❌ inherits current page protocol (e.g. http://example2.com/) — no meta tag present, blocked
60+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("//example:9090.com/themes/") // ❌ inherits current page protocol (e.g. http://example:9090.com/) — no meta tag present, blocked
61+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("//example.com/themes/") // ❌ inherits current page protocol (e.g. http://example.com/) — no meta tag present, blocked
62+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("/themes") // ✅ resolves to current page's origin — same-origin, no meta tag present, blocked
63+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("./themes") // ✅ resolves relative to current page's URL — same-origin, no meta tag present, blocked
64+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("../themes") // ✅ resolves relative to current page's URL — same-origin, no meta tag present, blocked
65+
66+
if (window.location.search.includes("sap-ui-theme")) {
67+
await window["sap-ui-webcomponents-bundle"].boot();
68+
}
69+
70+
const links = document.head.querySelectorAll('link');
71+
72+
console.log(links)
73+
74+
if (links.length) {
75+
alert(`Link tag(s) exist: ${[...links].map((link) => link.href).join(', ')}`);
76+
}
77+
78+
}, 1000)
79+
</script>
80+
</body>
81+
82+
</html>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="sap-allowed-theme-origins" content="http://example.com" />
7+
<title>Base package default test page</title>
8+
9+
<script src="../../bundle.esm.js" type="module"></script>
10+
11+
</head>
12+
13+
<body>
14+
<h1>With meta tag</h1>
15+
<p>Following page is using the meta tag <code>sap-allowed-theme-origins</code> to specify allowed theme origins with <code>http://example.com</code> as the allowed origin.</p>
16+
<ul>
17+
<li><a
18+
href="?sap-ui-theme=sap_horizon@http://example2.com/themes/">?sap-ui-theme=sap_horizon@http://example2.com/themes/</a>
19+
<br /> http://example2.com/ vs http://example.com/ — different origin, blocked
20+
</li>
21+
<li><a
22+
href="?sap-ui-theme=sap_horizon@https://example.com/themes/">?sap-ui-theme=sap_horizon@https://example.com/themes/</a>
23+
<br /> https://example.com/ vs http://example.com/ — different protocol, blocked
24+
</li>
25+
<li><a
26+
href="?sap-ui-theme=sap_horizon@http://example:9090.com/themes/">?sap-ui-theme=sap_horizon@http://example:9090.com/themes/</a>
27+
<br /> http://example:9090.com/ vs http://example.com/ — different port, blocked
28+
</li>
29+
<li><a
30+
href="?sap-ui-theme=sap_horizon@http://example.com/themes/">?sap-ui-theme=sap_horizon@http://example.com/themes/</a>
31+
<br /> http://example.com/ vs http://example.com/ — matches allowed origin. <br /> Expected link element
32+
</li>
33+
<li><a
34+
href="?sap-ui-theme=sap_horizon@//example2.com/themes/">?sap-ui-theme=sap_horizon@//example2.com/themes/</a>
35+
<br /> //example2.com/ — inherits current page protocol (e.g. http://example2.com/) vs http://example.com/ — different origin, blocked
36+
</li>
37+
<li><a
38+
href="?sap-ui-theme=sap_horizon@//example:9090.com/themes/">?sap-ui-theme=sap_horizon@//example:9090.com/themes/</a>
39+
<br /> //example:9090.com/ — inherits current page protocol (e.g. http://example:9090.com/) vs http://example.com/ — different port, blocked
40+
</li>
41+
<li><a
42+
href="?sap-ui-theme=sap_horizon@//example.com/themes/">?sap-ui-theme=sap_horizon@//example.com/themes/</a>
43+
<br /> //example.com/ — inherits current page protocol (e.g. http://example.com/) vs http://example.com/ — matches allowed origin. <br /> Expected link element
44+
</li>
45+
<li><a href="?sap-ui-theme=sap_horizon@/themes/">?sap-ui-theme=sap_horizon@/themes/</a><br /> /themes/
46+
<br /> (resolves to the current page's origin, e.g. http://localhost:8080/themes/) <br /> Same-origin — expected link element
47+
</li>
48+
<li><a href="?sap-ui-theme=sap_horizon@./themes/">?sap-ui-theme=sap_horizon@./themes/</a><br /> ./themes/
49+
<br /> (resolves relative to the current page's URL, e.g. http://localhost:8080/test/pages/themes/) <br /> Same-origin — expected link element
50+
</li>
51+
<li><a href="?sap-ui-theme=sap_horizon@../themes/">?sap-ui-theme=sap_horizon@../themes/</a><br /> ../themes/
52+
<br /> (resolves relative to the current page's URL, e.g. http://localhost:8080/test/themes/) <br /> Same-origin — expected link element
53+
</li>
54+
</ul>
55+
<script>
56+
setTimeout(async () => {
57+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("http://example2.com/themes/") // ❌ different origin, blocked
58+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("https://example.com/themes/") // ❌ different protocol, blocked
59+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("http://example:9090.com/themes/") // ❌ different port, blocked
60+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("http://example.com/themes/") // ✅ matches allowed origin — expected link element
61+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("//example2.com/themes/") // ❌ inherits current page protocol (e.g. http://example2.com/) — different origin, blocked
62+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("//example:9090.com/themes/") // ❌ inherits current page protocol (e.g. http://example:9090.com/) — different port, blocked
63+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("//example.com/themes/") // ✅ inherits current page protocol (e.g. http://example.com/) — matches allowed origin — expected link element
64+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("/themes") // ✅ resolves to current page's origin — same-origin — expected link element
65+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("./themes") // ✅ resolves relative to current page's URL — same-origin — expected link element
66+
// await window["sap-ui-webcomponents-bundle"].configuration.setThemeRoot("../themes") // ✅ resolves relative to current page's URL — same-origin — expected link element
67+
68+
if (window.location.search.includes("sap-ui-theme")) {
69+
await window["sap-ui-webcomponents-bundle"].boot();
70+
}
71+
72+
const links = document.head.querySelectorAll('link');
73+
74+
console.log(links)
75+
76+
if (links.length) {
77+
alert(`Link tag(s) exist: ${[...links].map((link) => link.href).join(', ')}`);
78+
}
79+
80+
}, 1000)
81+
</script>
82+
</body>
83+
84+
</html>

0 commit comments

Comments
 (0)