Bug 1418930 Part 6: Add a test of shape-outside with and without a CORS violation. r=emilio
authorBrad Werth <bwerth@mozilla.com>
Wed, 31 Jan 2018 17:02:14 -0500
changeset 402817 8554668651cc3364e840b14e784d6e317cac264c
parent 402816 e187bbe58b54f821d0c29645d6a5154a897d8960
child 402818 7a8fceb25ceb98647574a44de81a74f24a25ed1b
push id99659
push useraciure@mozilla.com
push dateWed, 07 Feb 2018 22:33:57 +0000
treeherdermozilla-inbound@5ceb1098fef3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1418930
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1418930 Part 6: Add a test of shape-outside with and without a CORS violation. r=emilio 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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..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>