web: Split frame/iframe polyfill tests into provided vs injected, as we see issues with one or the other

This commit is contained in:
Nathan Adams 2020-05-23 20:21:46 +02:00 committed by Mike Welsh
parent 8a32f0d053
commit d846ed943b
19 changed files with 270 additions and 50 deletions

View File

@ -14,11 +14,6 @@
], ],
}; };
</script> </script>
<!--
Frame polyfilling depends on ruffle being loaded first,
so here we explicitly add it early and not after-load
-->
<script src="/dist/ruffle.js"></script>
</head> </head>
<frameset rows="10%,90%"> <frameset rows="10%,90%">

View File

@ -0,0 +1,44 @@
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);
// TODO: Injected is broken today
describe.skip("Flash inside frame with injected ruffle", () => {
it("loads the test", () => {
open_test(browser, __dirname);
});
it("polyfills inside a frame", () => {
inject_ruffle_and_wait(browser);
browser.switchToFrame(browser.$("#test-frame"));
browser.$("<ruffle-object />").waitForExist();
const actual = browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("polyfills even after a reload", () => {
// Contaminate the old contents, to ensure we get a "fresh" state
browser.execute(() => {
document.getElementById("test-container").remove();
});
// Then reload
browser.switchToParentFrame();
browser.switchToFrame(browser.$("#nav-frame"));
browser.$("#reload-link").click();
// And finally, check
browser.switchToParentFrame();
browser.switchToFrame(browser.$("#test-frame"));
browser.$("<ruffle-object />").waitForExist();
const actual = browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
});

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Nav</title>
</head>
<body>
<a href="frame2.html" target="content" id="reload-link">Reload frame</a>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>REAL CONTENT</title>
<style>
* {
margin: 0;
}
</style>
</head>
<body>
<div id="test-container">
<object
type="application/x-shockwave-flash"
data="/test_assets/example.swf"
width="550"
height="400"
>
<param name="movie" value="/test_assets/example.swf" />
<param name="quality" value="high" />
</object>
</div>
</body>
</html>

View File

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>WEB</title>
<script>
window.RufflePlayer = window.RufflePlayer || {};
window.RufflePlayer.config = {
polyfills: [
"static-content",
"plugin-detect",
"dynamic-content",
"frames",
],
};
</script>
<script src="/dist/ruffle.js" type="text/javascript"></script>
</head>
<frameset rows="10%,90%">
<frame
id="nav-frame"
name="nav"
src="frame1.html"
scrolling="no"
frameborder="0"
></frame>
<frame
id="test-frame"
name="content"
src="frame2.html"
scrolling="no"
frameborder="0"
></frame>
</frameset>
</html>

View File

@ -5,16 +5,14 @@ const fs = require("fs");
use(chaiHtml); use(chaiHtml);
describe("Flash inside frame", () => { describe("Flash inside frame with provided ruffle", () => {
it("loads the test", () => { it("loads the test", () => {
open_test(browser, __dirname); open_test(browser, __dirname);
}); });
it("polyfills inside a frame", () => { it("polyfills inside a frame", () => {
browser.switchToFrame(browser.$("#test-frame")); browser.switchToFrame(browser.$("#test-frame"));
browser.waitUntil(() => browser.$("<ruffle-object />").waitForExist();
browser.execute(() => document.readyState === "complete")
);
const actual = browser.$("#test-container").getHTML(false); const actual = browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8"); const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
@ -35,9 +33,7 @@ describe("Flash inside frame", () => {
// And finally, check // And finally, check
browser.switchToParentFrame(); browser.switchToParentFrame();
browser.switchToFrame(browser.$("#test-frame")); browser.switchToFrame(browser.$("#test-frame"));
browser.waitUntil(() => browser.$("<ruffle-object />").waitForExist();
browser.execute(() => document.readyState === "complete")
);
const actual = browser.$("#test-container").getHTML(false); const actual = browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8"); const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");

View File

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>REAL CONTENT</title>
<style>
* {
margin: 0;
}
</style>
</head>
<body>
<div id="test-container">
<object
type="application/x-shockwave-flash"
data="/test_assets/example.swf"
width="550"
height="400"
>
<param name="movie" value="/test_assets/example.swf" />
<param name="quality" value="high" />
</object>
</div>
</body>
</html>

View File

@ -0,0 +1,9 @@
<ruffle-object
type="application/x-shockwave-flash"
data="/test_assets/example.swf"
width="550"
height="400"
>
<param name="movie" value="/test_assets/example.swf" />
<param name="quality" value="high" />
</ruffle-object>

View File

@ -19,11 +19,6 @@
], ],
}; };
</script> </script>
<!--
Frame polyfilling depends on ruffle being loaded first,
so here we explicitly add it early and not after-load
-->
<script src="/dist/ruffle.js"></script>
</head> </head>
<body> <body>
<a href="inner.html" target="content" id="reload-link">Reload frame</a> <a href="inner.html" target="content" id="reload-link">Reload frame</a>

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>REAL CONTENT</title>
<style>
* {
margin: 0;
}
</style>
</head>
<body>
<div id="test-container">
<object
type="application/x-shockwave-flash"
data="/test_assets/example.swf"
width="550"
height="400"
>
<param name="movie" value="/test_assets/example.swf" />
<param name="quality" value="high" />
</object>
</div>
</body>
</html>

View File

@ -0,0 +1,43 @@
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);
// TODO: Injected is broken today
describe.skip("Flash inside iframe with injected ruffle", () => {
it("loads the test", () => {
open_test(browser, __dirname);
});
it("polyfills inside an iframe", () => {
inject_ruffle_and_wait(browser);
browser.switchToFrame(browser.$("#test-frame"));
browser.$("<ruffle-object />").waitForExist();
const actual = browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
it("polyfills even after a reload", () => {
// Contaminate the old contents, to ensure we get a "fresh" state
browser.execute(() => {
document.getElementById("test-container").remove();
});
// Then reload
browser.switchToParentFrame();
browser.$("#reload-link").click();
// And finally, check
browser.switchToParentFrame();
browser.switchToFrame(browser.$("#test-frame"));
browser.$("<ruffle-object />").waitForExist();
const actual = browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
expect(actual).html.to.equal(expected);
});
});

View File

@ -0,0 +1,9 @@
<ruffle-object
type="application/x-shockwave-flash"
data="/test_assets/example.swf"
width="550"
height="400"
>
<param name="movie" value="/test_assets/example.swf" />
<param name="quality" value="high" />
</ruffle-object>

View File

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>FAKE CONTENT</title>
<style>
* {
margin: 0;
}
</style>
<script>
window.RufflePlayer = window.RufflePlayer || {};
window.RufflePlayer.config = {
polyfills: [
"static-content",
"plugin-detect",
"dynamic-content",
"frames",
],
};
</script>
<script src="/dist/ruffle.js" type="text/javascript"></script>
</head>
<body>
<a href="inner.html" target="content" id="reload-link">Reload frame</a>
<iframe
width="550"
height="400"
src="inner.html"
scrolling="no"
frameborder="0"
name="content"
id="test-frame"
></iframe>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>REAL CONTENT</title>
<style>
* {
margin: 0;
}
</style>
</head>
<body>
<div id="test-container">
<object
type="application/x-shockwave-flash"
data="/test_assets/example.swf"
width="550"
height="400"
>
<param name="movie" value="/test_assets/example.swf" />
<param name="quality" value="high" />
</object>
</div>
</body>
</html>

View File

@ -5,16 +5,14 @@ const fs = require("fs");
use(chaiHtml); use(chaiHtml);
describe("Flash inside iframe", () => { describe("Flash inside iframe with provided ruffle", () => {
it("loads the test", () => { it("loads the test", () => {
open_test(browser, __dirname); open_test(browser, __dirname);
}); });
it("polyfills inside an iframe", () => { it("polyfills inside an iframe", () => {
browser.switchToFrame(browser.$("#test-frame")); browser.switchToFrame(browser.$("#test-frame"));
browser.waitUntil(() => browser.$("<ruffle-object />").waitForExist();
browser.execute(() => document.readyState === "complete")
);
const actual = browser.$("#test-container").getHTML(false); const actual = browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8"); const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");
@ -34,9 +32,7 @@ describe("Flash inside iframe", () => {
// And finally, check // And finally, check
browser.switchToParentFrame(); browser.switchToParentFrame();
browser.switchToFrame(browser.$("#test-frame")); browser.switchToFrame(browser.$("#test-frame"));
browser.waitUntil(() => browser.$("<ruffle-object />").waitForExist();
browser.execute(() => document.readyState === "complete")
);
const actual = browser.$("#test-container").getHTML(false); const actual = browser.$("#test-container").getHTML(false);
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8"); const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8");