Bug 1418930 Part 6: Add a test of shape-outside with and without a CORS violation. draft
authorBrad Werth <bwerth@mozilla.com>
Wed, 31 Jan 2018 17:02:14 -0500
changeset 751875 801e9d09b215f0cf975faf7b1558bb34053c829b
parent 751874 8a74c1b92c03ff74e2c876e68174fd2f1dcbcff0
child 751876 b973da00ae02f24aebc93594aebe394fe5a6878f
push id98080
push userbwerth@mozilla.com
push dateWed, 07 Feb 2018 01:10:26 +0000
bugs1418930
milestone60.0a1
Bug 1418930 Part 6: Add a test of shape-outside with and without a CORS violation. MozReview-Commit-ID: KI4itQ1ORYJ
layout/style/test/file_shape_outside_CORS.html
layout/style/test/mochitest.ini
layout/style/test/support/1x1-transparent.png
layout/style/test/test_shape_outside_CORS.html
new file mode 100644
--- /dev/null
+++ b/layout/style/test/file_shape_outside_CORS.html
@@ -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>
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -291,16 +291,20 @@ skip-if = toolkit == 'android' # bug 132
 [test_root_node_display.html]
 [test_rule_insertion.html]
 [test_rule_serialization.html]
 [test_rules_out_of_sheets.html]
 [test_selectors.html]
 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
 [test_style_attr_listener.html]
 [test_style_attribute_quirks.html]
 [test_style_attribute_standards.html]
 [test_style_struct_copy_constructors.html]
 [test_stylesheet_additions.html]
new file mode 100644
index 0000000000000000000000000000000000000000..56cd9eb9309219771ca16fd3fbbd300365ccc04f
GIT binary patch
literal 89
zc%17D@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k8}bl&H|6fVg?3oVGw3ym^DWND9G*U
h;uyklJvo7aiGhKYf$@<V>ujJfgQu&X%Q~loCICU@4)_27
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_shape_outside_CORS.html
@@ -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>