Skip to content

Commit ada6442

Browse files
Simon-LauxWofWca
authored andcommitted
split link card into multiple cards for the different tabs
1 parent cd58c10 commit ada6442

File tree

4 files changed

+72
-42
lines changed

4 files changed

+72
-42
lines changed

index.html

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
</div>
4545
</div>
4646

47-
<div class="card" id="links-output"></div>
48-
<script src="js/links.js"></script>
47+
<div class="card" id="webxdc-notify-output"></div>
48+
<script src="js/webxdc-notify.js"></script>
4949

5050
<div class="card" id="info-output"></div>
5151
<script src="js/info.js"></script>
@@ -63,6 +63,9 @@
6363

6464
<div class="card" id="wasm-output"></div>
6565
<script src="js/wasm.js"></script>
66+
67+
<div class="card" id="links-output"></div>
68+
<script src="js/links.js"></script>
6669
</div>
6770
<div class="page" id="page-sandbox">
6871
<div class="card" id="cookies-output"></div>
@@ -77,18 +80,26 @@
7780
style="display: none"
7881
></iframe>
7982
<div class="card" id="webrtc-output"></div>
80-
<script src="js/webrtc.js"></script>
81-
<iframe
82-
src="./iframe-webrtc-test.html"
83-
sandbox="allow-scripts"
84-
width="100%"
85-
height="200"
86-
></iframe>
83+
<div class="card">
84+
<header class="container">
85+
<h2>webrtc-sidechannel iframe</h2>
86+
</header>
87+
<script src="js/webrtc.js"></script>
88+
<iframe
89+
src="./iframe-webrtc-test.html"
90+
sandbox="allow-scripts"
91+
width="100%"
92+
height="200"
93+
></iframe>
94+
</div>
95+
96+
<div class="card" id="iframe-output"></div>
97+
<script src="js/iframe.js"></script>
8798

8899
<!-- DNS prefetch check, originally developed by Cure53
89100
and distributed as "Cure53 Test App - DNS checker" app.
90101
See https://delta.chat/en/2023-05-22-webxdc-security#dns-prefetching-marks-another-exploit. -->
91-
<div class="dns-prefetch-output">
102+
<div class="card dns-prefetch-output">
92103
<header class="container">
93104
<h2>DNS Prefetch</h2>
94105
</header>
@@ -167,15 +178,15 @@ <h2>DNS Prefetch</h2>
167178
tab: document.getElementById("tab-sandbox"),
168179
},
169180
];
170-
for (const {page, tab} of tabs) {
181+
for (const { page, tab } of tabs) {
171182
tab.onclick = () => {
172-
tabs.forEach(({page, tab}) => {
173-
page.classList.remove("active")
174-
tab.classList.remove("active")
175-
});
176-
page.classList.add("active")
177-
tab.classList.add("active")
178-
}
183+
tabs.forEach(({ page, tab }) => {
184+
page.classList.remove("active");
185+
tab.classList.remove("active");
186+
});
187+
page.classList.add("active");
188+
tab.classList.add("active");
189+
};
179190
}
180191
</script>
181192
</body>

js/iframe.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
window.addEventListener("load", () => {
2+
const ifrmExplain = h(
3+
"p",
4+
{},
5+
"iframe: should be blocked and not load https://delta.chat from Internet:"
6+
);
7+
const ifrm = h("iframe", { src: "https://delta.chat" });
8+
ifrm.style.width = "100%";
9+
ifrm.style.height = "auto";
10+
11+
document
12+
.getElementById("iframe-output")
13+
.append(
14+
createHeader("Loading website in iframe"),
15+
h("div", { class: "container" }, ifrmExplain, ifrm)
16+
);
17+
});

js/links.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,7 @@ window.addEventListener("load", () => {
99
h("li", {}, h("a", {href: "chrome://crash"}, "chrome://crash")),
1010
);
1111

12-
let btn1 = h("button", {}, "info with deep-link to internal page, no notify");
13-
btn1.onclick = () => {
14-
window.webxdc.sendUpdate({ payload: "", info: "open page.html", href: "page.html" }, "");
15-
};
16-
ul.append(h("li", {}, btn1));
17-
18-
let btn2 = h("button", {}, "info and notify all with deep-link to internal page");
19-
btn2.onclick = () => {
20-
window.webxdc.sendUpdate({ payload: "", info: "open page.html", href: "page.html", notify: {"*": "notify page.html"} }, "");
21-
};
22-
ul.append(h("li", {}, btn2));
23-
24-
let btn3 = h("button", {}, "info and notify all with deep-link to #links-output section");
25-
btn3.onclick = () => {
26-
window.webxdc.sendUpdate({ payload: "", info: "open #links-output", href: "index.html#links-output", notify: {"*": "notify #links-output"} }, "");
27-
};
28-
ul.append(h("li", {}, btn3));
29-
30-
const ifrmExplain = h("p", {}, "iframe: should be blocked and not load https://delta.chat from Internet:");
31-
const ifrm = h("iframe", {src: "https://delta.chat"});
32-
ifrm.style.width = "100%";
33-
ifrm.style.height = "auto";
34-
3512
document.getElementById("links-output").append(
36-
createHeader("Links"), h("div", {class: "container"}, ul, ifrmExplain, ifrm)
13+
createHeader("Links"), h("div", {class: "container"}, ul)
3714
);
3815
});

js/webxdc-notify.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
window.addEventListener("load", () => {
2+
let ul = h("ul");
3+
4+
let btn1 = h("button", {}, "info with deep-link to internal page, no notify");
5+
btn1.onclick = () => {
6+
window.webxdc.sendUpdate({ payload: "", info: "open page.html", href: "page.html" }, "");
7+
};
8+
ul.append(h("li", {}, btn1));
9+
10+
let btn2 = h("button", {}, "info and notify all with deep-link to internal page");
11+
btn2.onclick = () => {
12+
window.webxdc.sendUpdate({ payload: "", info: "open page.html", href: "page.html", notify: {"*": "notify page.html"} }, "");
13+
};
14+
ul.append(h("li", {}, btn2));
15+
16+
let btn3 = h("button", {}, "info and notify all with deep-link to #links-output section");
17+
btn3.onclick = () => {
18+
window.webxdc.sendUpdate({ payload: "", info: "open #links-output", href: "index.html#links-output", notify: {"*": "notify #links-output"} }, "");
19+
};
20+
ul.append(h("li", {}, btn3));
21+
22+
document.getElementById("webxdc-notify-output").append(
23+
createHeader("Webxdc Notify"), h("div", {class: "container"}, ul)
24+
);
25+
});

0 commit comments

Comments
 (0)