Bug 1367028 part 3 - Add tests for the new serialization code. r?dholbert
MozReview-Commit-ID: GuoOCAKTUuB
--- a/layout/style/test/test_computed_style.html
+++ b/layout/style/test/test_computed_style.html
@@ -559,12 +559,67 @@ var noframe_container = document.getElem
p.style.backgroundImage = test[0];
is(cs.backgroundImage, test[1],
"computed value of prefixed gradient expression (" + test[2] + ")");
}
p.remove();
})();
+(function test_bug_1367028() {
+ const borderImageSubprops = [
+ "border-image-slice",
+ "border-image-outset",
+ "border-image-width"
+ ];
+ const rectValues = [
+ {
+ values: ["5 5 5 5", "5 5 5", "5 5", "5"],
+ expected: "5",
+ desc: "identical four sides",
+ },
+ {
+ values: ["5 6 5 6", "5 6 5", "5 6"],
+ expected: "5 6",
+ desc: "identical values on each axis",
+ },
+ {
+ values: ["5 6 7 6", "5 6 7"],
+ expected: "5 6 7",
+ desc: "identical values on left and right",
+ },
+ {
+ values: ["5 6 5 7"],
+ desc: "identical values on top and bottom",
+ },
+ {
+ values: ["5 5 6 6", "5 6 6 5"],
+ desc: "identical values on unrelated sides",
+ },
+ {
+ values: ["5 6 7 8"],
+ desc: "different values on all sides",
+ },
+ ];
+
+ let frameContainer = document.getElementById("display");
+ let p = document.createElement("p");
+ frameContainer.appendChild(p);
+ let cs = getComputedStyle(p);
+
+ for (let prop of borderImageSubprops) {
+ for (let {values, expected, desc} of rectValues) {
+ for (let value of values) {
+ p.style.setProperty(prop, value);
+ is(cs.getPropertyValue(prop),
+ expected ? expected : value, `${desc} for ${prop}`);
+ p.style.removeProperty(prop);
+ }
+ }
+ }
+
+ p.remove();
+})();
+
</script>
</pre>
</body>
</html>
--- a/layout/style/test/test_specified_value_serialization.html
+++ b/layout/style/test/test_specified_value_serialization.html
@@ -168,12 +168,66 @@
p.style.backgroundImage = test[0];
is(p.style.backgroundImage, test[1],
"serialization value of gradient expression (" + test[2] + ")");
}
p.remove();
})();
+(function test_bug_1367028() {
+ const borderImageSubprops = [
+ "border-image-slice",
+ "border-image-outset",
+ "border-image-width"
+ ];
+ const rectValues = [
+ {
+ values: ["5 5 5 5", "5 5 5", "5 5", "5"],
+ expected: "5",
+ desc: "identical four sides",
+ },
+ {
+ values: ["5 6 5 6", "5 6 5", "5 6"],
+ expected: "5 6",
+ desc: "identical values on each axis",
+ },
+ {
+ values: ["5 6 7 6", "5 6 7"],
+ expected: "5 6 7",
+ desc: "identical values on left and right",
+ },
+ {
+ values: ["5 6 5 7"],
+ desc: "identical values on top and bottom",
+ },
+ {
+ values: ["5 5 6 6", "5 6 6 5"],
+ desc: "identical values on unrelated sides",
+ },
+ {
+ values: ["5 6 7 8"],
+ desc: "different values on all sides",
+ },
+ ];
+
+ let frameContainer = document.getElementById("display");
+ let p = document.createElement("p");
+ frameContainer.appendChild(p);
+
+ for (let prop of borderImageSubprops) {
+ for (let {values, expected, desc} of rectValues) {
+ for (let value of values) {
+ p.style.setProperty(prop, value);
+ is(p.style.getPropertyValue(prop),
+ expected ? expected : value, `${desc} for ${prop}`);
+ p.style.removeProperty(prop);
+ }
+ }
+ }
+
+ p.remove();
+})();
+
</script>
</pre>
</body>
</html>