Bug 1418930 Part 5: Add a test of shape-outside with and without a CORS violation. r=emilio

MozReview-Commit-ID: KI4itQ1ORYJ

--HG--
extra : rebase_source : bd32a21627d49eb487bba2b45cf3bfd0ffc945be
This commit is contained in:
Brad Werth 2018-01-31 17:02:14 -05:00
parent 5d511edc2c
commit bd10ac8a0f
4 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,60 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
.container {
clear: both;
width: 500px;
}
.shaper {
width: 50px;
height: 50px;
float: left;
background-color: green;
}
.shapeAllow {
shape-outside: url("support/1x1-transparent.png");
}
.shapeRefuse {
shape-outside: url("http://example.com/layout/style/test/support/1x1-transparent.png");
}
.sibling {
display: inline-block;
}
</style>
<script>
const DOMAIN = "http://mochi.test:8888";
function sendResults() {
let divAllow = document.getElementById("allow");
let divAllowSib = divAllow.nextElementSibling;
window.parent.postMessage({
"result": (divAllowSib.getBoundingClientRect().left == divAllow.getBoundingClientRect().left),
"message": "Test 1: Sibling is at same left offset as div (shape-outside was allowed).",
"todo": true,
},
DOMAIN);
let divRefuse = document.getElementById("refuse");
let divRefuseSib = divRefuse.nextElementSibling;
window.parent.postMessage({
"result": (divRefuseSib.getBoundingClientRect().left != divRefuse.getBoundingClientRect().left),
"message": "Test 2: Sibling is at different left offset from div (shape-outside was refused).",
},
DOMAIN);
window.parent.postMessage({"done": true}, DOMAIN);
}
</script>
</head>
<body onload="sendResults()">
<div class="container">
<div id="allow" class="shaper shapeAllow"></div><div class="sibling">allow (image is blank, so text is flush left)</div>
</div>
<div class="container">
<div id="refuse" class="shaper shapeRefuse"></div><div class="sibling">refuse (image unread, so text is moved to box edge)</div>
</div>
</body>
</html>

View File

@ -295,6 +295,10 @@ skip-if = toolkit == 'android' # bug 1328522
skip-if = toolkit == 'android' #bug 775227
[test_selectors_on_anonymous_content.html]
[test_setPropertyWithNull.html]
[test_shape_outside_CORS.html]
support-files =
file_shape_outside_CORS.html
support/1x1-transparent.png
[test_shorthand_property_getters.html]
[test_specified_value_serialization.html]
support-files = file_specified_value_serialization_individual_transforms.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 B

View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Test: shape-outside with a CORS violation</title>
<link rel="author" title="Brad Werth" href="mailto:bwerth@mozilla.com"/>
<link rel="help" href="https://drafts.csswg.org/css-shapes/#shape-outside-property"/>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<script>
SimpleTest.waitForExplicitFinish();
// We'll eventually receive messages from our iframe, so prep to receive them here.
function receiveMessage(event)
{
if (event.data.done) {
// Remove ourself as an event listener, just to be thorough.
window.removeEventListener("message", receiveMessage);
// Undo our meddling in preferences, then finish the test.
SpecialPowers.popPrefEnv(SimpleTest.finish);
return;
}
let reportResult = event.data.todo ? todo : ok;
reportResult(event.data.result, event.data.message);
}
function runTests()
{
window.addEventListener("message", receiveMessage);
// Set a pref that we'll need, then set the source of the iframe.
// Once the iframe source is set, the contents will start sending
// messages to us.
SpecialPowers.pushPrefEnv({"set": [
["layout.css.shape-outside.enabled", true],
]}, () => {
let content = document.getElementById("content");
content.src = "file_shape_outside_CORS.html";
});
}
</script>
</head>
<body onload="runTests()">
<iframe id="content"></iframe>
</body>
</html>