Bug 1520018: Add web-platform-test for table element's UA-stylesheet-provided CSS rules. r=heycam
authorDaniel Holbert <dholbert@cs.stanford.edu>
Tue, 26 Feb 2019 19:29:58 +0000
changeset 519131 7754ccd4cb02ef10f9e5c90b6da3a122ae5e53e3
parent 519130 cabd5a85dc0fe6a4a40fb93025801b34a01e0262
child 519132 1d7d1c75a9a561b3356f0ad8183f6d6759728200
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1520018
milestone67.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 1520018: Add web-platform-test for table element's UA-stylesheet-provided CSS rules. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D20892
testing/web-platform/tests/html/rendering/non-replaced-elements/tables/table-ua-stylesheet.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/rendering/non-replaced-elements/tables/table-ua-stylesheet.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Test for table element's UA-stylesheet-provided styles</title>
+<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#the-css-user-agent-style-sheet-and-presentational-hints">
+<link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#tables-2">
+<link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<div id="refElem"></div>
+<!-- Note: this test puts the table inside of an element with a non-default
+     'text-indent' and 'border-collapse' values, so that we can verify that
+     the table does indeed use the initial value for these properties, rather
+     than simply inheriting. -->
+<div style="text-indent: 100px; border-collapse: collapse">
+  <table id="tableElem"></table>
+</div>
+
+<script>
+/* These styles come from the default `table` styling here:
+ *  https://html.spec.whatwg.org/multipage/rendering.html#tables-2
+ * We can't check for these values directly, because they may be
+ * serialized slightly differently when read from the computed style.
+ * So, for each property here, we apply it to a "reference" div and then
+ * read back the computed value, and we validate that a table element
+ * has that same computed value by default. */
+const defaultTablePropVals = {
+  'display':         'table',
+  'box-sizing':      'border-box',
+  'border-spacing':  '2px',
+  'border-collapse': 'separate',
+  'text-indent':     'initial',
+};
+
+for (var propName in defaultTablePropVals) {
+  test(function() {
+    refElem.style[propName] = defaultTablePropVals[propName];
+    let expectedComputedVal = getComputedStyle(refElem, "")[propName];
+
+    let actualComputedVal = getComputedStyle(tableElem, "")[propName];
+    assert_equals(actualComputedVal, expectedComputedVal);
+  }, `Computed '${propName}' on table should match html spec`);
+}
+</script>