32 lines
1.2 KiB
HTML
32 lines
1.2 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<script src="../include.js"></script>
|
||
|
|
<script>
|
||
|
|
asyncTest(async (done) => {
|
||
|
|
internals.setTestTimeout(5000);
|
||
|
|
|
||
|
|
const httpServer = httpTestServer();
|
||
|
|
const marker = "caf\u00e9";
|
||
|
|
const body = `<!DOCTYPE html><meta charset="UTF-8"><body>${"a".repeat(1500)}<span id="target">${marker}</span>`;
|
||
|
|
const targetIndex = body.indexOf("\u00e9");
|
||
|
|
const firstChunkSize = new TextEncoder().encode(body.substring(0, targetIndex)).length + 1;
|
||
|
|
const url = await httpServer.createEcho("GET", "/parser-streams-utf8-split", {
|
||
|
|
status: 200,
|
||
|
|
headers: {
|
||
|
|
"Content-Type": "text/html; charset=UTF-8",
|
||
|
|
},
|
||
|
|
body,
|
||
|
|
});
|
||
|
|
|
||
|
|
const frame = document.createElement("iframe");
|
||
|
|
frame.onload = () => {
|
||
|
|
const text = frame.contentDocument.getElementById("target").textContent;
|
||
|
|
println(`contains replacement: ${text.includes("\uFFFD")}`);
|
||
|
|
println(`length: ${text.length}`);
|
||
|
|
done();
|
||
|
|
};
|
||
|
|
|
||
|
|
frame.src = `${url}?chunks=${firstChunkSize}&chunk_delay_ms=100`;
|
||
|
|
document.body.appendChild(frame);
|
||
|
|
});
|
||
|
|
</script>
|