Skip to content

Commit

Permalink
tests: Checks that iframe correctly fires its onload event
Browse files Browse the repository at this point in the history
  • Loading branch information
Toad06 authored and Herschel committed Dec 10, 2020
1 parent 07d3e7d commit 83fcd7b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test_ok
18 changes: 18 additions & 0 deletions web/packages/selfhosted/test/polyfill/iframes_onload/index.html
Original file line number Diff line number Diff line change
@@ -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>
11 changes: 11 additions & 0 deletions web/packages/selfhosted/test/polyfill/iframes_onload/inner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>iframe onload</title>
</head>

<body>
Hello World!
</body>
</html>
21 changes: 21 additions & 0 deletions web/packages/selfhosted/test/polyfill/iframes_onload/test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});

0 comments on commit 83fcd7b

Please sign in to comment.