-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web: Fix 100% height when that equals 0
- Loading branch information
1 parent
7f416f8
commit 420c164
Showing
5 changed files
with
164 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
web/packages/selfhosted/test/polyfill/percent-height-when-zero/expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div id="result_1">200</div><div id="result_2">0</div><div id="result_3">50</div><div id="result_4">200</div><div id="result_5">50</div><div id="result_6">0</div> |
57 changes: 57 additions & 0 deletions
57
web/packages/selfhosted/test/polyfill/percent-height-when-zero/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>PERCENT-BASED-HEIGHT</title> | ||
</head> | ||
<body> | ||
<div style="height: 0px;"> | ||
<div> | ||
<embed id="content_1" width="100%" height="100%" src="/test_assets/example.swf"></embed> | ||
</div> | ||
</div> | ||
<div style="height: 0px;"> | ||
<embed id="content_2" width="100%" height="100%" src="/test_assets/example.swf"></embed> | ||
</div> | ||
<div style="height: 50px;"> | ||
<embed id="content_3" width="100%" height="100%" src="/test_assets/example.swf"></embed> | ||
</div> | ||
<embed id="content_4" width="100%" height="100%" src="/test_assets/example.swf"></embed> | ||
<embed id="content_5" width="100%" height="50px" src="/test_assets/example.swf"></embed> | ||
<embed id="content_6" width="100%" height="0px" src="/test_assets/example.swf"></embed> | ||
<div id="result"></div> | ||
<script> | ||
function writeResult(res, index) { | ||
const resultDiv = document.createElement("div"); | ||
resultDiv.textContent = res; | ||
resultDiv.id = "result_" + index; | ||
const result = document.getElementById("result"); | ||
for (let i = index + 1; i <= 6; i++) { | ||
const nextResult = document.getElementById("result_" + i); | ||
if (nextResult) { | ||
result.insertBefore(resultDiv, nextResult); | ||
return; | ||
} | ||
} | ||
result.appendChild(resultDiv); | ||
} | ||
function checkClientHeight(content) { | ||
const index = parseInt(content.id.replace(/^\D+/g, '')); | ||
setTimeout(() => writeResult(content.clientHeight, index), 1000); | ||
} | ||
document.addEventListener("DOMContentLoaded", () => { | ||
const observer = new MutationObserver(function (mutationsList) { | ||
for (const mutation of mutationsList) { | ||
if (mutation && mutation.addedNodes && mutation.addedNodes.length > 0) { | ||
const node = mutation.addedNodes[0]; | ||
if (node && node.nodeName === "RUFFLE-EMBED") { | ||
node.addEventListener("loadeddata", () => checkClientHeight(node)); | ||
} | ||
} | ||
} | ||
}); | ||
observer.observe(document, { childList: true, subtree: true }); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
25 changes: 25 additions & 0 deletions
25
web/packages/selfhosted/test/polyfill/percent-height-when-zero/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { openTest, injectRuffleAndWait } = require("../../utils"); | ||
const { expect, use } = require("chai"); | ||
const chaiHtml = require("chai-html"); | ||
const fs = require("fs"); | ||
|
||
use(chaiHtml); | ||
|
||
describe("Get correct sizes for Flash embeds with percent-based heights", () => { | ||
it("loads the test", async () => { | ||
await openTest(browser, __dirname); | ||
}); | ||
|
||
it("is the correct height", async () => { | ||
await injectRuffleAndWait(browser); | ||
await browser.$("#result_1").waitForExist(); | ||
await browser.$("#result_2").waitForExist(); | ||
await browser.$("#result_3").waitForExist(); | ||
await browser.$("#result_4").waitForExist(); | ||
await browser.$("#result_5").waitForExist(); | ||
await browser.$("#result_6").waitForExist(); | ||
const actual = await browser.$("#result").getHTML(false); | ||
const expected = fs.readFileSync(`${__dirname}/expected.html`, "utf8"); | ||
expect(actual).html.to.equal(expected); | ||
}); | ||
}); |