tests: Checks that iframe correctly fires its onload event

This commit is contained in:
Toad06 2020-12-08 00:42:42 +01:00 committed by Mike Welsh
parent 07d3e7d81b
commit 83fcd7ba40
4 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1 @@
test_ok

View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>iframe onload</title>
</head>
<body>
<script>
function setBody(elm) {
document.body.innerHTML = '<div id="container">' + elm.id + '</div>';
}
window.setTimeout(() => {
document.body.innerHTML = '<iframe id="test_ok" src="inner.html" onload="setBody(this);"></iframe>';
}, 500);
</script>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>iframe onload</title>
</head>
<body>
Hello World!
</body>
</html>

View File

@ -0,0 +1,21 @@
const { open_test, inject_ruffle_and_wait } = require("../utils");
const { expect, use } = require("chai");
const chaiHtml = require("chai-html");
const fs = require("fs");
use(chaiHtml);
describe("iframe onload", () => {
it("loads the test", () => {
open_test(browser, __dirname);
});
it("runs the iframe onload event", () => {
inject_ruffle_and_wait(browser);
browser.$("<div />").waitForExist();
const actual = browser.$("#container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
});