mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Unfortunately this is a bit of a pain to test as it is surprisingly difficult to create a non secure context in our test harness. This is because both file scheme URLs and localhost are considered secure contexts. To test this, add a very specific internals setter to change the top level origin of the environment for the current realm.
36 lines
1.1 KiB
HTML
36 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<script src="include.js"></script>
|
|
<script>
|
|
asyncTest(async (done) => {
|
|
const httpServer = httpTestServer();
|
|
const url = await httpServer.createEcho("GET", "/secure-context-idl", {
|
|
status: 200,
|
|
headers: {
|
|
"Access-Control-Allow-Origin": "*",
|
|
"Content-Type": "text/html",
|
|
},
|
|
body: `
|
|
<script>
|
|
// HTTP is not a secure context.
|
|
internals.setEnvironmentsTopLevelURL('http://ladybird.org');
|
|
|
|
parent.postMessage({
|
|
SubtleCrypto: !!crypto?.subtle,
|
|
Clipboard: typeof navigator.clipboard === "object",
|
|
CookieChangeEvent: typeof CookieChangeEvent === "function",
|
|
}, "*");
|
|
<\/script>`,
|
|
});
|
|
|
|
const frame = document.createElement('iframe');
|
|
frame.src = url;
|
|
|
|
addEventListener("message", (event) => {
|
|
println(JSON.stringify(event.data, null, 2));
|
|
done();
|
|
}, false);
|
|
|
|
document.body.appendChild(frame);
|
|
});
|
|
</script>
|